:root {
  color-scheme: dark;
  --bg: #11110f;
  --surface: #1c1b18;
  --surface-2: #28251f;
  --line: #3a352b;
  --text: #f3eee4;
  --muted: #afa792;
  --amber: #f0b13e;
  --mint: #62d6a3;
  --rose: #e36d8f;
  --cyan: #55c7d7;
  --ink: #090908;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 980px);
  min-height: 100vh;
  padding: 24px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 16px;
  align-items: center;
}

.game {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(220px, 280px);
  gap: 20px;
  align-items: stretch;
  justify-content: center;
}

.board-wrap {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1 / 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #151411;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.panel {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 11px, rgba(0, 0, 0, 0.2) 11px 13px, transparent 13px),
    linear-gradient(0deg, transparent 0 11px, rgba(0, 0, 0, 0.2) 11px 13px, transparent 13px),
    conic-gradient(from 90deg, var(--cyan), var(--mint), var(--amber), var(--rose), var(--cyan));
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats div,
.next {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.stats div {
  min-height: 74px;
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.stats span,
.next span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stats strong {
  font-size: 1.25rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.next {
  align-self: start;
  padding: 12px;
  display: grid;
  gap: 10px;
}

#next {
  width: 120px;
  height: 120px;
  justify-self: center;
}

.actions,
.touch {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  gap: 10px;
  justify-content: center;
}

.icon,
.touch button,
.primary {
  border-radius: 8px;
  background: #383228;
  box-shadow: inset 0 0 0 1px #514839;
}

.icon,
.touch button {
  width: 56px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.icon:hover,
.touch button:hover,
.primary:hover {
  background: #463e31;
}

.icon:active,
.touch button:active,
.primary:active {
  transform: translateY(1px);
}

.touch {
  grid-template-columns: repeat(4, 64px);
  display: none;
}

.touch button {
  width: 64px;
  height: 54px;
  font-size: 1.65rem;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  align-content: center;
  background: rgba(9, 9, 8, 0.72);
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

.overlay-title {
  min-height: 34px;
  font-size: 1.5rem;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
}

.primary {
  min-width: 108px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 750;
}

@media (max-width: 760px) {
  body {
    align-items: start;
  }

  .shell {
    min-height: 100svh;
    padding: 12px;
    gap: 10px;
  }

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

  .board-wrap {
    width: min(100%, 360px);
    justify-self: center;
  }

  .panel {
    width: min(100%, 360px);
    justify-self: center;
    min-height: 0;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 12px;
  }

  .brand {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 1.1rem;
  }

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

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

  .stats strong {
    font-size: 1.05rem;
  }

  .next {
    width: 84px;
    padding: 8px;
  }

  #next {
    width: 64px;
    height: 64px;
  }

  .actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 56px);
  }

  .touch {
    display: grid;
  }
}

@media (max-width: 390px) {
  .board-wrap,
  .panel {
    width: 100%;
  }

  .touch {
    grid-template-columns: repeat(4, 58px);
  }

  .touch button {
    width: 58px;
  }
}
