﻿@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg1: #0f1b24;
  --bg2: #1e2e3a;
  --accent: #f2b705;
  --accent-2: #ff6f5e;
  --ink: #eef3f7;
  --muted: #9db0be;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% 20%, #203240 0%, var(--bg1) 40%, #0a131a 100%);
  color: var(--ink);
}

#c {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  padding: 20px 22px 24px;
}

.stats-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  pointer-events: none;
  margin-top: 8px;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 28px;
  color: var(--muted);
}

.stats {
  margin-top: 0;
  display: grid;
  gap: 6px;
  font-size: 32px;
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 18px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.stats span {
  color: var(--accent);
  font-weight: 600;
}

.next-preview {
  display: grid;
  gap: 10px;
  padding: 16px 16px 14px;
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.next-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

#next-preview-canvas {
  width: 75px;
  height: 75px;
  display: block;
}

.camera-rotate {
  margin-top: 8px;
  display: grid;
  gap: 16px;
  pointer-events: auto;
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 18px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.camera-label {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.camera-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.camera-rotate button {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(24, 34, 42, 0.9);
  color: var(--ink);
  font-size: 28px;
  padding: 18px 26px;
  min-width: 92px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.camera-rotate button:hover {
  transform: translateY(-1px);
  background: rgba(36, 50, 60, 0.9);
}

.hint {
  margin-top: -10px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  border-radius: 12px;
  transform: none;
  max-width: 420px;
  line-height: 1.5;
  white-space: normal;
  transition: opacity 200ms ease;
}

.hint.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.version {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  padding-left: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard {
  position: absolute;
  right: 24px;
  top: 160px;
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 320px;
  pointer-events: auto;
}

.leaderboard.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.leaderboard-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  font-size: 16px;
  color: var(--ink);
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-list .lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list .lb-score {
  color: var(--accent);
  font-weight: 600;
}

#restart {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  pointer-events: auto;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #120d08;
  font-weight: 700;
  padding: 44px 76px;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  transition: transform 200ms ease, filter 200ms ease;
}

#restart:hover {
  filter: brightness(1.05);
  transform: translateX(-50%) translateY(-2px);
}

.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

#restart.hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

#mobile-controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(8px, 2.5vw, 16px);
  pointer-events: auto;
  --joystick-size: clamp(96px, min(26vw, 24vh), 200px);
  --stick-size: calc(var(--joystick-size) * 0.44);
  --drop-pad-y: clamp(14px, 4.5vw, 36px);
  --drop-pad-x: clamp(24px, 9vw, 64px);
  --drop-font: clamp(13px, 3.6vw, 20px);
}

body.touch-device #mobile-controls {
  display: flex;
}

body.force-touch #mobile-controls {
  display: flex;
}

.toggle-controls {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(24, 34, 42, 0.9);
  color: var(--ink);
  font-size: 16px;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.toggle-controls:hover {
  transform: translateY(-1px);
  background: rgba(36, 50, 60, 0.9);
}

.joystick {
  width: var(--joystick-size);
  height: var(--joystick-size);
  aspect-ratio: 1 / 1;
  flex: 0 0 var(--joystick-size);
  border-radius: 50%;
  background: rgba(10, 18, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.joystick .stick {
  width: var(--stick-size);
  height: var(--stick-size);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 80ms ease;
}

#drop-btn {
  pointer-events: auto;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #120d08;
  font-weight: 700;
  padding: var(--drop-pad-y) var(--drop-pad-x);
  font-size: var(--drop-font);
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

@media (max-width: 640px) {
  #mobile-controls {
    bottom: 12px;
  }

  #restart {
    padding: clamp(14px, 4.5vw, 36px) clamp(24px, 9vw, 64px);
    font-size: clamp(13px, 3.6vw, 20px);
  }

  .stats {
    font-size: 26px;
  }

  #next-preview-canvas {
    width: 70px;
    height: 70px;
  }

  .leaderboard {
    max-width: 260px;
    right: 12px;
    top: 140px;
  }

  .leaderboard-list {
    font-size: 14px;
  }
}

@media (max-width: 1100px), (max-height: 720px) {
  .stats {
    font-size: 18px;
    padding: 10px 12px;
  }

  .hint {
    font-size: 11px;
    padding: 10px 12px;
    max-width: 320px;
  }

  .next-preview {
    padding: 10px 12px;
  }
}

@media (max-width: 640px) {
  .stats {
    font-size: 14px;
  }

  .hint {
    font-size: 9px;
    line-height: 1.35;
    padding: 8px 10px;
    max-width: 260px;
  }

  .camera-rotate {
    font-size: 12px;
  }

  #next-preview-canvas {
    width: 60px;
    height: 60px;
  }

  .leaderboard {
    right: 10px;
    top: 120px;
    max-width: 210px;
    padding: 8px 10px;
  }

  .leaderboard-title {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .leaderboard-list {
    font-size: 12px;
    gap: 4px;
  }
}
