:root {
  --charcoal: #26313f;
  --night: #151b24;
  --paper: #fff8ec;
  --panel: rgba(255, 250, 238, 0.96);
  --panel-strong: #fffdf8;
  --line: rgba(38, 49, 63, 0.16);
  --muted: #5d6470;
  --copper: #c8612c;
  --amber: #f5b33d;
  --berry: #b94678;
  --leaf: #4f8b52;
  --blue: #2c718d;
  --shadow: 0 18px 42px rgba(21, 27, 36, 0.18);
  --body-font: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --display-font: "Trebuchet MS", "Aptos", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body-font);
  color: var(--charcoal);
  background:
    linear-gradient(180deg, #ffd56d 0 12%, #f68c41 12% 28%, #5e8492 28% 29%, #fff0d7 29% 100%);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.game-app {
  width: min(100% - 16px, 720px);
  height: 100dvh;
  margin: 0 auto;
  padding: 8px 0 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.top-panel,
.stage-panel,
.answer-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.top-panel {
  border-radius: 0 0 8px 8px;
  padding: 10px;
}

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

.answer-panel {
  border-radius: 8px 8px 0 0;
  padding: 10px;
}

.title-row,
.stage-header,
.answer-display-row,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.title-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.home-link {
  display: inline-flex;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.eyebrow,
.mode-pill,
.score-pill,
.timer-label {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--copper);
}

h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(1.85rem, 8vw, 3rem);
  line-height: 0.92;
}

.icon-button,
.talk-button,
.selector-button,
.number-pad button {
  border: 0;
  font-weight: 900;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 48px;
  padding: 0 10px;
  border-radius: 8px;
  color: white;
  background: var(--charcoal);
}

.button-icon {
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .icon-on {
  display: none;
}

.icon-button[aria-pressed="true"] .icon-on {
  display: block;
}

.icon-button[aria-pressed="true"] .icon-off {
  display: none;
}

.icon-button-secondary {
  color: var(--charcoal);
  background: #f5dfb8;
}

.icon-button-secondary[aria-pressed="true"] {
  color: white;
  background: var(--blue);
}

.icon-button:disabled {
  color: var(--muted);
  background: #ead6b6;
  cursor: default;
}

.help-dialog {
  width: min(100% - 24px, 520px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--charcoal);
  background: transparent;
}

.help-dialog::backdrop {
  background: rgba(21, 27, 36, 0.56);
}

.help-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.help-header h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 1.6rem;
  line-height: 1;
}

.dialog-close {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: white;
  background: var(--charcoal);
  font-weight: 900;
  cursor: pointer;
}

.help-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.help-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff8ec;
}

.help-grid h3,
.help-grid p {
  margin: 0;
}

.help-grid h3 {
  color: var(--copper);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.help-grid p {
  margin-top: 4px;
  color: var(--night);
  font-weight: 800;
  line-height: 1.25;
}

.selectors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.selector-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.selector-button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--charcoal);
  background: #f5dfb8;
}

.selector-button.is-active {
  color: white;
  background: var(--copper);
}

.difficulty-hint {
  min-height: 18px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.mode-pill,
.score-pill {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1e2cb;
}

.score-pill {
  color: white;
  background: var(--blue);
}

.character-zone {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 42%);
  align-items: center;
  gap: 8px;
  min-height: 150px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(38, 49, 63, 0.1);
  background:
    linear-gradient(180deg, #fffdf7 0%, #ffe8bd 62%, #d58b48 62% 100%);
}

.prompt-bubble {
  margin-left: 10px;
  padding: 14px;
  border-radius: 8px;
  color: var(--night);
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(200, 97, 44, 0.35);
  font-size: clamp(1.15rem, 4.8vw, 1.7rem);
  font-weight: 900;
  line-height: 1.18;
}

.feedster-sprite {
  display: block;
  width: min(100%, 230px);
  max-height: min(196px, calc(100% - 28px));
  object-fit: contain;
  justify-self: center;
  align-self: center;
  transform: translateY(-4px);
  filter: drop-shadow(0 14px 14px rgba(21, 27, 36, 0.25));
}

.plate-zone {
  min-height: 54px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.plate {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plate-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.plate-fact {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.plate-fact strong {
  font-size: 1rem;
}

.coach-text {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.2;
}

.timer-wrap {
  flex: 0 0 112px;
  display: grid;
  gap: 4px;
}

.timer-label {
  color: var(--copper);
  text-align: right;
}

.timer-track {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #ead6b6;
}

.timer-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--berry);
  transition: width 180ms linear;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.stat-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--charcoal);
  background: #f1e2cb;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.answer-display-row {
  margin-bottom: 8px;
}

.answer-input {
  width: 100%;
  height: 52px;
  border: 2px solid rgba(38, 49, 63, 0.16);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--night);
  background: white;
  font-size: 1.55rem;
  font-weight: 900;
  text-align: center;
}

