:root {
  color-scheme: dark;
  --bg: #101316;
  --surface: #181d22;
  --surface-raised: #20272e;
  --surface-border: #34404b;
  --text: #f3f7fb;
  --muted: #a6b3bf;
  --off: #29313a;
  --off-border: #3c4853;
  --on: #ffe66d;
  --on-hot: #ff9f1c;
  --accent: #56cfe1;
  --accent-strong: #4ea8de;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  --tile-size: clamp(3.25rem, 14vw, 5.8rem);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 20%, rgba(86, 207, 225, 0.15), transparent 28rem),
    linear-gradient(135deg, #101316 0%, #17202a 45%, #12151a 100%);
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(1rem, 3vw, 2rem);
}

.game-panel {
  width: min(100%, 42rem);
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  background: rgba(24, 29, 34, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(1.25rem, 4vw, 2rem);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 4.8rem);
  line-height: 0.95;
}

.move-card {
  display: grid;
  min-width: 6.5rem;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--surface-border);
  border-radius: 0.5rem;
  background: var(--surface-raised);
  text-align: right;
}

.move-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.move-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.board-section {
  display: grid;
  place-items: center;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  grid-template-rows: repeat(5, var(--tile-size));
  gap: clamp(0.4rem, 1.5vw, 0.7rem);
  padding: clamp(0.6rem, 2vw, 0.9rem);
  border: 1px solid var(--surface-border);
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    #11161b;
}

.tile {
  position: relative;
  display: grid;
  width: var(--tile-size);
  height: var(--tile-size);
  place-items: center;
  border: 1px solid var(--off-border);
  border-radius: 0.45rem;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    var(--off);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 18px rgba(0, 0, 0, 0.26);
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.tile::after {
  width: 28%;
  height: 28%;
  border-radius: 999px;
  background: rgba(166, 179, 191, 0.46);
  content: "";
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: #5a6b79;
}

.tile:disabled {
  cursor: not-allowed;
}

.tile:disabled:hover {
  transform: none;
}

.tile:focus-visible,
.control-button:focus-visible {
  outline: 3px solid rgba(86, 207, 225, 0.9);
  outline-offset: 4px;
}

.tile--on {
  border-color: rgba(255, 230, 109, 0.88);
  background:
    radial-gradient(circle at 42% 36%, rgba(255, 255, 255, 0.82), transparent 0.65rem),
    linear-gradient(145deg, var(--on), var(--on-hot));
  box-shadow:
    0 0 28px rgba(255, 230, 109, 0.32),
    0 14px 28px rgba(255, 159, 28, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.tile--on::after {
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.85),
    0 0 34px rgba(255, 230, 109, 0.7);
  transform: scale(1.18);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.victory-message {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(86, 207, 225, 0.36);
  border-radius: 0.5rem;
  background: rgba(86, 207, 225, 0.1);
  text-align: center;
}

.victory-message[hidden] {
  display: none;
}

.victory-message h2 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.victory-message p {
  margin: 0;
  color: var(--muted);
}

.control-button {
  min-width: 8rem;
  min-height: 2.9rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  cursor: pointer;
  font-weight: 800;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.control-button:hover {
  transform: translateY(-1px);
}

.control-button--secondary {
  border-color: var(--surface-border);
  color: var(--text);
  background: var(--surface-raised);
}

.control-button--secondary:hover {
  border-color: #5a6b79;
  background: #26313a;
}

.control-button--primary {
  color: #061015;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.control-button--primary:hover {
  background: linear-gradient(135deg, #72e4f1, #65b9ed);
}

@media (max-width: 36rem) {
  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .move-card {
    align-items: center;
    grid-template-columns: 1fr auto;
    min-width: 0;
    text-align: left;
  }

  .controls {
    flex-direction: column;
  }

  .control-button {
    width: 100%;
  }
}
