:root {
  color-scheme: dark;
  --bg: #111418;
  --panel: #1b2027;
  --panel-2: #232a32;
  --ink: #f6f2e8;
  --muted: #aeb7c2;
  --teal: #31d0aa;
  --coral: #ff6b6b;
  --amber: #ffd166;
  --blue: #6aa8ff;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100svh;
  background:
    linear-gradient(135deg, rgba(49, 208, 170, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(255, 107, 107, 0.13), transparent 34%),
    var(--bg);
}

button,
a {
  font: inherit;
}

.pr-bar {
  padding: 7px 12px;
  background: #0b0d10;
  color: #cdd3db;
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.app {
  width: min(100%, 920px);
  min-height: calc(100svh - 31px);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 22px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 14px;
}

.topline,
.scoreboard,
.stage,
.controls,
.support-strip,
.result {
  border: 1px solid var(--line);
  background: rgba(17, 20, 24, 0.82);
  box-shadow: var(--shadow);
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.hub-link,
.support-strip a {
  color: var(--ink);
  text-decoration: none;
}

.hub-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 800;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.scoreboard div {
  min-width: 0;
  padding: 10px;
  background: var(--panel);
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.scoreboard strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1;
}

.stage {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  padding: clamp(12px, 3vw, 20px);
  display: grid;
  grid-template-columns: minmax(160px, 0.72fr) minmax(270px, 1.28fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.target-panel,
.board-panel {
  min-width: 0;
}

.panel-label {
  display: block;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  margin: 0 0 10px;
}

.mini-grid,
.board-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  aspect-ratio: 1;
}

.mini-grid {
  max-width: 220px;
}

.mini-cell,
.cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  aspect-ratio: 1;
}

.mini-cell {
  background: #252b31;
}

.mini-cell.on {
  background: var(--amber);
  border-color: rgba(255, 209, 102, 0.88);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.16);
}

.board-panel {
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.timer-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #2e3339;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--coral));
}

.cell {
  position: relative;
  padding: 0;
  cursor: pointer;
  background: #262d35;
  color: var(--ink);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.cell.on {
  background: var(--teal);
  border-color: rgba(49, 208, 170, 0.95);
}

.cell.on::after {
  background: rgba(17, 20, 24, 0.28);
  transform: rotate(45deg);
}

.cell.match {
  box-shadow: inset 0 0 0 3px rgba(255, 209, 102, 0.28);
}

.cell:enabled:hover,
.cell:enabled:focus-visible {
  transform: translateY(-2px);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.cell:disabled {
  cursor: default;
  opacity: 0.74;
}

.feedback {
  grid-column: 1 / -1;
  min-height: 28px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

button.primary {
  background: var(--coral);
  border-color: rgba(255, 107, 107, 0.92);
  color: #160b0b;
}

button:disabled {
  cursor: default;
  color: #75808a;
  background: #1c2025;
}

.support-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.support-strip a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 800;
}

.result {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 24px));
  transform: translate(-50%, -50%);
  z-index: 10;
  padding: 22px;
  border-radius: 8px;
  text-align: center;
}

.result[hidden] {
  display: none;
}

.result-label {
  margin: 0;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.result strong {
  display: block;
  margin: 8px 0;
  font-size: 46px;
}

.result p {
  color: var(--muted);
}

.result button {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .app {
    padding-top: 12px;
  }

  h1 {
    font-size: 27px;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    max-width: 150px;
    margin: 0 auto;
  }

  .board-grid {
    max-width: min(100%, 430px);
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .topline {
    padding: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .scoreboard strong {
    font-size: 19px;
  }

  .mini-grid,
  .board-grid {
    gap: 6px;
  }

  .support-strip {
    flex-direction: column;
  }

  .support-strip a {
    justify-content: center;
  }
}
