/* ──────────────────────────────────────────────────
   KyKarts — styles  (kienyke.com brand identity)
   Palette: #FF3000 red  |  #101C37 dark navy
            #051937→#004D7A header gradient
   Fonts:   Oswald 700 (headings)  |  Ubuntu 400/500 (body)
   ────────────────────────────────────────────────── */

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #101C37;
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
}

/* ── Canvas ── */
#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Screen overlay system ── */
.screen {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.screen.active {
  pointer-events: auto;
  opacity: 1;
}

/* ══════════════════════════════════════════════════
   CHARACTER SELECT
   ══════════════════════════════════════════════════ */

#screen-select {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 25, 55, 0.92);
}

.cs-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0;
  width: 100%;
}

/* ── Kienyke-style top header bar ── */
.cs-header {
  width: 100%;
  background: linear-gradient(90deg, #051937 0%, #004D7A 100%);
  border-bottom: 3px solid #FF3000;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.cs-logo-dot {
  width: 8px;
  height: 8px;
  background: #FF3000;
  border-radius: 50%;
  flex-shrink: 0;
}

.cs-title {
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.cs-title span {
  color: #FF3000;
}

.cs-header-tagline {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(11px, 1.4vw, 13px);
  color: rgba(255,255,255,0.55);
  letter-spacing: 1px;
  font-weight: 400;
  margin-left: auto;
}

.cs-sub {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(13px, 1.8vw, 16px);
  color: rgba(255,255,255,0.6);
  letter-spacing: 3px;
  font-weight: 500;
  text-transform: uppercase;
  margin-top: 8px;
}

.cs-cards {
  display: flex;
  gap: clamp(12px, 2vw, 28px);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
  padding: 0 24px;
}

.cs-card {
  background: linear-gradient(170deg, #0d1e35 0%, #091526 100%);
  border: 2px solid #1a2d45;
  border-radius: 12px;
  width: clamp(180px, 22vw, 230px);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cs-photo-wrap {
  width: 100%;
  height: clamp(130px, 18vw, 170px);
  overflow: hidden;
  background: #0a1220;
  position: relative;
}

.cs-photo-wrap::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(9,21,38,0.85) 0%, transparent 100%);
}

.cs-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cs-photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 13px;
}

.cs-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.cs-char-name {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(11px, 1.4vw, 13px);
  color: #fff;
  text-align: center;
  line-height: 1.3;
  min-height: 2em;
  font-weight: 500;
}

.cs-stats { display: flex; flex-direction: column; gap: 5px; }

.cs-stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-stat-label {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 9px;
  color: rgba(255,255,255,0.45);
  width: 58px;
  flex-shrink: 0;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cs-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.cs-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.cs-btn {
  margin-top: 4px;
  padding: 8px 0;
  border-radius: 6px;
  text-align: center;
  font-family: 'Oswald', Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
}

.cs-hint {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 13px;
  color: rgba(255,255,255,0.3);
  font-weight: 400;
  letter-spacing: 1px;
  margin: 4px 0 16px;
}

/* ══════════════════════════════════════════════════
   COUNTDOWN
   ══════════════════════════════════════════════════ */

#screen-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
}

#countdown-text {
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
  font-size: clamp(80px, 18vw, 160px);
  font-weight: 700;
  color: #FF3000;
  text-shadow: 0 0 40px rgba(255,48,0,0.7), 0 4px 0 #000;
  letter-spacing: 4px;
  line-height: 1;
}

#countdown-text.pop {
  animation: countPop 0.5s ease-out forwards;
}

@keyframes countPop {
  0%   { transform: scale(1.5); opacity: 0.6; }
  60%  { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.countdown-hint {
  display: flex;
  gap: 16px;
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(11px, 1.5vw, 14px);
  color: rgba(255,255,255,0.6);
  font-weight: 400;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 16px;
}
.countdown-hint span {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 4px;
}

/* ══════════════════════════════════════════════════
   HUD
   ══════════════════════════════════════════════════ */

#screen-hud { pointer-events: none; }

.hud-block {
  position: absolute;
  background: rgba(5, 15, 30, 0.72);
  border-radius: 6px;
  padding: 6px 14px;
  color: #fff;
  font-family: 'Oswald', Arial, sans-serif;
  font-size: clamp(13px, 2vw, 16px);
  letter-spacing: 1px;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.08);
}

.hud-top-left  { top: 14px; left: 14px; }
.hud-top-right {
  top: 14px; right: 14px;
  font-size: clamp(18px, 3vw, 26px);
  color: #FF3000;
  min-width: 64px;
  text-align: center;
  font-weight: 700;
}

.hud-bottom-left { bottom: 14px; left: 14px; }

/* Turbo bar */
#hud-turbo-container {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 180px;
}

.hud-turbo-label {
  font-family: 'Oswald', Arial, sans-serif;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 3px;
}

