:root {
  --ink: #fff6df;
  --soft: #ecd8b0;
  --gold: #e6b54a;
  --font: "Noto Sans SC", "PingFang SC", sans-serif;
  --display: "Fredoka", "Noto Sans SC", sans-serif;
  --ipa: "Andika", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #12160f;
}

button { font-family: inherit; cursor: pointer; border: 0; }

.hidden { display: none !important; }

.app {
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background: #182016;
}

.app[data-world="1"] { background: #1a2e22; }
.app[data-world="2"] { background: #2a1c12; }
.app[data-world="3"] { background: #1a1012; }

.sky,
.haze {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(10, 14, 10, 0.42), rgba(10, 12, 8, 0.28)),
    url("../assets/ipa-forest-bg.png") center / cover no-repeat,
    linear-gradient(180deg, #2c3d28, #141910 70%);
}

.app[data-world="1"] .sky {
  background:
    linear-gradient(180deg, rgba(8, 16, 12, 0.28), rgba(8, 12, 8, 0.18)),
    url("../assets/ipa-nest-bg.png") center / cover no-repeat;
}

.app[data-world="2"] .sky {
  background:
    linear-gradient(180deg, rgba(16, 10, 6, 0.3), rgba(12, 8, 6, 0.2)),
    url("../assets/ipa-forest-bg.png") center / cover no-repeat;
}

.app[data-world="3"] .sky {
  background:
    linear-gradient(180deg, rgba(8, 6, 6, 0.38), rgba(8, 6, 6, 0.22)),
    url("../assets/ipa-bunker-bg.png") center / cover no-repeat;
}

.haze {
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 12, 8, 0.16), transparent 30%, rgba(8, 8, 6, 0.28));
}

.screen {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 230, 170, 0.1), transparent 42%),
    rgba(28, 20, 14, 0.82);
  border: 1px solid rgba(232, 196, 120, 0.28);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 230, 180, 0.14);
  backdrop-filter: blur(10px);
}

.title-stack {
  position: absolute;
  left: 28px;
  top: 28px;
  width: min(440px, calc(100% - 180px));
  padding: 22px 24px 20px;
  border-radius: 24px;
}

.kicker,
.title-en {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.title-stack h1,
.panel h2,
.board h2 {
  margin: 8px 0 0;
  font-family: var(--display);
  line-height: 1.1;
  color: #fff6df;
}

.title-stack h1 {
  font-size: clamp(28px, 5vw, 48px);
  text-shadow: 0 4px 0 #2a1a0c;
}

.title-en { margin-top: 10px; font-size: 16px; }

.home-progress {
  position: absolute;
  top: 26px;
  right: 28px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  color: #3d220c;
  background: linear-gradient(180deg, #ffe08a, #d7a03c);
  border: 3px solid #7a4814;
}

.home-panel {
  position: absolute;
  left: 50%;
  bottom: 5vh;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 36px));
  padding: 22px 24px 24px;
  text-align: center;
  border-radius: 24px;
}

