/*
 * Game UI styles for Stunt Car Racer.
 *
 * All game overlay, button, HUD, and screen styles live here,
 * keeping presentation out of game.js.
 */

/* ── Fixed overlays ──────────────────────────────────────── */

#fadeOverlay {
  position: fixed;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.35s ease;
}

#gameUI {
  position: fixed;
  left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 100;
  user-select: none;
  -webkit-user-select: none;
}

#season-overlay {
  position: fixed;
  left: 0; top: 0;
  width: 100%; height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 150;
  background: rgba(0, 0, 0, 0.85);
}

#season-card {
  background: rgba(20, 20, 40, 0.95);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 3vh 4vw;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  font-family: Arial, sans-serif;
  text-align: center;
  box-sizing: border-box;
  min-width: min(80vw, 360px);
}

/* ── Base game button ────────────────────────────────────── */

.game-button {
  position: absolute;
  display: none;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  font-family: Arial, sans-serif;
  font-weight: bold;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}

/* ── Main menu buttons ───────────────────────────────────── */

#mm-title {
  left: 50%; top: 18%;
  width: 70vw; height: auto;
  max-width: 400px;
  font-size: min(6vw, 32px);
  pointer-events: none;
  background: none; border: none;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
  transform: translateX(-50%);
}

#mm-practise {
  left: 50%; top: 40%;
  width: 50vw; height: 14vw;
  max-width: 280px; max-height: 70px;
  font-size: min(5vw, 26px);
  transform: translateX(-50%);
}

#mm-season {
  left: 50%; top: calc(40% + 16vw);
  width: 50vw; height: 14vw;
  max-width: 280px; max-height: 70px;
  font-size: min(5vw, 26px);
  transform: translateX(-50%);
}

/* ── Track menu (practise) ───────────────────────────────── */

#tc-prev {
  left: 2vw; bottom: 6vh;
  width: 14vw; height: 14vw;
  max-width: 75px; max-height: 75px;
  font-size: min(6vw, 32px);
}

#tc-next {
  left: 18vw; bottom: 6vh;
  width: 14vw; height: 14vw;
  max-width: 75px; max-height: 75px;
  font-size: min(6vw, 32px);
}

#tc-select {
  right: 2vw; bottom: 6vh;
  width: 22vw; height: 14vw;
  max-width: 130px; max-height: 75px;
  font-size: min(3.5vw, 18px);
}

#tc-trackname {
  left: 34vw; right: 26vw;
  width: auto;
  bottom: 6vh; height: 14vw;
  max-height: 75px;
  font-size: min(3.8vw, 20px);
  pointer-events: none;
  background: none; border: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

#tc-backmain {
  left: 2vw; top: 2vh;
  width: 18vw; height: 10vw;
  max-width: 100px; max-height: 55px;
  font-size: min(3.5vw, 18px);
}

/* ── Track preview (practise) ────────────────────────────── */

#tc-back {
  left: 2vw; bottom: 6vh;
  width: 22vw; height: 12vw;
  max-width: 120px; max-height: 70px;
  font-size: min(4.5vw, 22px);
}

#tc-start {
  right: 2vw; bottom: 6vh;
  width: 22vw; height: 12vw;
  max-width: 120px; max-height: 70px;
  font-size: min(4.5vw, 22px);
}

/* ── In-game driving controls (mobile) ───────────────────── */

#tc-left {
  left: 2vw; bottom: 6vh;
  width: 11vw; height: 11vw;
  max-width: 65px; max-height: 65px;
  font-size: min(5vw, 28px);
}

#tc-right {
  left: 15vw; bottom: 6vh;
  width: 11vw; height: 11vw;
  max-width: 65px; max-height: 65px;
  font-size: min(5vw, 28px);
}

#tc-accel {
  right: 2vw; bottom: 30vh;
  width: 11vw; height: 11vw;
  max-width: 65px; max-height: 65px;
  font-size: min(5vw, 28px);
}

