:root {
  color-scheme: dark;
  --bg: #080806;
  --panel: #11160f;
  --panel-soft: #1a2013;
  --ink: #f7f2e6;
  --muted: #aaa893;
  --line: #34402e;
  --acid: #b6f44f;
  --hot: #ff7042;
  --cool: #7ec7d8;
  --warn: #ffd15c;
  --bad: #ff5268;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(8, 8, 6, 0.72), var(--bg)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 74px),
    radial-gradient(circle at 16% 8%, rgba(255, 112, 66, 0.18), transparent 30%),
    radial-gradient(circle at 78% 12%, rgba(182, 244, 79, 0.14), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Trebuchet MS", "Gill Sans", Avenir, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--acid);
}

button:disabled {
  cursor: default;
  opacity: 0.52;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.studio-link {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.studio-link:hover {
  color: var(--ink);
}

.game-title {
  text-align: center;
}

.game-title p,
.stats span {
  margin: 0 0 6px;
  color: var(--acid);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.84;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-self: end;
  justify-content: flex-end;
  gap: 8px;
}

.audio-button,
.settings-button,
.new-button {
  min-width: 72px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 900;
}

.audio-button.on {
  border-color: rgba(126, 199, 216, 0.74);
  background: rgba(126, 199, 216, 0.18);
  color: #d9f8fb;
}

.game-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  background: rgba(17, 22, 15, 0.94);
  padding: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stats div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #10150d;
}

.stats strong {
  font-size: 24px;
}

.brief-panel {
  min-height: 130px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 112, 66, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 112, 66, 0.16), transparent 54%),
    #10150d;
  color: #f8d8c7;
  line-height: 1.4;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.actions button {
  min-height: 42px;
  font-weight: 900;
}

.stage-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.stage {
  display: block;
  width: min(100%, 920px);
  aspect-ratio: 16 / 9;
  border: 3px solid var(--ink);
  background: #11160f;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  touch-action: none;
}

.hint-strip {
  width: min(100%, 920px);
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(17, 22, 15, 0.9);
  color: var(--muted);
  font-weight: 850;
  line-height: 1.3;
}

.result-dialog,
.settings-dialog {
  width: min(430px, calc(100% - 28px));
  border: 1px solid var(--acid);
  background: var(--panel);
  color: var(--ink);
  padding: 24px;
}

.settings-dialog {
  width: min(520px, calc(100% - 28px));
}

.result-dialog:not([open]),
.settings-dialog:not([open]) {
  display: none;
}

.result-dialog[open],
.settings-dialog[open] {
  display: block;
  position: fixed;
  inset: 50% auto auto 50%;
  max-height: calc(100vh - 28px);
  overflow: auto;
  transform: translate(-50%, -50%);
  z-index: 40;
}

.result-dialog::backdrop,
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.result-dialog h2,
.settings-dialog h2 {
  margin-bottom: 10px;
  font-size: 32px;
}

.result-dialog p,
.settings-dialog p {
  color: var(--muted);
  line-height: 1.5;
}

.setting-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #10150d;
}

.setting-row label,
.setting-row strong {
  font-weight: 900;
}

.setting-row input {
  width: 100%;
  accent-color: var(--acid);
}

.result-dialog button,
.settings-dialog button {
  width: 100%;
  min-height: 46px;
  background: var(--acid);
  color: #101608;
  font-weight: 900;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .game-title {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: left;
  }

  .studio-link,
  .top-actions {
    grid-row: 2;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    order: 2;
  }

  .stage-wrap {
    order: 1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 16px, 1220px);
    padding-top: 12px;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats div {
    min-height: 58px;
    padding: 8px;
  }

  .stats span {
    font-size: 10px;
  }

  .stats strong {
    font-size: 17px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1 1 92px;
    min-width: 0;
    padding: 0 10px;
  }
}
