/* Breizh Surf — UI plein écran par-dessus la scène Three.js. */

:root {
  --ink: #eaf6ff;
  --ink-dim: #b8d4e2;
  --card: rgba(7, 32, 48, 0.82);
  --card-border: rgba(160, 220, 255, 0.18);
  --accent: #ffd166;
  --accent-ink: #143246;
  --danger: #ff6b6b;
  --ok: #06d6a0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: #0a3f57;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* --- overlays / cartes ----------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.overlay.center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1.6rem 1.8rem;
  width: min(94vw, 420px);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 10, 20, 0.45);
  text-align: center;
}

.logo {
  width: 288px;
  height: 288px;
  max-width: 70vw;
  max-height: 70vw;
  border-radius: 56px;
  box-shadow: 0 14px 40px rgba(0, 10, 20, 0.55);
}

.logo-sm {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  margin-bottom: 0.5rem;
}

h1 {
  margin: 0.4rem 0 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
}

h2 {
  margin: 0 0 0.8rem;
}

.tagline {
  margin: 0.2rem 0 1.2rem;
  color: var(--ink-dim);
}

.hint {
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 0.8rem 0 0;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
}

/* --- boutons & champs -------------------------------------------------------- */

button {
  font: inherit;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: transform 0.06s, background 0.15s;
}

button:hover {
  background: rgba(255, 255, 255, 0.16);
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 700;
}

button.primary:hover {
  filter: brightness(1.06);
}

button.big {
  width: 100%;
  font-size: 1.15rem;
  padding: 0.8rem;
  margin-top: 0.9rem;
}

.icon-btn {
  padding: 0.5rem 0.6rem;
  line-height: 0;
}

.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input[type='text'] {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.62rem 0.8rem;
  width: 100%;
  min-width: 0;
}

input[type='text']::placeholder {
  color: rgba(184, 212, 226, 0.55);
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.join-row,
.seat-row,
.invite-row {
  display: flex;
  gap: 0.5rem;
}

#join-code {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  text-align: center;
  font-weight: 700;
}

.seat-row {
  margin: 0.4rem 0;
}

.invite {
  margin-top: 1rem;
  text-align: left;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.8rem;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.world-row select {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  flex: 1;
}

.invite-row {
  margin-top: 0.3rem;
}

/* --- liste des joueurs -------------------------------------------------------- */

.players {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  text-align: left;
}

.players li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.32rem 0.2rem;
}

.players .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.players .who {
  flex: 1;
}

.players .off {
  opacity: 0.45;
}

.players .tag {
  font-size: 0.75rem;
  color: var(--ink-dim);
}

/* --- chat ---------------------------------------------------------------------- */

.chat {
  margin-top: 1rem;
  text-align: left;
}

.chat ul {
  list-style: none;
  margin: 0 0 0.4rem;
  padding: 0.3rem 0.4rem;
  max-height: 6.5rem;
  overflow-y: auto;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
}

.chat li {
  margin: 0.12rem 0;
  overflow-wrap: anywhere;
}

.chat li strong {
  color: var(--accent);
}

/* --- HUD de course --------------------------------------------------------------- */

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud-top-left {
  position: absolute;
  top: max(0.8rem, env(safe-area-inset-top));
  left: 0.9rem;
  font-size: 0.85rem;
}

.hud-room {
  color: var(--ink-dim);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#scoreboard {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.4rem 0.6rem;
  background: rgba(7, 32, 48, 0.55);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#scoreboard li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0;
}

#scoreboard .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

#scoreboard .pts {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  padding-left: 0.7rem;
}

#scoreboard .dead {
  opacity: 0.45;
  text-decoration: line-through;
}

.hud-top-right {
  position: absolute;
  top: max(0.8rem, env(safe-area-inset-top));
  right: 0.9rem;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.hearts {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
}

.score {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.speed {
  color: var(--ink-dim);
  font-size: 0.85rem;
}

.stage {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.18);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}

.go-stage {
  margin: -0.4rem 0 0.6rem;
  color: var(--accent);
  font-weight: 700;
}

.countdown {
  position: absolute;
  top: 32%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(4rem, 18vw, 9rem);
  font-weight: 900;
  text-shadow: 0 4px 24px rgba(0, 20, 35, 0.6);
  animation: pop 0.9s ease-out infinite;
}

@keyframes pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  25% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.95;
  }
}

.banner {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 800;
  text-shadow: 0 3px 16px rgba(0, 20, 35, 0.65);
}

.controls-hint {
  position: absolute;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: var(--ink-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  font-size: 0.95rem;
}

/* --- fin de course ------------------------------------------------------------- */

.ranking {
  text-align: left;
  margin: 0.4rem 0 1rem;
  padding-left: 0;
  list-style: none;
}

.ranking li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
}

.ranking li:first-child {
  background: rgba(255, 209, 102, 0.14);
}

.ranking .pts {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.go-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

/* --- effets & divers -------------------------------------------------------------- */

#flash {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 32%, rgba(255, 30, 30, 0.78));
  opacity: 0;
  transition: opacity 0.7s;
}

#flash.on {
  opacity: 1;
  transition: opacity 0.04s;
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(7, 32, 48, 0.85);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  animation: toast-in 0.25s ease-out, toast-out 0.5s ease-in 3.5s forwards;
}

.toast strong {
  color: var(--accent);
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
  }
}

.reconnect {
  position: fixed;
  top: max(0.8rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(120, 30, 30, 0.9);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
}
