* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #12122a;
  color: #eef0ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 16px;
}

.game {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.board-wrap {
  position: relative;
  border: 3px solid #3d3d7a;
  border-radius: 6px;
  background: #0a0a1a;
  line-height: 0;
}

#board {
  display: block;
  width: min(300px, 62vw);
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10, 10, 26, 0.85);
  text-align: center;
  line-height: 1.4;
  padding: 16px;
}

.overlay.hidden { display: none; }

.overlay h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 2px;
  color: #ffd84d;
}

.overlay p { margin: 0; font-size: 16px; }

button {
  font: inherit;
  cursor: pointer;
}

#start-btn {
  padding: 10px 28px;
  font-size: 18px;
  font-weight: 600;
  color: #12122a;
  background: #ffd84d;
  border: 0;
  border-radius: 6px;
}

#start-btn:focus-visible, .touch button:focus-visible {
  outline: 3px solid #7ee8ff;
  outline-offset: 2px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 140px;
}

.panel {
  background: #1c1c3d;
  border: 2px solid #3d3d7a;
  border-radius: 6px;
  padding: 10px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #aab0e0;
}

#next {
  display: block;
  width: 100%;
  height: auto;
}

.stats { display: grid; gap: 8px; }
.stats div { display: flex; flex-direction: column; }
.stats span { font-size: 13px; color: #aab0e0; }
.stats strong { font-size: 22px; font-variant-numeric: tabular-nums; }

.help p { margin: 2px 0; font-size: 13px; color: #aab0e0; }

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

.touch button {
  height: 56px;
  font-size: 22px;
  color: #eef0ff;
  background: #2b2b5c;
  border: 2px solid #3d3d7a;
  border-radius: 10px;
}

.touch button:active { background: #3d3d7a; }

@media (hover: none), (max-width: 600px) {
  .touch { display: grid; }
  .help { display: none; }
  .side { width: 110px; }
  .stats strong { font-size: 18px; }
}
