:root {
  --ink: #1d2327;
  --muted: #65717b;
  --line: #d8dfe4;
  --paper: #f7f3ec;
  --accent: #2f7d6d;
  --accent-dark: #205a50;
  --good: #207846;
  --bad: #b64242;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  background:
    linear-gradient(135deg, rgba(47, 125, 109, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(219, 79, 116, 0.14), transparent 42%),
    var(--paper);
}

button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(380px, 1.1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100dvh;
  padding: 12px;
  overflow: hidden;
}

.game-header,
.stage-panel,
.wardrobe-panel {
  border: 1px solid rgba(29, 35, 39, 0.12);
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 16px 40px rgba(60, 48, 36, 0.1);
}

.game-header {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.title-row,
.header-actions,
.panel-header,
.level-meta,
.clue-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1, h2, h3 { margin: 0; }

h1 {
  font-family: "Fredoka", "Noto Sans SC", sans-serif;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  line-height: 1.1;
}

h2 { font-size: 1.1rem; }

h3 {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.panel-header p,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.score-card {
  min-width: 68px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
  font-weight: 800;
}

.score-card span {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.score-card small { color: var(--muted); }

.level-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.level-meta {
  justify-content: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

#promptText {
  margin: 4px 0 2px;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 900;
  cursor: pointer;
}

.clue-actions {
  justify-content: flex-end;
}

.listen-btn,
.ghost-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.listen-btn {
  color: #3d220c;
  background: linear-gradient(180deg, #ffe7a8, #e2b24a);
  border: 2px solid #7a4814;
  box-shadow: 0 3px 0 #4a2a08;
}

.ghost-btn {
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid var(--line);
}

.progress-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8ece8;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 240ms ease;
}

.stage-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding: 10px;
}

.character-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(#f4e7d4 0 68%, #b88858 68% 70%, #e5c79a 70%);
}

.character {
  position: relative;
  width: min(42vh, 300px);
  aspect-ratio: 2 / 3;
  max-width: 92%;
}

.girl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.outfit-list {
  margin: 8px 0 0;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.wardrobe-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 10px 12px;
}

.feedback {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.feedback.good {
  color: var(--good);
  border-color: rgba(32, 120, 70, 0.35);
  background: #f1fbf5;
}

.feedback.bad {
  color: var(--bad);
  border-color: rgba(182, 66, 66, 0.35);
  background: #fff5f3;
}

.wardrobe-grid {
  flex: 1 1 auto;
  min-height: 260px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 2px 4px 8px 0;
}

.shelf-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.item-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 158px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.item-btn:hover {
  border-color: rgba(47, 125, 109, 0.45);
  box-shadow: 0 8px 18px rgba(47, 125, 109, 0.12);
}

.item-btn.selected {
  outline: 3px solid rgba(47, 125, 109, 0.22);
  border-color: var(--accent);
}

.item-btn.wrong { animation: shake 360ms ease; }

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}

.item-picture {
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 108px;
  max-height: 128px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 44%, #fff, #f4f1ea 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--swatch) 10%, #fff), #f3efe8);
  overflow: hidden;
}

.item-photo,
.item-picture svg {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.item-photo { mix-blend-mode: multiply; }

.item-label {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.level-list {
  display: grid;
  grid-template-columns: repeat(10, minmax(22px, 1fr));
  gap: 5px;
  flex: 0 0 auto;
}

.jump-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.jump-btn.current {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.jump-btn.done:not(.current) {
  color: var(--accent-dark);
  background: #edf8f3;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .level-card {
    grid-template-columns: 1fr;
  }

  .clue-actions { justify-content: flex-start; }

  .stage-panel {
    min-height: 38vh;
  }

  .wardrobe-panel {
    height: auto;
  }

  .wardrobe-grid {
    flex: none;
    min-height: 0;
    overflow: visible;
  }

  .shelf-row {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
