* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at top, #1b1f3a, #0a0b14 70%);
  color: #e6e8f2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

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

.layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 140px;
}

.panel section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px;
}

h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a90b8;
}

.stats div {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}
.stats div:last-child { margin-bottom: 0; }
.stats span { font-size: 11px; color: #8a90b8; text-transform: uppercase; letter-spacing: 1px; }
.stats strong { font-size: 22px; font-variant-numeric: tabular-nums; }

.help p { margin: 4px 0; font-size: 12px; color: #aab0d4; }
kbd {
  display: inline-block;
  padding: 1px 5px;
  margin-right: 2px;
  border-radius: 4px;
  background: #2a2f55;
  font-size: 11px;
  font-family: inherit;
}

canvas { display: block; }

.board-wrap {
  position: relative;
  border: 2px solid #3a4078;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(90, 110, 255, 0.25);
  background: #07080f;
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(7, 8, 15, 0.82);
  text-align: center;
  padding: 16px;
}
.overlay.hidden { display: none; }
.overlay h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #00f0f0, #a000f0, #f0a000);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay p { margin: 0; color: #aab0d4; }

button {
  font: inherit;
  cursor: pointer;
  color: #fff;
  background: #4c55c9;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
}
button:hover { background: #5d66de; }

.touch {
  display: none;
  grid-template-columns: repeat(3, 72px);
  gap: 10px;
}
.touch button { padding: 16px 0; font-size: 20px; background: #2a2f55; }
.touch button:active { background: #4c55c9; }

@media (max-width: 640px), (pointer: coarse) {
  .touch { display: grid; }
  .help { display: none; }
  .layout { gap: 8px; }
  .panel { width: 80px; gap: 8px; }
  .panel canvas { width: 70px; height: auto; }
  .stats strong { font-size: 16px; }
}

.back {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 13px;
  color: #8a90b8;
}
.back a { color: #aab0d4; text-decoration: none; }
.back a:hover { color: #fff; }

.panel section.denied {
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); border-color: #f03838; }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
