:root {
  --ink: #5c3317;
  --ink-soft: #7b4b28;
  --cream: #fdf5e2;
  --cream-deep: #f5e2bc;
  --slot-bg: #ecd09c;
  --gold: #f4c44e;
  --gold-bright: #ffd966;
  --gold-deep: #dfa530;
  --orange-warm: #e67e35;
  --sage: #7ab369;
  --sage-deep: #518744;
  --sky-card: #d9ecf2;
  --rose-card: #f7dad9;
  --mint-card: #dcecd3;
  --butter-card: #fcedbd;
  --lav-card: #e8def5;
  --peach-card: #fce1cb;
  --danger: #d9534f;
  --font-ko: 'Jua', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  --font-en: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #f5ebd4;
  color: var(--ink);
  font-family: var(--font-ko);
  overflow: hidden;
}

.desktop-backdrop {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 248, 226, 0.9), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(244, 196, 78, 0.25), transparent 50%),
    repeating-linear-gradient(
      45deg,
      #f2e5c9 0px,
      #f2e5c9 14px,
      #efe0c0 14px,
      #efe0c0 28px
    );
}

.game-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  background: #fcf4df;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(70, 38, 14, 0.26);
}

@media (min-width: 480px) {
  .game-shell {
    height: min(96dvh, 860px);
    border-radius: 26px;
    border: 4px solid var(--ink);
  }
}

/* ================= Screens (Home / Stage Select / Game) ================= */
.screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.screen.hidden {
  display: none;
}

.home-screen {
  position: relative;
  justify-content: space-between;
  padding: 16px 18px 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 249, 232, 0.92) 0%, rgba(252, 238, 202, 0.86) 55%, rgba(244, 210, 140, 0.88) 100%),
    url('../assets/room-bg-1.png') center 22% / cover no-repeat;
}

.home-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-brand-ribbon {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #ffe07d 0%, #f1b636 100%);
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  box-shadow: 0 3px 0 var(--ink);
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto 0;
}

.home-logo {
  margin: 0;
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 50px;
  line-height: 1.05;
  color: #ffb82e;
  -webkit-text-stroke: 2.5px var(--ink);
  text-shadow: 0 5px 0 var(--ink), 0 10px 18px rgba(70, 38, 14, 0.25);
  letter-spacing: 0.5px;
}

.home-subtitle {
  margin: 6px 0 8px;
  font-size: 20px;
  color: var(--ink);
}

.home-level-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(255, 250, 236, 0.92);
  font-size: 12px;
  color: var(--ink-soft);
}

.home-emblem {
  margin: 18px 0 12px;
  animation: gentleFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 14px rgba(70, 38, 14, 0.18));
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.home-progress-pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #b5834a;
  background: rgba(255, 248, 229, 0.94);
  font-size: 13px;
  color: var(--ink);
}

.home-actions {
  display: grid;
  gap: 10px;
}

.home-start-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, #ffe169 0%, #f1b12e 100%);
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink), inset 0 4px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.home-start-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.home-secondary-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: rgba(255, 249, 234, 0.96);
  color: var(--ink);
  font-family: var(--font-ko);
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}

.home-secondary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

/* Stage Select Screen */
.stages-screen {
  background: #fbf2dc;
}

.stage-pill-static {
  cursor: default;
}

.stage-pill-static:active {
  transform: none;
  box-shadow: 0 3px 0 var(--ink);
}

.stages-continue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #faebc8;
  border-bottom: 2.5px solid var(--ink);
}

.stages-continue-tag {
  font-size: 11px;
  color: #a94c10;
}

.stages-continue-title {
  font-size: 15px;
  color: var(--ink);
}

.stages-continue-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.unlock-chip-btn {
  padding: 7px 10px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: #fff8e6;
  color: var(--ink);
  font-family: var(--font-ko);
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}

.unlock-chip-btn.active {
  background: #d8efc9;
  color: #2d5c20;
}

.play-mini-btn {
  padding: 7px 13px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #ffe074 0%, #f1b636 100%);
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}

.stages-screen-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

/* ================= Top Header ================= */
.top-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 9px;
  background: linear-gradient(180deg, #f9cf5b 0%, #f1b83b 100%);
  border-bottom: 3px solid var(--ink);
  box-shadow: inset 0 -3px 0 rgba(160, 96, 20, 0.22);
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 13px;
  border: 2.5px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: var(--ink);
}

.btn-q {
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 21px;
  line-height: 1;
}

.stage-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-ko);
  transition: transform 0.1s ease;
}

