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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #14181f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f4f0e8;
}

#app {
  position: fixed;
  inset: 0;
  touch-action: none;
}

canvas#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 20px 0 20px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1b2230;
  text-shadow: none;
  pointer-events: none;
  z-index: 5;
}

#hud-timer {
  font-size: 1.4rem;
  color: #c2760c;
}

#hud-mistakes {
  color: #c0392b;
}

.hidden {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, rgba(20,24,31,0.88) 0%, rgba(10,12,16,0.96) 100%);
  text-align: center;
  padding: 24px;
  z-index: 10;
  overflow-y: auto;
  touch-action: pan-y;
}

.screen h1 {
  font-size: 3rem;
  margin: 0;
  background: linear-gradient(180deg, #ffe9b3, #d9a441);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.screen h2 {
  font-size: 2rem;
  margin: 0;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.8;
  margin: 0 0 12px 0;
}

.btn {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(180deg, #6fcf97, #3a9d6a);
  color: #0d1a12;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  cursor: pointer;
}

.btn:active {
  transform: translateY(2px);
}

.btn-secondary {
  background: linear-gradient(180deg, #4a5568, #2d3340);
  color: #f4f0e8;
}

#final-score {
  font-size: 3.2rem;
  font-weight: 800;
  color: #ffd76a;
  margin: 4px 0 10px 0;
}

#initials-input {
  font-size: 2rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  width: 140px;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: #f4f0e8;
  color: #14181f;
  font-weight: 800;
  caret-color: transparent;
}

#keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.kb-row {
  display: flex;
  gap: 6px;
}

.key {
  min-width: 34px;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  background: #2d3340;
  color: #f4f0e8;
  cursor: pointer;
}

.key:active {
  background: #3d4658;
  transform: translateY(1px);
}

.key-wide {
  min-width: 64px;
  background: #4a5568;
}

#screen-interstitial h2 {
  font-size: 2.4rem;
}

#interstitial-count {
  font-size: 5rem;
  font-weight: 800;
  color: #ffd76a;
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: min(360px, 80vw);
  max-height: 50vh;
  overflow-y: auto;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#leaderboard-list li:nth-child(1) { color: #ffd76a; font-weight: 800; }
#leaderboard-list li:nth-child(2) { color: #d9d9d9; font-weight: 700; }
#leaderboard-list li:nth-child(3) { color: #d9a441; font-weight: 700; }

#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}

#flash.hit {
  background: rgba(90, 220, 130, 0.35);
  animation: flashOut 0.25s ease-out forwards;
}

#flash.miss {
  background: rgba(220, 70, 70, 0.4);
  animation: flashOut 0.25s ease-out forwards;
}

#flash.bonus {
  background: rgba(60, 140, 230, 0.4);
  animation: flashOut 0.25s ease-out forwards;
}

@keyframes flashOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