#tc-brake {
  right: 2vw; bottom: 6vh;
  width: 11vw; height: 11vw;
  max-width: 65px; max-height: 65px;
  font-size: min(5vw, 28px);
}

#tc-boost {
  left: 50%; bottom: 6vh;
  width: 22vw; height: 11vw;
  max-width: 120px; max-height: 65px;
  font-size: min(5vw, 28px);
  transform: translateX(-50%);
}

/* ── In-game common ──────────────────────────────────────── */

#tc-menu {
  right: 2vw; top: 2vh;
  width: 10vw; height: 10vw;
  max-width: 55px; max-height: 55px;
  font-size: min(5vw, 28px);
}



/* ── Game over / result ──────────────────────────────────── */

#tc-gameover-label {
  left: 50%; top: 40%;
  width: 80vw; height: auto;
  max-width: 500px;
  font-size: min(7vw, 40px);
  pointer-events: none;
  background: none; border: none;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
  transform: translate(-50%, -50%);
}

#tc-gameover {
  left: 50%; bottom: 6vh;
  width: 18vw; height: 11vw;
  max-width: 100px; max-height: 65px;
  font-size: min(3.5vw, 18px);
  transform: translateX(-50%);
}

/* ── HUD bars ────────────────────────────────────────────── */

.hud-bar {
  position: absolute;
  display: none;
  align-items: center;
  pointer-events: none;
  height: 2.5vh;
  min-height: 14px;
}

.hud-icon {
  font-size: min(6vh, 30px);
  margin-right: 1vw;
  line-height: 1;
}

.hud-track {
  flex: 1;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.hud-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.15s;
}

#tc-hud-damage {
  left: 2vw; right: 14vw;
  top: 2vh;
  padding-left: 1vw;
}

#tc-hud-damage-fill { background: #ff3333; }

/* ── HUD box (left side) ─────────────────────────────────── */

#tc-hud-box {
  position: absolute;
  display: none;
  left: 1.5vw;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  flex-direction: row;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 0.6em 0.8em;
  gap: 0.6em;
}

