:root {
  color-scheme: dark;
  --bg: #080910;
  --panel: #111827;
  --panel-soft: #172033;
  --ink: #f8fafc;
  --muted: #a8b3c7;
  --line: #31405e;
  --acid: #b6f44f;
  --hot: #ff4560;
  --cool: #7dd3fc;
  --gold: #ffb84d;
  --violet: #c084fc;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(8, 9, 16, 0.72), var(--bg)),
    linear-gradient(90deg, rgba(125, 211, 252, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 20% 12%, rgba(182, 244, 79, 0.16), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(255, 69, 96, 0.16), transparent 32%),
    var(--bg);
  background-size: auto, 72px 72px, 72px 72px, auto, auto, auto;
  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(--cool);
}

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

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

.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;
  color: var(--ink);
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.88;
}

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

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

.audio-button.on {
  border-color: rgba(125, 211, 252, 0.78);
  background: rgba(125, 211, 252, 0.16);
  color: #dff7ff;
}

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

.side-panel {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 39, 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: #0d1321;
}

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

.brief-panel {
  min-height: 126px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 69, 96, 0.48);
  background:
    linear-gradient(135deg, rgba(255, 69, 96, 0.15), transparent 58%),
    #0d1321;
  color: #ffd7de;
  line-height: 1.4;
}

.actions {
  display: grid;
  gap: 8px;
}

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

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

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

.touch-controls {
  display: grid;
  width: min(100%, 900px);
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.touch-controls button {
  min-height: 46px;
  font-weight: 900;
}

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

@media (min-width: 1500px) {
  .app-shell {
    width: min(1760px, calc(100% - 64px));
  }

  .game-layout {
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 32px;
  }

  .stage,
  .touch-controls,
  .hint-strip {
    width: min(100%, 1320px);
  }

  .brief-panel {
    min-height: 150px;
  }
}

@media (min-width: 2600px) and (min-height: 1400px) {
  .app-shell {
    width: min(2120px, calc(100% - 96px));
  }

  .game-layout {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 40px;
  }

  .stage,
  .touch-controls,
  .hint-strip {
    width: min(100%, 1500px);
  }
}

.result-dialog,
.settings-dialog {
  width: min(430px, calc(100% - 28px));
  border: 1px solid var(--cool);
  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::backdrop,
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.result-dialog button,
.settings-dialog button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 900;
}

.setting-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

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

input[type="range"] {
  width: 100%;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 18px, 720px);
    padding-top: 12px;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }

  .top-actions {
    justify-content: center;
    justify-self: center;
  }

  h1 {
    font-size: clamp(40px, 13vw, 64px);
  }

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

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

  .stage-wrap {
    order: 1;
  }

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

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

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

  .brief-panel {
    min-height: 76px;
    margin-bottom: 10px;
  }

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

@media (max-width: 520px) {
  .audio-button,
  .settings-button,
  .new-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .stage {
    border-width: 2px;
  }

  .touch-controls button,
  .actions button {
    min-height: 42px;
    font-size: 13px;
  }

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

  .hint-strip {
    min-height: 42px;
    padding: 10px;
    font-size: 13px;
  }

  .setting-row {
    grid-template-columns: 74px minmax(0, 1fr) 52px;
    gap: 8px;
  }
}
