:root {
  color-scheme: dark;
  --bg: #091018;
  --panel: #121d2a;
  --panel-2: #172638;
  --text: #e8f4ff;
  --muted: #95a8ba;
  --accent: #51c8ff;
  --danger: #ff6b6b;
  --border: rgba(255,255,255,.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #17324a 0%, var(--bg) 48%, #04070b 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: center;
  padding: 24px 0;
}

h1, h2 { margin: 0 0 10px; }
h1 { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); margin: 0 0 18px; }

.card,
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.24);
}

.panel {
  width: min(720px, 100%);
  background: rgba(10, 18, 30, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

label { display: block; margin-bottom: 8px; color: var(--muted); }
.row { display: flex; gap: 8px; }

input, button {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
}

input {
  flex: 1;
  width: 100%;
  background: rgba(0,0,0,.24);
  color: var(--text);
}

input[type="color"] {
  height: 44px;
  padding: 4px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #031018;
  font-weight: 800;
}

button:disabled { opacity: .45; cursor: not-allowed; }
.stats { display: grid; gap: 8px; color: var(--muted); }
.stats strong { color: var(--text); }

.chat { min-height: 300px; }
.messages {
  height: 210px;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(0,0,0,.22);
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.message { margin-bottom: 9px; line-height: 1.3; }
.message strong { color: var(--accent); }
.message small { color: var(--muted); }

.game-wrap {
  display: grid;
  place-items: center;
  gap: 14px;
}

.auth-panel h2 { margin-top: 0; }

.auth-panel label,
.profile-panel label {
  margin: 10px 0;
  font-size: 0.95rem;
}

.auth-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.auth-buttons button,
.profile-panel button {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: #26a9e0;
  color: #03131f;
  font-weight: 700;
}

#authMessage {
  min-height: 24px;
  color: #ffd166;
}

.hidden { display: none !important; }

canvas {
  width: 100%;
  max-width: 768px;
  aspect-ratio: 3 / 2;
  image-rendering: pixelated;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  background: #102615;
  box-shadow: 0 26px 80px rgba(0,0,0,.45);
}

.mobile-controls {
  display: none;
  gap: 8px;
  text-align: center;
}

.mobile-controls button {
  width: 58px;
  height: 48px;
  margin: 3px;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; align-items: start; }
  .mobile-controls { display: block; }
}
