:root {
  --bg-0: #05060f;
  --bg-1: #0a0e22;
  --grid: rgba(120, 160, 255, 0.10);
  --panel: rgba(16, 22, 48, 0.72);
  --panel-border: rgba(120, 170, 255, 0.25);
  --accent: #57e6ff;
  --accent-2: #b96bff;
  --text: #dfe8ff;
  --text-dim: #8a97c4;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: #05060f;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Animated canvas background */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Subtle gradient overlay for depth */
.bg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(60, 80, 200, 0.08), transparent 60%),
    radial-gradient(900px 600px at 80% 110%, rgba(150, 60, 200, 0.06), transparent 55%);
}

.stage {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.title {
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: 6px;
  font-weight: 800;
  text-align: center;
  text-shadow:
    0 0 8px rgba(87, 230, 255, 0.6),
    0 0 24px rgba(87, 230, 255, 0.35);
}

.mute-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-size: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.mute-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(87, 230, 255, 0.4);
}

.title span {
  color: var(--accent);
  text-shadow:
    0 0 10px rgba(185, 107, 255, 0.8),
    0 0 28px rgba(185, 107, 255, 0.4);
}

.layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 128px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.card-title {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 10px;
}

canvas.mini {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}

canvas.mini.tall {
  aspect-ratio: 1 / 1.6;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(87, 230, 255, 0.4);
}

.help ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
}

.help b {
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}

/* Board */
.board-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.board-frame {
  position: relative;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow:
    var(--shadow),
    inset 0 0 30px rgba(87, 230, 255, 0.06);
}

#board {
  display: block;
  width: min(58vh, 340px);
  height: min(116vh, 680px);
  max-height: 72vh;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 16, 0.72);
  border-radius: 10px;
  backdrop-filter: blur(4px);
  animation: fadein 0.2s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-box {
  text-align: center;
  padding: 24px;
}

.overlay-box h3 {
  font-size: 30px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  text-shadow: 0 0 14px rgba(87, 230, 255, 0.5);
}

.overlay-box p {
  color: var(--text-dim);
  margin-bottom: 18px;
}

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #04121a;
  background: linear-gradient(180deg, #7af0ff, #37c9f0);
  border: none;
  border-radius: 10px;
  padding: 12px 26px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(87, 230, 255, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 26px rgba(87, 230, 255, 0.7);
}

.btn:active {
  transform: translateY(0);
}

/* Touch controls */
.touch {
  display: none;
  gap: 10px;
  margin-top: 6px;
}

.tbtn {
  width: 60px;
  height: 60px;
  font-size: 24px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.tbtn:active {
  background: rgba(87, 230, 255, 0.25);
}

.tbtn.drop {
  background: linear-gradient(180deg, rgba(185,107,255,0.5), rgba(185,107,255,0.25));
}

@media (hover: none) and (pointer: coarse) {
  .touch {
    display: flex;
  }
  .help {
    display: none;
  }
}

@media (max-width: 640px) {
  .layout {
    flex-wrap: wrap;
    justify-content: center;
  }
  .panel {
    flex-direction: row;
    width: 100%;
    justify-content: center;
  }
  .panel .card {
    flex: 1;
    max-width: 150px;
  }
  .board-wrap {
    order: -1;
    width: 100%;
  }
  #board {
    width: min(60vw, 300px);
    height: min(120vw, 600px);
  }
}
