:root {
  color-scheme: dark;
  --bg: #070806;
  --panel: #10150f;
  --panel-soft: #171f15;
  --slot: #0d120d;
  --slot-open: #172018;
  --ink: #f7f1e4;
  --muted: #aaa694;
  --line: #34402f;
  --line-strong: #68765d;
  --acid: #b6f44f;
  --hot: #ff7042;
  --gold: #f3c84e;
  --cool: #75c9d5;
  --violet: #c991ff;
  --bad: #ff5069;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(7, 8, 6, 0.74), var(--bg) 74%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 70px),
    repeating-linear-gradient(0deg, rgba(182, 244, 79, 0.03) 0 1px, transparent 1px 70px),
    radial-gradient(circle at 15% 7%, rgba(117, 201, 213, 0.15), transparent 28%),
    radial-gradient(circle at 84% 12%, rgba(255, 112, 66, 0.12), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

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

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

.app-shell {
  width: min(1200px, 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: 850;
  text-decoration: none;
}

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

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

.game-title p,
.objective-panel p,
.quick-guide p,
.coach-panel p,
.detail-panel p,
.stats span,
.board-header 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, 86px);
  line-height: 0.86;
}

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

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

.audio-button.on {
  border-color: rgba(117, 201, 213, 0.74);
  background: rgba(117, 201, 213, 0.18);
  color: #d9f8fb;
}

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

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

.objective-panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(117, 201, 213, 0.44);
  background:
    linear-gradient(135deg, rgba(117, 201, 213, 0.13), transparent 58%),
    var(--slot);
}

.objective-panel h2 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.02;
}

.objective-panel span {
  display: block;
  color: #d8d2c4;
  line-height: 1.38;
}

.quick-guide,
.coach-panel,
.detail-panel {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(182, 244, 79, 0.36);
  background:
    linear-gradient(135deg, rgba(182, 244, 79, 0.1), transparent 58%),
    var(--slot);
  line-height: 1.38;
}

.quick-guide strong,
.quick-guide span,
.coach-panel span,
.detail-panel strong,
.detail-panel span,
.detail-panel em {
  display: block;
}

.quick-guide strong,
.detail-panel strong {
  margin-bottom: 6px;
  font-size: 17px;
}

.quick-guide span,
.coach-panel span,
.detail-panel span,
.detail-panel em {
  color: #d8d2c4;
}

.detail-panel {
  border-color: rgba(117, 201, 213, 0.4);
  background:
    linear-gradient(135deg, rgba(117, 201, 213, 0.12), transparent 58%),
    var(--slot);
}

.detail-panel em {
  margin-top: 8px;
  color: var(--cool);
  font-style: normal;
  font-weight: 850;
}

.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: var(--slot);
}

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

.mode-group,
.tool-group {
  display: grid;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

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

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

.segment,
.tool {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  font-weight: 850;
}

.segment:last-child,
.tool:last-child {
  border-right: 0;
}

.segment.active,
.tool.active {
  background: var(--acid);
  color: #101608;
}

.segment,
.tool,
.actions button,
.top-actions button {
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.segment:active,
.tool:active,
.actions button:active,
.top-actions button:active {
  transform: translateY(1px);
}

.meters {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.meters label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.meter {
  height: 12px;
  border: 1px solid var(--line);
  background: #090c09;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cool), var(--acid));
  transition: width 160ms ease;
}

.meter.danger span {
  background: linear-gradient(90deg, var(--gold), var(--hot), var(--bad));
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

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

#submit-button.ready {
  border-color: rgba(182, 244, 79, 0.7);
  background: var(--acid);
  color: #101608;
  box-shadow: 0 0 22px rgba(182, 244, 79, 0.22);
}

.event-log {
  min-height: 86px;
  padding: 12px;
  border: 1px solid rgba(255, 112, 66, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 112, 66, 0.15), transparent 58%),
    var(--slot);
  color: #f5d5c6;
  line-height: 1.38;
}

.tutorial-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(182, 244, 79, 0.54);
  background:
    linear-gradient(135deg, rgba(182, 244, 79, 0.14), transparent 58%),
    var(--slot);
  line-height: 1.38;
}

.tutorial-panel.hidden {
  display: none;
}

.tutorial-panel p {
  margin: 0 0 6px;
  color: var(--acid);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.tutorial-panel strong,
.tutorial-panel span {
  display: block;
}

.tutorial-panel strong {
  margin-bottom: 6px;
  font-size: 18px;
}

.tutorial-panel span {
  color: #d8d2c4;
}

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

.board-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 760px);
}

.board-header strong {
  display: block;
  font-size: 24px;
}

.tile-reader {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 760px);
}

.tile-reader span {
  min-height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(13, 18, 13, 0.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tile-reader b {
  color: var(--ink);
}

.topic-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topic-chip {
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid rgba(117, 201, 213, 0.45);
  background: rgba(117, 201, 213, 0.12);
  color: #d9f8fb;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.topic-chip.covered {
  border-color: rgba(182, 244, 79, 0.65);
  background: rgba(182, 244, 79, 0.16);
  color: #ecffd1;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  width: min(100%, 760px);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  background: var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--slot);
}

.tile {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 5px;
  width: 100%;
  min-width: 0;
  padding: clamp(6px, 1.2vw, 10px);
  border: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 55%),
    var(--slot-open);
  text-align: left;
  transition:
    box-shadow 140ms ease,
    transform 140ms ease,
    background-color 140ms ease;
}

.tile:hover {
  outline: 2px solid rgba(182, 244, 79, 0.72);
  outline-offset: -2px;
  transform: translateY(-1px);
}

.tile-top,
.tile-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  color: rgba(247, 241, 228, 0.78);
  font-size: clamp(9px, 1.1vw, 12px);
  font-weight: 900;
  text-transform: uppercase;
}

