/* Turbó Kupa — retró versenypálya UI (desktop fókusz) */

:root {
  --accent: #ffb52e;
  --accent-dark: #b87a10;
  --asphalt: #2b2b33;
  --grass: #2f5c2c;
  --danger: #e5433f;
  --boost: #4dc3ff;
  --panel-bg: rgba(18, 16, 22, 0.92);
  --hud-bg: rgba(12, 10, 16, 0.6);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14231a;
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

/* iOS Safari: a body-szintű user-select:none blokkolja az input fókuszát */
input,
textarea {
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}

.hidden {
  display: none !important;
}

/* --- Canvas: teljes képernyő; touch-action csak itt tiltva --- */

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* --- Képernyők (join / lobby) --- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 181, 46, 0.1), transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(77, 195, 255, 0.08), transparent 55%),
    rgba(8, 12, 9, 0.78);
  animation: screenFade 0.35s ease-out;
}

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

.panel {
  background: var(--panel-bg);
  border: 4px solid var(--accent);
  border-radius: 20px;
  padding: 40px 54px;
  text-align: center;
  min-width: 400px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.title {
  font-size: 52px;
  letter-spacing: 3px;
  font-weight: 900;
  font-style: italic;
  color: #fff;
  text-shadow: 3px 3px 0 var(--accent-dark), 6px 6px 14px rgba(0, 0, 0, 0.6);
}

.title-accent {
  color: var(--accent);
}

.tagline {
  margin: 8px 0 22px;
  color: #cfc9bd;
  font-style: italic;
}

.panel-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 16px;
}

#name-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-size: 18px;
  border-radius: 10px;
  border: 2px solid #5a5347;
  background: #201d18;
  color: #fff;
  margin-bottom: 14px;
  outline: none;
  text-align: center;
}

#name-input:focus {
  border-color: var(--accent);
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 26px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #3a3630;
  color: #fff;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #4a453d;
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-big {
  background: var(--accent);
  color: #241a04;
  font-size: 20px;
  padding: 14px 36px;
}

.btn-big:hover:not(:disabled) {
  background: #ffc95e;
}

.hint {
  margin-top: 14px;
  font-size: 13px;
  color: #a9a294;
  line-height: 1.5;
}

#player-list {
  list-style: none;
  margin: 6px 0 10px;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
}

#player-list li {
  padding: 7px 10px;
  font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.car-dot,
.st-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  flex: 0 0 auto;
}

.lobby-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0 4px;
}

/* --- Vezetési preset választó (lobby) --- */

#preset-select {
  margin: 14px 0 6px;
  padding: 10px 12px 8px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

.preset-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #d8d2c6;
  margin-bottom: 8px;
}

.preset-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.preset-btn {
  font-size: 14px;
  padding: 8px 14px;
  opacity: 0.7;
}

.preset-btn.selected {
  opacity: 1;
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

#preset-desc {
  margin-top: 8px;
  min-height: 1.2em;
}

/* --- Rajtlámpa --- */

#startlight {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  text-align: center;
  background: rgba(10, 10, 14, 0.8);
  border: 3px solid #4b4b55;
  border-radius: 16px;
  padding: 14px 22px 10px;
}

.lamp-row {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.lamp {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #33262a;
  border: 2px solid #55444a;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.lamp.on {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(229, 67, 63, 0.9);
}

.lamp.go {
  background: #43d05a;
  border-color: #2c8c3c;
  box-shadow: 0 0 22px rgba(67, 208, 90, 0.95);
}

#startlight-label {
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  margin-top: 6px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* --- HUD --- */

#screen-game {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

#hud-left {
  position: absolute;
  top: 16px;
  left: 18px;
  background: var(--hud-bg);
  border-radius: 12px;
  padding: 10px 18px;
  text-align: left;
}

#hud-pos {
  font-size: 46px;
  font-weight: 900;
  font-style: italic;
  color: var(--accent);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
  line-height: 1;
}

#hud-lap {
  font-size: 18px;
  font-weight: 800;
  margin-top: 4px;
}