#hud-turbo-track {
  width: 180px;
  height: 10px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
}

#hud-turbo-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #FF3000, #ff6600);
  border-radius: 5px;
  transition: width 0.05s linear, background 0.2s;
}

.hud-turbo-hint {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 9px;
  color: rgba(255,255,255,0.25);
}

@keyframes turboPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* Portraits */
.hud-bottom-right {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-portrait-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(5, 15, 30, 0.72);
  border-radius: 6px;
  padding: 3px 8px 3px 5px;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.07);
}

.player-row { border: 1px solid rgba(255,48,0,0.55); }

.hud-pos-badge {
  font-family: 'Oswald', Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #FF3000;
  min-width: 26px;
}

.hud-portrait-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
}

.hud-portrait-name {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  min-width: 52px;
  font-weight: 400;
}

/* Minimap */
.hud-minimap {
  position: absolute;
  top: 50px;
  right: 14px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ══════════════════════════════════════════════════
   RESULTS
   ══════════════════════════════════════════════════ */

#screen-results {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 15, 30, 0.90);
}

.res-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0;
  max-width: 520px;
  width: 100%;
}

/* Kienyke-style header on results */
.res-header {
  width: 100%;
  background: linear-gradient(90deg, #051937 0%, #004D7A 100%);
  border-bottom: 3px solid #FF3000;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.res-header-logo {
  font-family: 'Oswald', Arial, sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  letter-spacing: 2px;
}

.res-header-logo span { color: #FF3000; }

.res-header-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.25);
}

.res-title {
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 3px;
}

.res-body {
  width: 100%;
  padding: 20px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.res-commentary {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(14px, 2vw, 17px);
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  text-align: center;
}

.res-podium {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.res-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.07);
}

.res-player {
  background: rgba(255,48,0,0.08);
  border-color: rgba(255,48,0,0.35);
}

.res-medal {
  font-size: 26px;
}

.res-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
}

.res-name {
  flex: 1;
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 500;
  line-height: 1.2;
}

.res-time {
  font-family: 'Ubuntu', 'Courier New', monospace;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

.res-btn {
  margin-top: 4px;
  padding: 14px 48px;
  background: #FF3000;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.1s, box-shadow 0.1s;
}

.res-btn:hover  { transform: scale(1.05); box-shadow: 0 4px 24px rgba(255,48,0,0.5); }
.res-btn:active { transform: scale(0.97); }

.res-row-eliminated {
  opacity: 0.55;
  background: rgba(255,48,0,0.04);
  border-color: rgba(255,48,0,0.12);
}

.res-elim-badge {
  font-family: 'Ubuntu', Arial, sans-serif;
  color: #FF3000;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════
   ELIMINATION BANNER
   ══════════════════════════════════════════════════ */

#elim-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-300px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: linear-gradient(170deg, #051937 0%, #0a1e3a 100%);
  border: 2px solid #FF3000;
  border-radius: 12px;
  padding: 16px 32px;
  min-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.35s ease;
  box-shadow: 0 0 36px rgba(255, 48, 0, 0.35);
}

#elim-banner.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* player elimination gets a slightly more intense glow */
#elim-banner.player-elim {
  border-color: #FF3000;
  box-shadow: 0 0 60px rgba(255, 48, 0, 0.55);
}

#elim-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,48,0,0.6);
  background: #111;
}

#elim-label {
  font-family: 'Oswald', 'Arial Black', Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #FF3000;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(255, 48, 0, 0.7);
}

#elim-banner.player-elim #elim-label {
  color: #FF3000;
  text-shadow: 0 0 18px rgba(255, 48, 0, 0.9);
}

#elim-name {
  font-family: 'Ubuntu', Arial, sans-serif;
  font-size: 14px;
  color: #fff;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
}

/* ══════════════════════════════════════════════════
   TOUCH CONTROLS  (tablet / mobile)
   ══════════════════════════════════════════════════ */

#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

@media (pointer: coarse) {
  #touch-controls { display: block; }
  /* Hide portrait leaderboard — it overlaps touch buttons on small screens */
  #hud-portraits { display: none; }
}

#touch-pad-left {
  position: absolute;
  bottom: 20px;
  left: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

#touch-pad-right {
  position: absolute;
  bottom: 20px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

#touch-accel-row {
  display: flex;
  gap: 10px;
}

.touch-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-size: 22px;
  font-family: 'Oswald', Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.08s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
  background: rgba(255, 48, 0, 0.45);
  border-color: #FF3000;
  transform: scale(0.92);
}

.touch-btn-accel {
  background: rgba(255, 48, 0, 0.25);
  border-color: rgba(255, 48, 0, 0.6);
}

.touch-btn-turbo {
  width: auto;
  height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 2px;
  background: rgba(255, 48, 0, 0.3);
  border-color: rgba(255, 48, 0, 0.7);
}
