﻿:root {
  --bg0: #0d1119;
  --bg1: #172033;
  --panel: #101826;
  --ink: #e8f0ff;
  --muted: #9ab0d4;
  --accent: #40f5c8;
  --warn: #ffc85c;
  --danger: #ff6b6b;
  --grid-line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #1e2d48 0%, var(--bg0) 45%, #06080d 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: manipulation;
}

.app {
  min-height: 100vh;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
  text-shadow: 0 0 8px rgba(64, 245, 200, 0.5);
}

.hud {
  width: min(96vw, 620px);
  background: linear-gradient(180deg, rgba(33, 49, 79, 0.88), rgba(14, 23, 39, 0.94));
  border: 1px solid rgba(154, 176, 212, 0.3);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.92rem;
}

.hud-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.hud-item .label {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-item .value {
  font-weight: 700;
  color: var(--ink);
}

.canvas-wrap {
  width: min(96vw, 620px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(64, 245, 200, 0.35);
  box-shadow: 0 0 24px rgba(64, 245, 200, 0.2);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: linear-gradient(180deg, var(--bg1) 0%, #0d1422 100%);
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.controls {
  width: min(96vw, 620px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

button {
  min-height: 46px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #3be4bb, #26b78f);
  color: #04261e;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-size: 0.95rem;
}

button.secondary {
  background: linear-gradient(180deg, #9eb4d8, #6f88b4);
  color: #0e1a30;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 12, 0.78);
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 12px;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  width: min(96vw, 520px);
  background: linear-gradient(180deg, #1b2a46, #0d1525);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.panel h2 {
  margin: 0 0 10px;
  color: var(--warn);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: clamp(1rem, 4vw, 1.35rem);
}

.panel p {
  margin: 6px 0;
  color: var(--ink);
}

.leaderboard {
  margin-top: 10px;
  text-align: left;
  font-size: 0.92rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 8px;
}

.leaderboard div {
  padding: 4px 2px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.panel-actions button {
  min-height: 44px;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

input[type="text"] {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(4, 9, 17, 0.72);
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.95rem;
}

@media (min-width: 780px) {
  .hud { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