#hud-laptime,
#hud-best {
  font-size: 13px;
  color: #d8d2c6;
  margin-top: 2px;
}

#hud-right {
  position: absolute;
  top: 16px;
  right: 18px;
  background: var(--hud-bg);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 190px;
}

#hud-race {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
  text-align: center;
}

.st-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  padding: 2.5px 2px;
}

.st-row.me {
  background: rgba(255, 181, 46, 0.16);
  border-radius: 6px;
  font-weight: 800;
}

.st-pos {
  width: 26px;
  font-weight: 800;
  color: #cfc9bd;
}

.st-row.me .st-pos {
  color: var(--accent);
}

.st-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-lap {
  font-size: 11.5px;
  color: #a9a294;
}

#hud-item {
  position: absolute;
  bottom: 20px;
  left: 18px;
  background: var(--hud-bg);
  border: 2px solid #4b4b55;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 800;
  color: #8f897d;
}

#hud-item.has-item {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 181, 46, 0.35);
}

#feed {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 420px;
}

.feed-entry {
  background: rgba(12, 10, 16, 0.55);
  border-radius: 8px;
  display: inline-block;
  padding: 4px 12px;
  margin-top: 4px;
  font-size: 13.5px;
  animation: feedIn 0.25s ease-out;
}

@keyframes feedIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- bannerek / popok --- */

.banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.banner.gold { color: var(--accent); }
.banner.boost { color: var(--boost); }
.banner.danger { color: var(--danger); }

.banner.pop,
#pos-pop.pop,
#lap-flash.pop {
  animation: popIn 0.4s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes popIn {
  from { transform: translateX(-50%) scale(0.3); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

#pos-pop {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 52px;
  font-weight: 900;
  font-style: italic;
  color: var(--accent);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6);
}

#lap-flash {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.lf-checker {
  width: 220px;
  height: 26px;
  margin: 0 auto 8px;
  background:
    repeating-conic-gradient(#f2f2f2 0% 25%, #181818 0% 50%) 0 0 / 26px 26px;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.lf-text {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

/* --- eredmény / kupa overlay --- */

#results-overlay,
#cupend-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 8, 0.66);
  animation: screenFade 0.3s ease-out;
}

.re-panel {
  background: var(--panel-bg);
  border: 4px solid var(--accent);
  border-radius: 18px;
  padding: 30px 42px;
  text-align: center;
  min-width: 460px;
}

.re-panel h2 {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 14px;
  font-style: italic;
}

#results-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
}

#results-body th {
  color: #a9a294;
  font-size: 12.5px;
  text-transform: uppercase;
  padding: 4px 10px;
}

#results-body td {
  padding: 6px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

#results-body td:nth-child(2) {
  text-align: left;
}

#results-body tr.me td {
  background: rgba(255, 181, 46, 0.14);
  font-weight: 800;
}

/* --- kupa-dobogó --- */

#cup-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  margin: 18px 0 8px;
  flex-wrap: wrap;
}

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.podium-car {
  width: 40px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.podium-name {
  font-weight: 800;
  font-size: 15px;
}

.podium-block {
  width: 104px;
  background: linear-gradient(180deg, #4a453d, #322e28);
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  padding-top: 6px;
}

.place-1 .podium-block {
  background: linear-gradient(180deg, #ffb52e, #a87812);
  color: #241a04;
}

.podium-rest {
  width: 100%;
  margin-top: 12px;
  font-size: 14px;
  color: #cfc9bd;
  line-height: 1.6;
}

/* --- kapcsolat státusz --- */

#conn-status {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(180, 40, 40, 0.9);
  padding: 8px 20px;
  border-radius: 10px;
  z-index: 50;
  font-weight: 700;
}

/* Visszalink a játékválasztóra — meccs közben rejtve */
#home-link {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 30;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #fff;
  opacity: 0.55;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}
#home-link:hover { opacity: 1; }
body:has(#screen-game:not(.hidden)) #home-link { display: none; }
