@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Nunito:wght@400;600;700&family=Caveat:wght@400;700&display=swap');

:root {
  --ink: #2c1810;
  --ink-light: #5a3d2b;
  --stone: #d4b896;
  --stone-dark: #b8956a;
  --stone-light: #e8d5b7;
  --coral: #e07a5f;
  --amber: #f4a261;
  --gold: #e9c46a;
  --teal: #2a9d8f;
  --teal-light: #81b29a;
  --cream: #f5e6c8;
  --ocean-deep: #0a1628;
  --ocean-mid: #162a4a;
  --glow: #ffd685;
  --ghost: #fff8e7;
  --stain-red: #c44536;
  --stain-blue: #457b9d;
  --stain-green: #588157;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ocean-deep);
  font-family: 'Nunito', sans-serif;
  color: var(--cream);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Fullscreen button */
#fullscreenBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: rgba(44, 24, 16, 0.7);
  border: 2px solid var(--stone);
  color: var(--cream);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  backdrop-filter: blur(4px);
}
#fullscreenBtn:hover {
  background: rgba(44, 24, 16, 0.9);
  transform: scale(1.1);
}

/* Mute button */
#muteBtn {
  position: fixed;
  top: 12px;
  right: 60px;
  z-index: 100;
  background: rgba(44, 24, 16, 0.7);
  border: 2px solid var(--stone);
  color: var(--cream);
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  backdrop-filter: blur(4px);
}
#muteBtn:hover {
  background: rgba(44, 24, 16, 0.9);
  transform: scale(1.1);
}

/* Pause button (mobile) */
#pauseBtn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  background: rgba(44, 24, 16, 0.7);
  border: 2px solid var(--stone);
  color: var(--cream);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
  display: none;
}

/* Overlay base */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(10, 22, 40, 0.85);
  backdrop-filter: blur(8px);
  transition: opacity 0.3s;
}

.overlay.hidden {
  display: none;
}

/* Menu */
#menuOverlay .menu-title {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(36px, 8vw, 72px);
  color: var(--glow);
  text-shadow: 0 0 30px rgba(255, 214, 133, 0.5), 0 4px 0 var(--ink);
  margin-bottom: 8px;
  text-align: center;
  line-height: 1.1;
}

#menuOverlay .menu-subtitle {
  font-family: 'Caveat', cursive;
  font-size: clamp(18px, 4vw, 28px);
  color: var(--teal-light);
  margin-bottom: 40px;
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
}

.menu-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 18px;
  padding: 14px 32px;
  background: var(--stone);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
  letter-spacing: 0.5px;
}

.menu-btn:hover, .menu-btn:focus {
  background: var(--glow);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255, 214, 133, 0.4);
  outline: none;
}

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

.menu-btn.primary {
  background: var(--coral);
  color: var(--ghost);
  font-size: 20px;
  border-color: var(--ink);
}

.menu-btn.primary:hover {
  background: var(--amber);
}

.menu-version {
  position: absolute;
  bottom: 16px;
  font-size: 12px;
  color: var(--ink-light);
  opacity: 0.6;
}

/* Tutorial */
#tutorialOverlay {
  background: rgba(10, 22, 40, 0.92);
}

.tutorial-box {
  background: var(--stone-light);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  color: var(--ink);
  text-align: center;
}

.tutorial-box h2 {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--ink);
}

.tutorial-box .step-indicator {
  font-family: 'Caveat', cursive;
  font-size: 16px;
  color: var(--ink-light);
  margin-bottom: 16px;
}

.tutorial-box p {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.tutorial-box .key-hint {
  display: inline-block;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: 14px;
  margin: 2px;
}

.tutorial-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.tutorial-nav .menu-btn {
  padding: 10px 24px;
  font-size: 15px;
}

/* Game Over */
#gameOverOverlay .gameover-box {
  text-align: center;
}

#gameOverOverlay .gameover-title {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(32px, 7vw, 56px);
  color: var(--coral);
  margin-bottom: 8px;
}