.talk-button {
  flex: 0 0 76px;
  height: 52px;
  border-radius: 8px;
  color: white;
  background: var(--blue);
}

.talk-button:disabled {
  color: var(--muted);
  background: #ead6b6;
  cursor: default;
}

.talk-button.is-listening {
  background: var(--berry);
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.number-pad button {
  min-height: 52px;
  border-radius: 8px;
  color: var(--night);
  background: #ffe0a4;
  font-size: 1.28rem;
}

.number-pad .pad-secondary {
  color: white;
  background: var(--charcoal);
  font-size: 1rem;
}

.number-pad .pad-submit {
  color: white;
  background: var(--copper);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.orientation-guard {
  display: none;
  min-height: 100dvh;
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.orientation-card {
  width: min(100%, 380px);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.orientation-card img {
  width: min(100%, 180px);
}

.orientation-title,
.orientation-copy {
  margin: 0;
}

.orientation-title {
  font-weight: 900;
  font-size: 1.35rem;
}

.orientation-copy {
  margin-top: 8px;
  color: var(--muted);
}

@media (min-width: 700px) {
  .selectors {
    grid-template-columns: 1fr 1fr;
  }

  .game-app {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .feedster-sprite {
    max-height: min(264px, calc(100% - 28px));
  }
}

@media (max-height: 880px) {
  .game-app {
    gap: 6px;
    padding-top: 6px;
    padding-bottom: 8px;
  }

  .top-panel,
  .stage-panel,
  .answer-panel {
    padding: 8px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .home-link {
    font-size: 0.78rem;
  }

  .selector-button {
    min-height: 42px;
  }

  .difficulty-hint {
    margin-top: 4px;
    font-size: 0.7rem;
  }

  .icon-button {
    min-height: 42px;
    min-width: 46px;
    padding: 0 6px;
    font-size: 0.76rem;
  }

  .help-panel {
    padding: 10px;
  }

  .help-header h2 {
    font-size: 1.35rem;
  }

  .help-grid {
    gap: 6px;
    margin-top: 8px;
  }

  .help-grid section {
    padding: 8px;
  }

  .help-grid h3 {
    font-size: 0.78rem;
  }

  .help-grid p {
    font-size: 0.82rem;
  }

  .character-zone {
    min-height: 118px;
  }

  .prompt-bubble {
    padding: 9px;
    font-size: 1rem;
  }

  .feedster-sprite {
    max-height: min(136px, calc(100% - 24px));
  }

  .plate-zone {
    min-height: 48px;
  }

  .plate {
    min-height: 32px;
  }

  .plate-facts {
    gap: 4px;
  }

  .plate-fact {
    min-height: 24px;
    font-size: 0.64rem;
  }

  .plate-fact strong {
    font-size: 0.86rem;
  }

  .answer-input,
  .talk-button {
    height: 42px;
  }

  .number-pad {
    gap: 6px;
  }

  .number-pad button {
    min-height: 42px;
    font-size: 1.1rem;
  }

  .stats-row {
    gap: 4px;
  }

  .stat-chip {
    min-height: 24px;
    font-size: 0.62rem;
  }
}

@media (max-height: 880px) and (min-width: 700px) {
  .character-zone {
    min-height: 190px;
  }

  .feedster-sprite {
    align-self: start;
    margin-top: 6px;
    max-height: min(164px, calc(100% - 28px));
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .game-app {
    display: none;
  }

  .orientation-guard {
    display: flex;
  }
}
