:root {
  --bg: #0b1020;
  --panel: rgba(15, 23, 42, 0.9);
  --panel-strong: #111827;
  --panel-soft: rgba(30, 41, 59, 0.72);
  --line: rgba(148, 163, 184, 0.2);
  --text: #e5edf9;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --accent-strong: #06b6d4;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(34, 211, 238, 0.17), transparent 28rem),
    radial-gradient(circle at 86% 20%, rgba(244, 114, 182, 0.12), transparent 30rem),
    linear-gradient(135deg, #070b16 0%, #111827 45%, #101625 100%);
}

button,
canvas {
  font: inherit;
}

.game-shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(360px, 640px) 320px;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.game-stage,
.side-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.game-stage {
  padding: 22px;
  border-radius: 22px;
}

.brand-bar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 9px 12px;
  border: 1px solid rgba(34, 211, 238, 0.32);
  border-radius: 999px;
  color: #cffafe;
  background: rgba(8, 145, 178, 0.14);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.board-wrap {
  position: relative;
  width: min(100%, 410px);
  margin: 0 auto;
  aspect-ratio: 1 / 2;
  padding: 10px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #050816;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 48px rgba(0, 0, 0, 0.34);
}

.account-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 13px 14px;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 14px;
  background: rgba(8, 145, 178, 0.12);
}

.account-banner strong,
.account-banner span {
  display: block;
}

.account-banner strong {
  color: #f8fafc;
  font-size: 0.98rem;
}

.account-banner span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.account-banner.is-signed-in {
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(16, 185, 129, 0.1);
}

.account-banner-action,
.history-actions a,
.history-empty a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 10px;
  color: #07111f;
  background: linear-gradient(180deg, #67e8f9 0%, var(--accent-strong) 100%);
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 800;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: #050816;
}

.board-overlay {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(5, 8, 22, 0.72);
  color: #f8fafc;
  font-size: clamp(1.15rem, 2.5vw, 1.75rem);
  font-weight: 800;
  text-align: center;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.board-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.side-panel {
  padding: 20px;
  border-radius: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-card,
.preview-panel,
.keys-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.stat-card {
  min-height: 82px;
  padding: 14px 16px;
}

.stat-card span,
.preview-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0;
}

.preview-panel {
  margin-top: 14px;
  padding: 14px;
}

#next {
  display: block;
  width: 128px;
  height: 128px;
  margin: 12px auto 2px;
  border-radius: 10px;
  background: #080d1c;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 16px 0;
}

.controls button {
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  color: #07111f;
  background: linear-gradient(180deg, #67e8f9 0%, var(--accent-strong) 100%);
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.2);
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, filter 120ms ease;
}

.controls button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.controls button:active {
  transform: translateY(0);
}

.controls button:nth-child(2) {
  color: var(--text);
  background: #334155;
  box-shadow: none;
}

.controls button:nth-child(3) {
  color: #ffe4e6;
  background: rgba(251, 113, 133, 0.18);
  box-shadow: none;
}

.save-status {
  min-height: 20px;
  margin: -4px 0 12px;
  color: #bae6fd;
  font-size: 0.84rem;
  text-align: center;
}

.keys-panel {
  padding: 12px;
}

.keys-panel div {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
  font-size: 0.88rem;
}

kbd {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.history-body {
  min-height: 100vh;
}

.history-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.history-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(15, 23, 42, 0.9) 42%, rgba(251, 113, 133, 0.16)),
    var(--panel);
  box-shadow: var(--shadow);
}

.history-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
}

.history-hero p {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.history-actions a:nth-child(2) {
  color: var(--text);
  background: #334155;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 136px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.metric-card.is-primary {
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.22), rgba(15, 23, 42, 0.94));
}

.metric-card span,
.section-heading span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.45rem, 2.4vw, 2.3rem);
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.stats-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-bottom: 18px;
}

.score-bars,
.stats-orbit,
.history-list-panel,
.history-empty {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.score-bars,
.history-list-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading strong {
  color: #cffafe;
}

.score-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.score-row:first-of-type {
  border-top: 0;
}

.score-row strong,
.score-row span {
  display: block;
}

.score-row span {
  color: var(--muted);
  font-size: 0.83rem;
}

.score-bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22d3ee, #34d399 55%, #facc15);
}

.stats-orbit {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.stats-orbit:before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 50%;
}

.orbit-core {
  position: relative;
  z-index: 1;
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.34), rgba(15, 23, 42, 0.96) 68%);
  box-shadow: 0 0 42px rgba(34, 211, 238, 0.2);
  text-align: center;
}

.orbit-core strong,
.orbit-core span {
  display: block;
}

.orbit-core strong {
  max-width: 128px;
  overflow-wrap: anywhere;
  font-size: 1.45rem;
}

.orbit-core span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.orbit-chip {
  position: absolute;
  z-index: 2;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: #111827;
  color: #e0f2fe;
  font-size: 0.8rem;
  font-weight: 800;
}

.chip-one {
  top: 52px;
  left: 28px;
}

.chip-two {
  top: 92px;
  right: 24px;
}

.chip-three {
  bottom: 62px;
  left: 58px;
}

.history-search {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.history-search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.92);
  padding: 0 13px;
}

.history-search button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  color: #07111f;
  background: var(--accent);
  font-weight: 800;
  padding: 0 16px;
}

.game-table {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
}

.game-row {
  display: grid;
  grid-template-columns: 1.1fr .8fr .8fr .9fr 1.4fr;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  color: #dbeafe;
}

.game-row:first-child {
  border-top: 0;
}

.game-head {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.8);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.history-empty {
  padding: 34px;
  text-align: center;
}

.history-empty h2 {
  margin: 0 0 8px;
}

.history-empty p {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-showcase {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 20px 0;
  }

  .side-panel {
    width: min(100%, 640px);
    margin: 0 auto;
  }

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

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

@media (max-width: 560px) {
  .game-shell {
    width: min(100vw - 20px, 460px);
  }

  .game-stage,
  .side-panel {
    padding: 14px;
    border-radius: 16px;
  }

  .brand-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

  .account-banner,
  .history-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .account-banner-action {
    width: 100%;
  }

  .stats-grid,
  .controls {
    grid-template-columns: 1fr;
  }

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

  .score-row,
  .game-row {
    grid-template-columns: 1fr;
  }

  .game-head {
    display: none;
  }
}