#gameOverOverlay .gameover-score {
  font-family: 'Playfair Display', serif;
  font-size: clamp(28px, 5vw, 44px);
  color: var(--glow);
  margin-bottom: 4px;
}

#gameOverOverlay .gameover-detail {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--teal-light);
  margin-bottom: 24px;
}

/* Leaderboard */
#leaderboardOverlay .lb-box {
  background: var(--stone-light);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 28px;
  min-width: 320px;
  max-width: 420px;
  width: 90%;
  color: var(--ink);
}

#leaderboardOverlay h2 {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  text-align: center;
  margin-bottom: 16px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.lb-table th {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--ink);
  padding: 6px 8px;
  text-align: left;
}

.lb-table td {
  font-size: 15px;
  padding: 8px;
  border-bottom: 1px solid var(--stone-dark);
}

.lb-table tr.highlight td {
  background: var(--gold);
  font-weight: 700;
}

.lb-table .rank { width: 30px; text-align: center; }
.lb-table .initials { font-weight: 700; width: 50px; }
.lb-table .score { text-align: right; font-family: 'Nunito', monospace; }
.lb-table .date { font-size: 12px; color: var(--ink-light); }

/* Name Entry */
#nameEntryOverlay .name-box {
  text-align: center;
}

#nameEntryOverlay .name-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--glow);
  margin-bottom: 8px;
}

#nameEntryOverlay .name-score {
  font-family: 'Caveat', cursive;
  font-size: 24px;
  color: var(--teal-light);
  margin-bottom: 20px;
}

.name-inputs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.name-inputs input {
  width: 56px;
  height: 64px;
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  caret-color: var(--coral);
}

.name-inputs input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 12px rgba(224, 122, 95, 0.4);
}

/* Pause overlay */
#pauseOverlay {
  background: rgba(10, 22, 40, 0.75);
}

#pauseOverlay h2 {
  font-family: 'Playfair Display', serif;
  font-size: 48px;
  color: var(--glow);
  margin-bottom: 24px;
}

/* Settings */
#settingsOverlay .settings-box {
  background: var(--stone-light);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 28px;
  min-width: 300px;
  max-width: 400px;
  width: 90%;
  color: var(--ink);
  text-align: center;
}

#settingsOverlay h2 {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.setting-row label {
  font-weight: 600;
  font-size: 16px;
}

.setting-row input[type="range"] {
  width: 140px;
  accent-color: var(--coral);
}

/* Mobile controls */
#mobileControls {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 12px 12px;
  z-index: 40;
  pointer-events: none;
}

#mobileControls.hidden {
  display: none;
}

.flipper-btn {
  width: 120px;
  height: 80px;
  border-radius: 16px;
  background: rgba(44, 24, 16, 0.35);
  border: 2px solid rgba(212, 184, 150, 0.4);
  color: rgba(245, 230, 200, 0.5);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  transition: background 0.1s;
}

.flipper-btn:active, .flipper-btn.active {
  background: rgba(224, 122, 95, 0.5);
  border-color: var(--coral);
  color: var(--ghost);
}

.launch-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(224, 122, 95, 0.3);
  border: 2px solid rgba(224, 122, 95, 0.5);
  color: rgba(245, 230, 200, 0.5);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  margin-bottom: 8px;
  transition: background 0.1s;
}

.launch-btn:active, .launch-btn.active {
  background: rgba(224, 122, 95, 0.7);
  color: var(--ghost);
}

/* Demo overlay text */
.demo-text {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--cream);
  opacity: 0;
  animation: demoPulse 2s ease-in-out infinite;
  z-index: 45;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Title animation */
#menuOverlay .menu-title {
  animation: titleFloat 4s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); text-shadow: 0 0 30px rgba(255,214,133,0.5), 0 4px 0 var(--ink); }
  50% { transform: translateY(-6px); text-shadow: 0 0 50px rgba(255,214,133,0.7), 0 4px 0 var(--ink), 0 0 80px rgba(255,214,133,0.25); }
}

.demo-text.visible {
  opacity: 1;
}

@keyframes demoPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

/* Scrollbar hide */
::-webkit-scrollbar { display: none; }