.stage-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.stage-num {
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.4px;
  color: var(--ink);
  line-height: 1.15;
}

.pattern-badge {
  font-size: 13px;
  color: #b45314;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ================= Compact HUD Bar ================= */
.hud-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #faebc8;
  border-bottom: 2.5px solid var(--ink);
}

.hud-hearts {
  display: flex;
  align-items: center;
  gap: 3px;
}

.heart-icon {
  font-size: 17px;
  line-height: 1;
  color: #e4504b;
  text-shadow: 0 1px 0 var(--ink);
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.heart-icon.lost {
  opacity: 0.28;
  filter: grayscale(1);
  transform: scale(0.84);
}

.combo-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #fff8e6;
  border: 2px solid var(--ink);
}

.combo-text {
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 12px;
  color: #b54d12;
  letter-spacing: 0.3px;
}

.charge-pips {
  display: flex;
  align-items: center;
  gap: 3px;
}

.charge-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: #e6d1a8;
  transition: background 0.16s ease, transform 0.16s ease;
}

.charge-pip.filled {
  background: #f5b324;
  transform: scale(1.15);
}

.hint-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #fff5c8 0%, #f8d46b 100%);
  color: var(--ink);
  font-family: var(--font-ko);
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.hint-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}

.hint-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint-count-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--orange-warm);
  color: #fff;
  border: 1.5px solid var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}

/* ================= Shelf Zone (Baskets + Waiting Tray) ================= */
.shelf-zone {
  position: relative;
  z-index: 9;
  padding: 10px 10px 9px;
  background:
    radial-gradient(circle at 50% 0%, #fffdf6 0%, #faedd1 100%);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 4px 10px rgba(92, 51, 23, 0.14);
}

.baskets-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 98px;
}

.next-basket-preview {
  width: 82px;
  flex-shrink: 0;
  padding: 8px 6px;
  border-radius: 12px;
  border: 2px dashed #9d7145;
  background: rgba(247, 231, 197, 0.85);
  text-align: center;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 76px;
}

.next-preview-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e5cba0;
  color: var(--ink);
}

.next-preview-role {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.15;
}

.next-preview-count {
  font-size: 10px;
  opacity: 0.85;
}

.basket-card.basket-bounce {
  animation: basketBounce 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes basketBounce {
  0% { transform: translateY(-5px) scale(1); }
  45% { transform: translateY(-9px) scale(1.06); }
  100% { transform: translateY(-5px) scale(1); }
}

.basket-card.basket-slide-in {
  animation: basketSlideIn 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes basketSlideIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.86); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.baskets-row.count-4 {
  gap: 6px;
}

.basket-card {
  position: relative;
  flex: 1;
  max-width: 150px;
  min-width: 0;
  padding: 20px 6px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 10px 10px 14px 14px;
  background: linear-gradient(180deg, #f9ebd0 0%, #efd5a7 100%);
  box-shadow: 0 4px 0 #b88a55, inset 0 6px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  text-align: center;
  font-family: var(--font-ko);
  color: var(--ink);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.16s ease, border-color 0.16s ease;
  user-select: none;
}

/* Cardboard box top opening rim */
.basket-card::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  right: 6px;
  height: 12px;
  background: #cfa774;
  border: 2px solid var(--ink);
  border-radius: 5px;
  z-index: 1;
}

.basket-peeks {
  position: absolute;
  top: -12px;
  left: 10px;
  right: 10px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.peek-chip {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 5px;
  border: 2px solid var(--ink);
  background: #fff9e8;
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 9px;
  color: var(--ink);
  transform: rotate(var(--r, -4deg));
  box-shadow: 0 1px 0 rgba(92, 51, 23, 0.25);
  white-space: nowrap;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: peekPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes peekPop {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.75) rotate(var(--r, 0deg));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--r, 0deg));
  }
}