.hud-speed-track {
  width: 6px;
  min-width: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.hud-speed-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  border-radius: 3px;
  background: linear-gradient(0deg, #44cc44, #cccc00, #ff4400);
  transition: height 0.10s;
}

.hud-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-row {
  font-family: 'Courier New', Courier, monospace;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  line-height: 1.4;
  min-height: 1.4em;
}

/* Compact HUD on mobile / touch devices */
.hud-box-mobile {
  padding: 0.4em 0.6em !important;
  gap: 0.5em !important;
}
.hud-box-mobile .hud-speed-track {
  width: 5px;
  min-width: 5px;
}
.hud-box-mobile .hud-row {
  font-size: 12px;
}

/* ── Credits ── */

.credits-btn {
  position: absolute;
  right: 3vw;
  bottom: 2vh;
  width: auto;
  min-width: 0;
  padding: 0.8vh 1.5vw;
  font-size: min(4vw, 20px);
  opacity: 0.6;
}

.credits-text {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.credits-text h1 {
  font-size: min(4vw, 20px);
  margin: 2.5vh 0 0.5vh;
  color: #ffcc00;
}

.credits-text h2 {
  font-size: min(3vw, 16px);
  margin: 1vh 0 0.3vh;
  color: #ccc;
  font-weight: normal;
}

.credits-text p {
  font-size: min(3vw, 16px);
  margin: 0.3vh 0;
  color: #fff;
}

.credits-text a {
  color: #66bbff;
}

.credits-aside {
  font-style: italic;
  opacity: 0.7;
}

/* ── Overlay buttons (used in season and multiplayer screens) ── */

.overlay-button {
  display: inline-block;
  margin: 1.5vh 1vw;
  padding: 1.5vh 4vw;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: min(4vw, 20px);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.overlay-button-secondary {
  opacity: 0.5;
  font-size: min(3vw, 14px);
}

/* ── Overlay text styles ─────────────────────────────────── */

.overlay-title             { font-size: min(5vw, 28px); margin-bottom: 2vh; }
.overlay-title-large       { font-size: min(6vw, 32px); margin-bottom: 1vh; }
.overlay-subtitle          { font-size: min(3.5vw, 18px); opacity: 0.7; margin-bottom: 1vh; }
.overlay-description       { font-size: min(3vw, 16px); opacity: 0.7; margin-bottom: 2vh; }
.overlay-label             { font-size: min(2.5vw, 13px); opacity: 0.5; margin-bottom: 0.5vh; }
.overlay-track             { font-size: min(5vw, 28px); margin: 2vh 0; }
.overlay-matchup           { font-size: min(6vw, 32px); margin: 2vh 0; }
.overlay-matchup-vs        { opacity: 0.5; font-size: min(4vw, 22px); }
.overlay-winner            { font-size: min(4vw, 22px); margin: 1vh 0; }
.overlay-fastest           { font-size: min(3.5vw, 18px); margin: 1vh 0; }
.overlay-detail            { font-size: min(3vw, 16px); opacity: 0.6; margin: 1vh 0; }
.overlay-info              { font-size: min(3.5vw, 18px); opacity: 0.7; margin: 1vh 0; }
.overlay-result-large      { font-size: min(6vw, 32px); margin: 2vh 0; }
.overlay-result            { font-size: min(5vw, 26px); margin: 2vh 0; }
.overlay-result-small      { font-size: min(4vw, 20px); margin: 2vh 0; }

/* ── Color helpers ───────────────────────────────────────── */

.color-gold   { color: #ffd700; }
.color-green  { color: #44ff44; }
.color-red    { color: #ff4444; }
.color-orange { color: #ff8844; }
.color-yellow { color: #ffdd44; }

/* ── Multiplayer inputs ──────────────────────────────────── */

.multiplayer-code-display {
  font-size: min(10vw, 60px);
  letter-spacing: 0.3em;
  margin: 2vh 0;
}

.multiplayer-code-input {
  font-size: min(10vw, 60px);
  text-align: center;
  letter-spacing: 0.3em;
  width: min(60vw, 300px);
  padding: 1vh 2vw;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: monospace;
  outline: none;
}

.multiplayer-signaling-input {
  font-size: min(3vw, 15px);
  text-align: center;
  width: min(70vw, 340px);
  padding: 0.8vh 1.5vw;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: monospace;
  outline: none;
  margin-bottom: 2vh;
}

.multiplayer-status {
  font-size: min(3vw, 16px);
  opacity: 0.7;
  margin: 1vh 0;
  min-height: 3vh;
}

/* ── Season overview ─────────────────────────────────────── */

.season-grid {
  display: flex;
  gap: 1vw;
  justify-content: center;
  align-items: stretch;
  margin: 1vh 0;
}

.season-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 1.5vh 1vw;
  display: flex;
  flex-direction: column;
}

.season-card-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

.season-label {
  font-size: min(3.5vw, 17px);
  font-weight: bold;
  margin-bottom: 1vh;
}

.season-player {
  font-size: min(3vw, 15px);
  padding: 0.3vh 0;
  opacity: 0.8;
}

.season-player-human {
  color: #ffdd44;
  font-weight: bold;
  opacity: 1;
}

.season-spacer { flex: 1; }

.season-tracks {
  margin-top: 1.5vh;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 1vh;
}

.season-track-name {
  font-size: min(2.5vw, 13px);
  opacity: 0.6;
  padding: 0.2vh 0;
}

/* ── Standings table ─────────────────────────────────────── */

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: min(3.5vw, 18px);
  margin: 1vh 0;
}

.standings-table td {
  padding: 0.5vh 1vw;
}

.standings-header {
  opacity: 0.6;
}

.standings-center {
  text-align: center;
}

.standings-bold {
  font-weight: bold;
}