.lede,
.tip {
  margin: 8px 0 0;
  color: var(--soft);
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.primary,
.ghost,
.back,
.listen,
.link-btn {
  padding: 12px 22px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 999px;
}

.primary {
  color: #fff8e8;
  background: linear-gradient(180deg, #3d8a4a, #226330);
  border: 3px solid #123818;
  box-shadow: 0 6px 0 #0a1c0e;
}

.primary.big { padding: 15px 36px; font-size: 24px; }
.primary:hover { transform: translateY(1px); }

.ghost,
.back,
.link-btn {
  color: #3d220c;
  text-decoration: none;
  background: linear-gradient(180deg, #ffe7a8, #e2b24a);
  border: 3px solid #7a4814;
  box-shadow: 0 6px 0 #4a2a08;
}

.link-btn { display: inline-block; }

.listen {
  margin-top: 6px;
  padding: 7px 12px;
  font-size: 14px;
  color: #fff8e8;
  background: linear-gradient(180deg, #2a7a6e, #145248);
  border: 3px solid #083830;
  box-shadow: 0 4px 0 #042420;
}

.panel-wrap {
  min-height: 100dvh;
  padding: 28px 22px;
}

.panel.wide {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 22px;
  border-radius: 28px;
}

.panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.help-grid,
.world-grid,
.stage-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.help-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(20, 10, 6, 0.28);
  border: 2px solid rgba(232, 195, 106, 0.28);
}

.help-card strong { display: block; margin-bottom: 6px; }

.world-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.world-card,
.stage-node {
  text-align: left;
  padding: 16px;
  border-radius: 20px;
  color: #3d220c;
  border: 3px solid #5a3010;
  box-shadow: 0 8px 0 #2a1406;
}

.world-card {
  background: linear-gradient(180deg, #fff1c4, #e2b24a);
  min-height: 210px;
}

.world-card.nest { background: linear-gradient(180deg, #d9f2c8, #7cbc6a); }
.world-card.mushroom { background: linear-gradient(180deg, #ffe1b0, #e08a3a); }
.world-card.bomb { background: linear-gradient(180deg, #ffd0c4, #d45454); }

.world-card h3 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 26px;
}

.world-card p { margin: 6px 0 0; color: #4a3014; }

.world-card.open:hover,
.stage-node.open:hover { transform: translateY(-3px); }

.world-card .done {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 12, 8, 0.16);
  font-weight: 800;
}

.stage-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.stage-node {
  background: linear-gradient(180deg, #fff4d2, #e8c36a);
  min-height: 132px;
}

.stage-node .stage-num {
  font-family: var(--display);
  font-size: 28px;
}

.stage-node strong { display: block; margin-top: 4px; font-size: 16px; }

.stage-node .meta {
  margin-top: 8px;
  font-size: 13px;
  color: #6a4018;
}

.stage-node.done {
  background: linear-gradient(180deg, #dff6c8, #8fce6e);
}

.play { min-height: 100dvh; }

#stage {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  pointer-events: none;
}

.cue {
  position: relative;
  overflow: hidden;
  min-width: min(320px, 42vw);
  padding: 10px 28px 12px;
  border-radius: 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(64, 44, 22, 0.78), rgba(18, 12, 8, 0.88));
  border: 1px solid rgba(232, 196, 120, 0.42);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 230, 180, 0.2);
  backdrop-filter: blur(8px);
}

.cue[hidden] { display: none !important; }

.cue-halo {
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 50% 42%, rgba(255, 214, 90, 0.5), transparent 58%);
  opacity: 0;
  pointer-events: none;
}

.cue-kicker {
  position: relative;
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  color: #e8c36a;
}

.cue-word {
  position: relative;
  margin: 4px 0 0;
  font-family: var(--ipa);
  font-size: clamp(30px, 4.6vw, 50px);
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: #f3e2b0;
  text-shadow: 0 2px 0 #1a1208;
}

.cue-word::after {
  content: "";
  display: block;
  width: 0;
  height: 3px;
  margin: 7px auto 0;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, #ffe08a, transparent);
}

.cue-ipa {
  position: relative;
  margin: 2px 0 0;
  min-height: 1.2em;
  font-family: var(--ipa);
  font-size: clamp(22px, 3.2vw, 32px);
  color: transparent;
}

.cue.speak {
  background:
    linear-gradient(180deg, rgba(42, 30, 16, 0.82), rgba(16, 12, 8, 0.9));
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.38),
    inset 0 0 18px rgba(255, 196, 90, 0.06);
}

.cue.speak .cue-word {
  color: #e8d6a4;
  animation: cuePulse 1.1s ease-in-out infinite;
}

.cue.lit {
  border-color: #ffe9a8;
  background:
    linear-gradient(180deg, #c9922a, #7a4a10);
  box-shadow:
    0 0 0 3px rgba(255, 224, 138, 0.55),
    0 0 48px rgba(255, 186, 54, 0.85),
    inset 0 0 28px rgba(255, 236, 170, 0.28);
}

.cue.lit .cue-halo {
  opacity: 1;
  animation: haloBloom 0.8s ease;
}

.cue.lit .cue-word {
  color: #fff8d2;
  text-shadow: 0 0 12px #ffe08a, 0 0 28px #ffb347, 0 2px 0 #5a3a10;
  animation: wordLit 0.75s ease;
}

.cue.lit .cue-word::after {
  width: 78%;
  transition: width 0.45s ease;
}

.cue.lit .cue-ipa {
  color: #ffe08a;
  text-shadow: 0 0 10px rgba(255, 210, 90, 0.55);
}

@keyframes cuePulse {
  0%, 100% { opacity: 0.78; text-shadow: 0 0 0 transparent; }
  50% { opacity: 1; text-shadow: 0 0 16px rgba(255, 214, 120, 0.55); }
}

@keyframes wordLit {
  0% { transform: scale(0.9); filter: brightness(0.65); }
  40% { transform: scale(1.12); filter: brightness(1.45); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes haloBloom {
  0% { opacity: 0; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

.hud button { pointer-events: auto; }

.board {
  border-radius: 16px;
  padding: 8px 12px 10px;
  max-width: min(260px, 42vw);
  background:
    linear-gradient(180deg, rgba(255, 230, 170, 0.1), transparent 40%),
    rgba(28, 20, 14, 0.78);
  border: 1px solid rgba(232, 196, 120, 0.28);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.board.compact h2 {
  margin: 4px 0 0;
  font-size: 16px;
}

.status {
  min-width: 148px;
  text-align: right;
  color: #3d220c;
  background: linear-gradient(180deg, #ffe08a, #d7a03c);
  border-color: #7a4814;
}

.status p { margin: 0 0 4px; font-weight: 800; font-size: 14px; }

.bomb-clock {
  font-family: var(--ipa);
  font-size: 28px;
  color: #ff6a4a;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 7;
  margin: 0;
  padding: 10px 20px;
  border-radius: 999px;
  pointer-events: none;
  background: #2a150a;
  border: 2px solid #c9a056;
  font-family: var(--ipa);
  font-weight: 800;
}

.result-card {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 36px));
  text-align: center;
  padding: 24px;
  border-radius: 28px;
  z-index: 8;
}

.result-letters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.result-letters span,
.result-letters .word-chip {
  min-width: 120px;
  padding: 12px 16px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-family: var(--ipa);
  font-size: 22px;
  font-weight: 800;
  color: #fff8d2;
  background: linear-gradient(180deg, #5a8a42, #2d6b38);
  border: 1px solid #ffe08a;
  box-shadow:
    0 0 0 1px rgba(255, 224, 138, 0.28),
    0 0 16px rgba(255, 196, 80, 0.35);
  animation: wordLit 0.7s ease;
}

.result-score {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 42px;
  color: var(--gold);
}

@media (max-width: 900px) {
  .world-grid { grid-template-columns: 1fr; }
  .stage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .help-grid { grid-template-columns: 1fr; }
  .stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .title-stack { left: 16px; top: 18px; width: calc(100% - 32px); }
  .home-progress { top: auto; bottom: 28vh; right: 18px; }
  .hud { padding: 12px; flex-wrap: wrap; }
  .cue { order: -1; width: 100%; min-width: 0; }
}