.basket-card.selected {
  transform: translateY(-5px);
  border-color: var(--ink);
  background: linear-gradient(180deg, #fff5d1 0%, #f8d47c 100%);
  box-shadow:
    0 0 0 3px #ffd966,
    0 6px 0 var(--ink);
}

.basket-card.selected::after {
  content: '선택됨';
  position: absolute;
  top: -11px;
  right: 6px;
  background: var(--orange-warm);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 6px;
  line-height: 1.2;
  z-index: 5;
  box-shadow: 0 2px 0 var(--ink);
}

.basket-card.completed {
  background: linear-gradient(180deg, #e5f3dc 0%, #c8e3b9 100%);
  box-shadow: 0 2px 0 #739962;
  opacity: 0.92;
  cursor: default;
}

.basket-card.completed::after {
  content: '완료!';
  position: absolute;
  top: -11px;
  right: 6px;
  background: var(--sage-deep);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 6px;
  line-height: 1.2;
  z-index: 5;
}

.basket-card.locked-basket {
  background: linear-gradient(180deg, #eadfc8 0%, #d8c6a3 100%);
  border-color: #8f7455;
  box-shadow: 0 2px 0 #a38966;
  color: #7c6448;
  opacity: 0.78;
  cursor: not-allowed;
}

.basket-card.locked-basket::before {
  background: #baa282;
  border-color: #8f7455;
}

.basket-card.locked-basket::after {
  content: '🔒 대기중';
  position: absolute;
  top: -11px;
  right: 4px;
  background: #7c6448;
  color: #fff9ec;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 9px;
  padding: 1px 5px;
  line-height: 1.2;
  z-index: 5;
}

.basket-role-badge {
  position: relative;
  z-index: 3;
  display: inline-block;
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(92, 51, 23, 0.11);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 11px;
  color: var(--ink-soft);
}

.basket-label {
  position: relative;
  z-index: 3;
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
}

.baskets-row.count-4 .basket-label {
  font-size: 15px;
}

.basket-count-pill {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  z-index: 4;
  min-width: 48px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: #fff9ec;
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(92, 51, 23, 0.25);
}

.basket-card.completed .basket-count-pill {
  background: #ebf9e3;
  color: #2f5c23;
}

/* ================= Middle Waiting Tray ================= */
.tray-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tray-frame {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 6px 7px;
  background: linear-gradient(180deg, #f9ebd0 0%, #ebd2a4 100%);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 3px 0 #b88a55;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tray-frame.danger {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(217, 83, 79, 0.35), 0 3px 0 #9f3532;
  animation: gentleShake 0.45s ease;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.tray-slot {
  height: 46px;
  border-radius: 10px;
  border: 2px solid #b58550;
  background: linear-gradient(180deg, #dfbe89 0%, #edd3a6 100%);
  box-shadow: inset 0 2px 4px rgba(92, 51, 23, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 3px;
  overflow: hidden;
  position: relative;
}

.tray-slot.filled {
  background: #fff8e6;
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  animation: slotPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slotPop {
  from { transform: scale(0.7); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.tray-word {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 11px;
  line-height: 1.08;
  color: var(--ink);
  text-align: center;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shuffle-btn {
  position: relative;
  width: 56px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #fff5dc 0%, #f4dca8 100%);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  font-family: var(--font-ko);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.shuffle-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.shuffle-count-badge {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--orange-warm);
  color: #fff;
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.shuffle-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.shuffle-btn svg {
  width: 22px;
  height: 22px;
  fill: var(--ink);
}

/* ================= Room Floor Playfield ================= */
.room-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background-color: #efce99;
  background-size: cover;
  background-position: center 22%;
  background-repeat: no-repeat;
}

.room-stage.theme-1 {
  background-image: url('../assets/room-bg-1.png');
}

.room-stage.theme-2 {
  background-image: url('../assets/room-bg-2.png');
}

/* Subtle warm vignette so scattered cards pop clearly */
.room-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 248, 229, 0.22) 0%,
    rgba(255, 248, 229, 0.04) 28%,
    rgba(255, 244, 214, 0.14) 100%
  );
  pointer-events: none;
}

.toast-pill {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 25;
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: rgba(255, 250, 236, 0.96);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 12px rgba(70, 38, 14, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-pill.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-pill.good {
  background: #e9f7df;
  color: #28561d;
}

.toast-pill.warn {
  background: #fff0d8;
  color: #9e4710;
}

.stage-subtitle-chip {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(253, 245, 226, 0.92);
  font-size: 12px;
  color: var(--ink-soft);
  pointer-events: none;
  white-space: nowrap;
}

.floor-cards {
  position: absolute;
  inset: 0;
  z-index: 10;
}

/* ================= Hand-Drawn Stationery Cards ================= */
.word-card {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  padding: 7px 11px;
  min-width: 64px;
  max-width: 134px;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  background: var(--butter-card);
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 14px;
  line-height: 1.12;
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 0 var(--ink), 0 7px 12px rgba(70, 38, 14, 0.24);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease, filter 0.18s ease;
}

.word-card .card-text {
  display: inline;
}

.word-card .card-q {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 17px;
  color: #825229;
  pointer-events: none;
}

.word-card:hover {
  transform: translate(-50%, -54%) scale(1.06) rotate(var(--rot, 0deg));
}

.word-card:active {
  transform: translate(-50%, -48%) scale(0.96) rotate(var(--rot, 0deg));
}

.word-card.blocked {
  background: repeating-linear-gradient(
    -45deg,
    #d5be98 0px,
    #d5be98 7px,
    #c7ad82 7px,
    #c7ad82 14px
  ) !important;
  filter: brightness(0.84);
  box-shadow: 0 2px 0 var(--ink);
  cursor: not-allowed;
}

.word-card.blocked::before {
  display: none;
}

.word-card.blocked .card-text {
  visibility: hidden;
}

.word-card.blocked .card-q {
  display: flex;
}

.word-card.blocked:hover,
.word-card.blocked:active {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}

.word-card.shake-blocked {
  animation: blockedWiggle 0.28s ease;
}

@keyframes blockedWiggle {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
  25% { transform: translate(-53%, -50%) rotate(calc(var(--rot, 0deg) - 4deg)); }
  75% { transform: translate(-47%, -50%) rotate(calc(var(--rot, 0deg) + 4deg)); }
}

.word-card.just-uncovered {
  animation: flipReveal 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes flipReveal {
  0% {
    transform: translate(-50%, -50%) perspective(260px) rotateY(90deg) scale(0.9) rotate(var(--rot, 0deg));
  }
  65% {
    transform: translate(-50%, -53%) perspective(260px) rotateY(-8deg) scale(1.08) rotate(var(--rot, 0deg));
  }
  100% {
    transform: translate(-50%, -50%) perspective(260px) rotateY(0deg) scale(1) rotate(var(--rot, 0deg));
  }
}

.word-card.hint-glow {
  box-shadow: 0 0 0 4px #ffd966, 0 0 18px rgba(255, 200, 40, 0.9), 0 4px 0 var(--ink);
  animation: hintPulse 0.75s ease-in-out infinite alternate;
  z-index: 88 !important;
}

@keyframes hintPulse {
  from { transform: translate(-50%, -50%) scale(1) rotate(var(--rot, 0deg)); }
  to { transform: translate(-50%, -55%) scale(1.1) rotate(var(--rot, 0deg)); }
}

.word-card.collecting {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -130%) scale(0.55) rotate(0deg);
}

.word-card.to-tray {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -95%) scale(0.7) rotate(0deg);
}

/* 6 cozy stationery variants (independent of grammatical role) */
.word-card.style-0 {
  background: #fff5cc;
  border-radius: 6px 14px 12px 12px;
}
.word-card.style-0::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 28px;
  height: 10px;
  background: rgba(230, 126, 53, 0.72);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
}

.word-card.style-1 {
  background: var(--sky-card);
  border-radius: 10px;
  box-shadow: inset 0 -4px 0 rgba(92, 51, 23, 0.12), 0 4px 0 var(--ink), 0 8px 14px rgba(70, 38, 14, 0.22);
}

.word-card.style-2 {
  background: var(--rose-card);
  border-radius: 14px 14px 4px 14px;
}

.word-card.style-3 {
  background: var(--mint-card);
  border-radius: 11px;
  padding-left: 18px;
}
.word-card.style-3::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fcf4df;
  border: 1.5px solid var(--ink);
}

.word-card.style-4 {
  background: var(--lav-card);
  border-radius: 8px;
  box-shadow: inset 4px 0 0 rgba(92, 51, 23, 0.16), 0 4px 0 var(--ink), 0 8px 14px rgba(70, 38, 14, 0.22);
}

.word-card.style-5 {
  background: var(--peach-card);
  border-radius: 16px;
}

/* ================= Modals ================= */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(54, 28, 10, 0.56);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--cream);
  border: 3.5px solid var(--ink);
  border-radius: 22px;
  padding: 18px 16px 16px;
  box-shadow: 0 8px 0 var(--ink), 0 18px 36px rgba(38, 18, 5, 0.35);
  animation: modalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-tall {
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from { transform: scale(0.88) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.close-x-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: #ffe9c2;
  color: var(--ink);
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
}

.modal-ribbon {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--gold);
  border: 2px solid var(--ink);
  font-size: 13px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.25;
  color: var(--ink);
}

.modal-subtitle {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}

.modal-desc {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.guide-example-box {
  background: #fff9ec;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.guide-ex-label {
  font-size: 12px;
  color: var(--orange-warm);
  margin-bottom: 3px;
}

.guide-ex-en {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
}

.guide-ex-ko {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.guide-tip-box {
  background: #eaf5e0;
  border: 2px solid #6b9a57;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 14px;
  line-height: 1.45;
  color: #2c5220;
  margin-bottom: 12px;
}

.guide-roles-list {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.guide-role-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #f6e7c7;
  border: 1.5px solid #c59b65;
  font-size: 13px;
}

.guide-role-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  border: 1.5px solid var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

/* Buttons */
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  font-family: var(--font-ko);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.1s ease;
}

.primary-btn:active,
.secondary-btn:active,
.danger-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.primary-btn {
  background: linear-gradient(180deg, #ffd863 0%, #f1b636 100%);
  color: var(--ink);
}

.secondary-btn {
  background: #fff7e4;
  color: var(--ink);
}

.danger-btn {
  margin-top: 12px;
  background: #fbe1df;
  color: #8f2926;
}

/* Clear Modal */
.modal-clear-card {
  text-align: center;
}

.clear-stars {
  font-size: 28px;
  color: #f0a818;
  text-shadow: 0 2px 0 var(--ink);
  margin-bottom: 4px;
}

.fail-icon {
  font-size: 36px;
  text-align: center;
  margin-bottom: 6px;
}

.review-list {
  max-height: 250px;
  overflow-y: auto;
  text-align: left;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}

.review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: #fff9ec;
  border: 2px solid #d4af7a;
}

.review-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.review-role {
  padding: 2px 7px;
  border-radius: 8px;
  background: #f5dfb0;
  border: 1.5px solid var(--ink);
  font-size: 11px;
  flex-shrink: 0;
}

.review-en {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
}

.review-ko {
  font-size: 13px;
  color: var(--ink-soft);
}

.tts-mini-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 2px solid var(--ink);
  background: #ffeaa8;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Stage Select Grid */
.stages-progress-text {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.stages-grid-wrap {
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding-right: 2px;
}

.chapter-block {
  background: #fff9ec;
  border: 2px solid #d4af7a;
  border-radius: 14px;
  padding: 10px;
}

.chapter-head {
  font-size: 14px;
  color: #a94c10;
  margin-bottom: 8px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.clear-stats-pill {
  display: inline-block;
  margin: 0 auto 10px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid #cfa36b;
  background: #fff6df;
  font-size: 12px;
  color: var(--ink-soft);
}

.stage-tile {
  height: 46px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #f9ebc9;
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
}

.tile-stars {
  font-size: 9px;
  color: #e49b12;
  margin-top: 2px;
  letter-spacing: -0.5px;
}

.stage-tile.cleared {
  background: #d8efc9;
  color: #2d5c20;
}

.stage-tile.current {
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--orange-warm);
}

.stage-tile.locked {
  background: #e6dcc8;
  color: #9e8d75;
  border-color: #a6957c;
  cursor: not-allowed;
}

/* Floating Flight & Combo FX Layer */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.flying-card {
  position: fixed;
  transform: translate(-50%, -50%);
  padding: 7px 11px;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  background: #fff7d6;
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 6px 14px rgba(70, 38, 14, 0.28);
  transition: left 0.24s cubic-bezier(0.22, 1, 0.36, 1), top 0.24s cubic-bezier(0.18, 0.89, 0.32, 1.15), transform 0.24s ease, opacity 0.24s ease;
  z-index: 999;
}

.float-callout {
  position: fixed;
  transform: translate(-50%, -50%);
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #ffd966;
  color: var(--ink);
  font-family: var(--font-en);
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 3px 0 var(--ink);
  animation: floatUpFade 0.85s ease-out forwards;
  z-index: 999;
}

.float-callout.bad {
  background: #fbd0ce;
  color: #8b1e1b;
}

@keyframes floatUpFade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
  30% { opacity: 1; transform: translate(-50%, -90%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(0.95); }
}

/* Settings */
.settings-list {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff9ec;
  border: 2px solid #d4af7a;
  cursor: pointer;
}

.setting-name {
  font-size: 15px;
  color: var(--ink);
}

.setting-hint {
  font-size: 12px;
  color: var(--ink-soft);
}

.toggle-input {
  width: 22px;
  height: 22px;
  accent-color: var(--orange-warm);
  cursor: pointer;
}

/* Confetti */
.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 95;
  overflow: hidden;
}

.confetti-bit {
  position: absolute;
  top: -14px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  animation: confettiFall 1.3s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(820px) rotate(420deg); opacity: 0; }
}
