:root {
  --sky-top: #4ec0ca;
  --sky-bottom: #a8e6cf;
  --pipe: #6bc82c;
  --pipe-dark: #4a9c1e;
  --ground: #ded895;
  --ground-dark: #c8b968;
  --ui-yellow: #ffd23f;
  --ui-brown: #8b4513;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#back-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  color: #00ffaa;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #00ffaa;
  border-radius: 6px;
  padding: 6px 12px;
}

#back-link:hover {
  background: #00ffaa;
  color: #0f1117;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
}

canvas#game {
  display: block;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  text-align: center;
  padding: 20px;
  transition: opacity 0.2s ease;
}

.screen.hidden {
  display: none;
}

.screen h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 44px);
  color: var(--ui-yellow);
  text-shadow: 3px 3px 0 var(--ui-brown), -1px -1px 0 #000;
  letter-spacing: 1px;
}

.screen .hint {
  margin: 0;
  font-size: clamp(14px, 4vw, 18px);
  opacity: 0.9;
}

.screen p#final-score,
.screen p#best-score {
  margin: 0;
  font-size: clamp(18px, 5vw, 24px);
  color: #fff;
}

button {
  margin-top: 10px;
  padding: 14px 38px;
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: bold;
  color: #fff;
  background: linear-gradient(#ff8c42, #ff5e3a);
  border: 3px solid #fff;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.secondary-btn {
  margin-top: 4px;
  padding: 10px 26px;
  font-size: clamp(13px, 3.6vw, 16px);
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--ui-yellow);
  color: var(--ui-yellow);
  box-shadow: none;
}

.secondary-btn:active {
  box-shadow: none;
}

/* Arcade initials entry */
.initials-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.initials-boxes {
  display: flex;
  gap: 10px;
}

.initial-box {
  width: 44px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  color: var(--ui-yellow);
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
}

.initial-box.active {
  border-color: var(--ui-yellow);
  box-shadow: 0 0 12px var(--ui-yellow);
  animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
  50% { border-color: rgba(255, 255, 255, 0.4); box-shadow: none; }
}

.initials-controls {
  display: flex;
  gap: 14px;
}

.arrow-btn {
  margin-top: 0;
  padding: 8px 18px;
  font-size: 18px;
  min-width: 48px;
}

/* Leaderboard */
.leaderboard {
  width: 100%;
  max-width: 320px;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(13px, 3.6vw, 16px);
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.leaderboard-row.highlight {
  background: rgba(255, 210, 63, 0.25);
  border-radius: 4px;
  color: var(--ui-yellow);
  font-weight: bold;
}

.leaderboard-rank {
  width: 2em;
  text-align: right;
  opacity: 0.7;
}

.leaderboard-name {
  flex: 1;
  text-align: left;
  padding-left: 10px;
  letter-spacing: 2px;
}

.leaderboard-score {
  text-align: right;
}

.leaderboard-empty {
  opacity: 0.7;
  padding: 10px;
}

#hud {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

#score {
  font-size: clamp(36px, 10vw, 56px);
  font-weight: bold;
  color: #fff;
  -webkit-text-stroke: 2px #000;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}