.tile strong {
  align-self: center;
  min-width: 0;
  color: var(--ink);
  font-size: clamp(18px, 3.2vw, 36px);
  line-height: 0.9;
  overflow-wrap: anywhere;
}

.tile small {
  color: rgba(247, 241, 228, 0.68);
  font-size: clamp(9px, 1.05vw, 12px);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tile.pinned::after {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border: 1px solid #101608;
  background: var(--acid);
  box-shadow: 0 0 18px rgba(182, 244, 79, 0.5);
  content: "";
}

.tile.pinned {
  box-shadow: inset 0 0 0 1px rgba(182, 244, 79, 0.34);
}

@media (prefers-reduced-motion: no-preference) {
  #submit-button.ready {
    animation: readyPulse 1.6s ease-in-out infinite;
  }

  .tile.hinted,
  .tile.coached {
    animation: tilePulse 1.4s ease-in-out infinite;
  }
}

@keyframes readyPulse {
  0%,
  100% {
    box-shadow: 0 0 16px rgba(182, 244, 79, 0.18);
  }

  50% {
    box-shadow: 0 0 30px rgba(182, 244, 79, 0.38);
  }
}

@keyframes tilePulse {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.22);
  }
}

.tile.fact {
  border-left: 5px solid var(--cool);
}

.tile.memory {
  border-left: 5px solid var(--acid);
}

.tile.summary {
  border-left: 5px solid var(--violet);
  background:
    repeating-linear-gradient(135deg, rgba(201, 145, 255, 0.14) 0 8px, transparent 8px 16px),
    var(--slot-open);
}

.tile.stale {
  border-left: 5px solid var(--gold);
}

.tile.noise {
  border-left: 5px solid var(--line-strong);
  color: var(--muted);
}

.tile.fake {
  border-left: 5px solid var(--bad);
  background:
    repeating-linear-gradient(45deg, rgba(255, 80, 105, 0.14) 0 8px, transparent 8px 16px),
    #211015;
}

.tile.selected {
  outline: 3px solid var(--acid);
  outline-offset: -3px;
}

.tile.hinted {
  box-shadow:
    inset 0 0 0 3px rgba(182, 244, 79, 0.82),
    0 0 24px rgba(182, 244, 79, 0.2);
}

.tile.coached {
  box-shadow:
    inset 0 0 0 3px rgba(117, 201, 213, 0.9),
    0 0 26px rgba(117, 201, 213, 0.22);
}

.hinted-control {
  border-color: rgba(182, 244, 79, 0.86);
  box-shadow: 0 0 0 2px rgba(182, 244, 79, 0.18);
}

.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.tour-layer.hidden {
  display: none;
}

.tour-card {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 110;
  width: min(430px, calc(100vw - 32px));
  padding: 22px;
  border: 3px solid var(--acid);
  background:
    linear-gradient(135deg, rgba(182, 244, 79, 0.14), transparent 58%),
    #0b100b;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58);
  pointer-events: auto;
}

.tour-card p {
  margin: 0;
}

.tour-card > p:first-child {
  margin-bottom: 8px;
  color: var(--acid);
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.tour-card h2 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.tour-card #tour-copy {
  color: #d8d2c4;
  font-size: 17px;
  line-height: 1.45;
}

.tour-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  background: var(--acid);
  color: #101608;
  font-weight: 950;
}

.tour-card button.hidden {
  display: none;
}

.tour-arrow {
  position: fixed;
  z-index: 105;
  width: 120px;
  height: 14px;
  border: 1px solid rgba(7, 8, 6, 0.8);
  background: #ff304f;
  box-shadow: 0 0 34px rgba(255, 48, 79, 0.48);
  pointer-events: none;
  transform-origin: left center;
}

.tour-arrow::after {
  position: absolute;
  top: 50%;
  right: -24px;
  width: 0;
  height: 0;
  border-top: 18px solid transparent;
  border-bottom: 18px solid transparent;
  border-left: 26px solid #ff304f;
  content: "";
  transform: translateY(-50%);
}

.tour-target {
  position: relative;
  z-index: 100;
  outline: 5px solid #ff304f;
  outline-offset: 5px;
  box-shadow: 0 0 0 12px rgba(255, 48, 79, 0.16);
}

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

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

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

.result-dialog p,
.help-dialog p,
.help-dialog li,
.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: var(--slot);
}

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

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

.help-dialog ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.help-dialog kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  border: 1px solid var(--line);
  background: var(--slot);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
}

.dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

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

.dialog-actions .secondary-action {
  background: var(--panel-soft);
  color: var(--ink);
}

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

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

  .studio-link {
    grid-row: 2;
  }

  .top-actions {
    grid-row: 2;
  }

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

  .side-panel {
    position: static;
  }
}

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

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

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

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

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

  .top-actions {
    width: 100%;
  }

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

  .board-header {
    align-items: start;
    flex-direction: column;
  }

  .topic-strip {
    justify-content: flex-start;
  }

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

  .tile {
    gap: 3px;
    padding: 5px;
  }

  .tile-top,
  .tile-bottom {
    font-size: 8px;
  }

  .tile strong {
    font-size: clamp(14px, 6vw, 24px);
  }

  .tile small {
    font-size: 8px;
  }

  .tour-card {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    padding: 18px;
  }

  .tour-card h2 {
    font-size: 28px;
  }
}
