/* ==========================================================================
   ITEMS v2.0: SEAMLESS CONNECTED POLYOMINOES, SYNERGY SPARKS & EVENT POSTCARD
   ========================================================================== */

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.tag-essential { background: #f4dcd6; color: #8f3626; border: 1px solid #ddb1a6; }
.tag-dream { background: var(--gold-soft); color: #785515; border: 1px solid #d9be82; }
.tag-emotion { background: var(--emotion-bg); color: var(--emotion-ink); border: 1px solid var(--emotion-border); }
.tag-daily { background: var(--paper-warm); color: var(--ink-secondary); border: 1px solid var(--paper-edge); }
.tag-heirloom { background: #e5ede6; color: #3d5c42; border: 1px solid #b8ccb9; }
.tag-foldable { background: #f5efe0; color: #7b643b; border: 1px dashed #c7b48b; }

/* ---------------- TRAY ITEM CARDS ---------------- */
.tray-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 9px;
  background: #fffdf8;
  border: 1.5px solid var(--paper-edge);
  border-radius: 9px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 2px 5px rgba(44, 38, 33, 0.04);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease, border-color 0.2s ease;
}

.tray-item:hover {
  transform: translateY(-2.5px);
  box-shadow: var(--shadow-paper);
  border-color: var(--accent);
}

.tray-item.selected {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(200, 109, 81, 0.16);
}

.tray-item.type-emotion {
  background: linear-gradient(155deg, #f8f5fc, #efeaf7);
  border-color: var(--emotion-border);
  border-style: dashed;
}

.tray-item.type-dream {
  background: linear-gradient(155deg, #fffdf5, #faf1db);
  border-color: #d8bc7d;
}

.tray-item.is-folded::after {
  content: "已摺";
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sage-soft);
  color: #365239;
}

.tray-item-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.tray-item-cells {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
}

.tray-item-art {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  margin: 2px 0 6px;
}

.tray-item-art svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(44, 38, 33, 0.08));
}

.tray-item-name {
  font-family: var(--font-serif);
  font-size: 12.2px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  color: var(--ink-primary);
}

.tray-item-dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-essential { background: #c24b3a; }
.dot-dream { background: #c99a45; box-shadow: 0 0 6px rgba(201, 154, 69, 0.7); }
.dot-emotion { background: #776399; }
.dot-daily { background: #a89f91; }

/* ---------------- SEAMLESS CONNECTED POLYOMINOES INSIDE SUITCASE ---------------- */
.placed-item {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 3px 6px rgba(44, 38, 33, 0.12));
  transition: transform 0.22s var(--ease-spring), filter 0.2s ease;
}

.placed-item.just-placed {
  animation: popPlace 0.3s var(--ease-spring);
}

@keyframes popPlace {
  0% { transform: scale(1.07); }
  58% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Each cell of a placed item merges seamlessly with adjacent cells of the SAME item */
.placed-cell-hit {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  pointer-events: auto;
  cursor: grab;
  border-radius: 8px;
  background: #fbf7ee;
  border: 1.8px solid rgba(118, 98, 76, 0.42);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* Seamless edge merging! */
.placed-cell-hit.conn-r {
  width: calc(var(--cell-size) + var(--cell-gap) + 1px);
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.placed-cell-hit.conn-l {
  border-left: none;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.placed-cell-hit.conn-b {
  height: calc(var(--cell-size) + var(--cell-gap) + 1px);
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.placed-cell-hit.conn-t {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.placed-item.type-essential .placed-cell-hit {
  background: #fdf2ee;
  border-color: rgba(186, 86, 65, 0.58);
}

.placed-item.type-dream .placed-cell-hit {
  background: #fef8e4;
  border-color: rgba(196, 148, 56, 0.72);
}

.placed-item.type-emotion .placed-cell-hit {
  background: #ece5f5;
  border-style: dashed;
  border-color: rgba(110, 88, 148, 0.68);
}

.placed-item.selected {
  filter: drop-shadow(0 0 0 rgba(0,0,0,0)) drop-shadow(0 6px 14px rgba(156, 74, 51, 0.28));
  z-index: 4;
}

.placed-item.selected .placed-cell-hit {
  border-color: var(--accent-deep);
}

.placed-item.in-synergy {
  filter: drop-shadow(0 0 8px rgba(201, 154, 69, 0.32));
}

.placed-art-wrap {
  position: absolute;
  inset: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.placed-art-wrap svg {
  max-width: 80%;
  max-height: 74%;
  filter: drop-shadow(0 2px 3px rgba(44, 38, 33, 0.14));
}

.placed-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 10px);
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(251, 248, 241, 0.92);
  border: 1px solid rgba(90, 74, 58, 0.18);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 4;
}

.keepsake-pin {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: #fffdf8;
  display: grid;
  place-items: center;
  font-size: 13px;
  box-shadow: 0 3px 8px rgba(130, 92, 20, 0.35);
  border: 2px solid #fffdf8;
  z-index: 7;
  pointer-events: none;
  animation: popPlace 0.3s var(--ease-spring);
}

/* ---------------- SYNERGY SEAM SPARKS & TOAST ---------------- */
.suitcase-synergy-layer {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  pointer-events: none;
  z-index: 6;
}

.synergy-spark {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #fffdf8;
  background: var(--gold);
  border: 2px solid #fffdf8;
  box-shadow: 0 3px 10px rgba(201, 154, 69, 0.45);
  pointer-events: auto;
  cursor: pointer;
  animation: sparkPulse 2.2s ease-in-out infinite;
}

.synergy-spark.mood-tension {
  background: var(--emotion-ink);
  box-shadow: 0 3px 10px rgba(90, 78, 115, 0.45);
}

.synergy-spark.mood-bittersweet {
  background: #a66c7c;
  box-shadow: 0 3px 10px rgba(143, 92, 110, 0.45);
}

@keyframes sparkPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.14); }
}

.synergy-toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(470px, calc(100% - 24px));
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(253, 250, 242, 0.97);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  z-index: 30;
  animation: slideUpToast 0.35s var(--ease-spring);
}

.synergy-toast.mood-tension {
  border-color: var(--emotion-ink);
  background: rgba(246, 242, 252, 0.97);
}

.synergy-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: #fffdf8;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.synergy-toast.mood-tension .synergy-toast-icon {
  background: var(--emotion-ink);
}

.synergy-toast-body strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 13.5px;
  color: var(--ink-primary);
  margin-bottom: 2px;
}

.synergy-toast-body p {
  font-family: var(--font-serif);
  font-size: 12.2px;
  line-height: 1.55;
  color: var(--ink-secondary);
}

@keyframes slideUpToast {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- BRASS WEIGHT GAUGE & SUITCASE STICKERS ---------------- */
.weight-gauge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 7px;
  background: var(--paper-bg);
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
}

.gauge-dial {
  position: relative;
  width: 26px;
  height: 15px;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(90deg, #9db59f 0%, #e3c278 55%, #cf745b 100%);
  border: 1.5px solid #8a7558;
  border-bottom: none;
  overflow: hidden;
}

.gauge-needle {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 12px;
  background: #2c2621;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(-50deg);
  transition: transform 0.45s var(--ease-spring);
}

.gauge-readout {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.gauge-readout small {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-muted);
}

.weight-gauge.level-heavy { border-color: var(--danger); background: #f8ebe8; }
.weight-gauge.level-heavy .gauge-readout small { color: var(--danger); font-weight: 600; }

/* Suitcase Corner Brass Protectors & Stickers */
.suitcase-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 4px solid #d9b56c;
  pointer-events: none;
  z-index: 4;
  opacity: 0.85;
}
.corner-tl { top: 2px; left: 2px; border-right: none; border-bottom: none; border-top-left-radius: 18px; }
.corner-tr { top: 2px; right: 2px; border-left: none; border-bottom: none; border-top-right-radius: 18px; }
.corner-bl { bottom: 2px; left: 2px; border-right: none; border-top: none; border-bottom-left-radius: 18px; }
.corner-br { bottom: 2px; right: 2px; border-left: none; border-top: none; border-bottom-right-radius: 18px; }

.suitcase-stickers {
  position: absolute;
  left: -26px;
  top: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 6;
}

.luggage-sticker {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1.5px solid rgba(44, 38, 33, 0.25);
  box-shadow: 0 2px 6px rgba(44, 38, 33, 0.16);
  font-family: var(--font-mono);
  text-align: center;
  line-height: 1.15;
}

.luggage-sticker strong { display: block; font-size: 9.5px; letter-spacing: 0.06em; }
.luggage-sticker span { display: block; font-size: 7.5px; opacity: 0.82; }

/* 5-Age Real Fabric Linings */
.suitcase-shell[data-lining="gingham"] .suitcase-interior {
  background-image:
    linear-gradient(90deg, rgba(196, 164, 122, 0.11) 50%, transparent 50%),
    linear-gradient(rgba(196, 164, 122, 0.11) 50%, transparent 50%);
  background-size: 26px 26px;
}

.suitcase-shell[data-lining="pinstripe"] .suitcase-interior {
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 14px,
    rgba(76, 114, 125, 0.09) 14px,
    rgba(76, 114, 125, 0.09) 16px
  );
}

.suitcase-shell[data-lining="herringbone"] .suitcase-interior {
  background-image:
    repeating-linear-gradient(45deg, rgba(102, 86, 124, 0.06) 0 4px, transparent 4px 12px),
    repeating-linear-gradient(-45deg, rgba(102, 86, 124, 0.06) 0 4px, transparent 4px 12px);
}

.suitcase-shell[data-lining="quilt"] .suitcase-interior {
  background-image:
    linear-gradient(45deg, rgba(110, 102, 92, 0.06) 25%, transparent 25%, transparent 75%, rgba(110, 102, 92, 0.06) 75%),
    linear-gradient(-45deg, rgba(110, 102, 92, 0.06) 25%, transparent 25%, transparent 75%, rgba(110, 102, 92, 0.06) 75%);
  background-size: 28px 28px;
}

.suitcase-shell[data-lining="botanical"] .suitcase-interior {
  background-image:
    radial-gradient(circle at 12px 12px, rgba(94, 122, 99, 0.09) 2px, transparent 2.5px),
    linear-gradient(90deg, transparent 49%, rgba(148, 93, 58, 0.06) 49%, rgba(148, 93, 58, 0.06) 51%, transparent 51%);
  background-size: 24px 24px;
}

/* Inspector Synergy Hint Box */
.detail-synergy-hint {
  padding: 9px 12px;
  background: #fdf6e2;
  border-left: 2.5px solid var(--gold);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.6;
  color: #6b5016;
  margin-bottom: 12px;
}

/* ---------------- MID-CHAPTER EVENT POSTCARD ---------------- */
.event-backdrop {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(34, 28, 24, 0.54);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.event-postcard {
  position: relative;
  width: min(560px, 100%);
  background: #fcf8ee;
  border: 1.5px solid #d9cbb2;
  border-radius: 10px;
  padding: 34px 36px 30px;
  box-shadow: var(--shadow-lift);
  animation: fadeScreen 0.35s var(--ease-spring);
}

.event-stamp {
  position: absolute;
  top: 22px;
  right: 26px;
  padding: 5px 9px;
  border: 1.5px dashed var(--accent);
  color: var(--accent-deep);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  transform: rotate(5deg);
}

.event-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 10px;
}

.event-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-right: 76px;
}

.event-body {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink-secondary);
  padding: 14px 16px;
  background: var(--paper-bg);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  margin-bottom: 20px;
}

.event-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-choice-btn {
  text-align: left;
  padding: 13px 16px;
  border-radius: 9px;
  background: #fffdf8;
  border: 1.5px solid var(--paper-edge);
  transition: all 0.2s var(--ease-spring);
}

.event-choice-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1.5px);
}

.event-choice-btn strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-primary);
  margin-bottom: 2px;
}

.event-choice-btn small {
  display: block;
  font-size: 12px;
  color: var(--ink-secondary);
}

/* ---------------- GHOST PREVIEW & FLOATING DRAG ---------------- */
.ghost-cell {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 7px;
  transition: transform 0.08s ease;
}

.ghost-cell.valid { background: rgba(111, 134, 114, 0.28); border: 2px solid var(--sage); }
.ghost-cell.invalid { background: rgba(184, 74, 57, 0.24); border: 2px dashed var(--danger); }

.drag-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }

.drag-floating {
  position: fixed;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.04) rotate(-1.5deg);
  filter: drop-shadow(0 18px 24px rgba(44, 38, 33, 0.24));
  transition: transform 0.12s var(--ease-spring);
}

.drag-floating .placed-cell-hit { pointer-events: none; }

.drag-hint-pill {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(44, 38, 33, 0.88);
  color: #faf6ee;
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-card);
}
