:root {
  --bg: #05060f;
  --panel: rgba(12, 16, 40, 0.88);
  --line: rgba(110, 150, 255, 0.25);
  --text: #e8ecff;
  --muted: #8a93bd;
  --accent: #00f0ff;
  --accent2: #ff2bd6;
  --me: #00f0ff;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }

.logo { margin: 0; font-weight: 900; letter-spacing: .12em; font-size: 2.4rem; color: var(--accent);
  text-shadow: 0 0 12px var(--accent), 0 0 32px rgba(0,240,255,.5); }
.logo span { color: var(--accent2); text-shadow: 0 0 12px var(--accent2), 0 0 32px rgba(255,43,214,.5); margin-left: .25em; }
.logo.big { font-size: clamp(2.5rem, 5vw, 4.5rem); }

button.big { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #05060f;
  font-weight: 800; font-size: 1.25rem; padding: .9em 1.6em; border-radius: 14px; letter-spacing: .04em;
  box-shadow: 0 0 24px rgba(0,240,255,.35); }
button.big:disabled { opacity: .4; box-shadow: none; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: .5em .9em; color: var(--muted); }
button.ghost.small { font-size: .85rem; }
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 3px; background: var(--c);
  box-shadow: 0 0 8px var(--c); flex: none; }

/* ================= PHONE ================= */
body.phone { overflow: hidden; height: 100dvh; touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; position: fixed; inset: 0; }
.phone .screen { display: none; position: absolute; inset: 0; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.phone .screen.active { display: flex; }

#join { align-items: center; justify-content: center; gap: 2rem; padding: 24px; touch-action: auto; }
#joinForm { width: min(100%, 360px); display: flex; flex-direction: column; gap: 1rem; }
#joinForm label { display: flex; flex-direction: column; gap: .4rem; color: var(--muted); font-size: .9rem; }
#joinForm input { background: #0c1030; border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  font-size: 1.4rem; padding: .7em .8em; outline: none; user-select: text; -webkit-user-select: text; }
#joinForm input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,240,255,.2); }
#code { text-transform: uppercase; letter-spacing: .5em; padding-left: 1.3em !important; text-align: center; font-weight: 800; font-size: 2rem !important; }
.error { color: #ff6b8a; min-height: 1.2em; margin: 0; text-align: center; }

.bar { display: flex; align-items: center; gap: .6rem; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.swatch { width: 28px; height: 28px; border-radius: 8px; background: var(--me); box-shadow: 0 0 14px var(--me); }
.me { font-weight: 800; font-size: 1.2rem; color: var(--me); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: .85rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .25em .7em; }

.touch { flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--me) 14%, transparent), transparent 70%);
  border-bottom: 1px solid var(--line); overflow: hidden; }
.status { text-align: center; padding: 0 24px; display: flex; flex-direction: column; align-items: center; gap: .6rem; z-index: 2; pointer-events: none; }
.status button { pointer-events: auto; margin-top: .8rem; }
#statusBig { font-size: clamp(2rem, 10vw, 3.5rem); font-weight: 900; color: var(--me); text-shadow: 0 0 18px var(--me); }
#statusSmall { color: var(--muted); font-size: 1rem; max-width: 22em; }
.hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: .8rem; opacity: .6; }
.arrow { position: absolute; font-size: 9rem; color: var(--me); opacity: 0; pointer-events: none; text-shadow: 0 0 30px var(--me); }
.arrow.flash { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .55; transform: scale(1); } to { opacity: 0; transform: scale(1.3); } }
body.dead .touch { filter: grayscale(.8) brightness(.6); }
body[data-phase="playing"]:not(.dead) .hint { opacity: .25; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px 18px; }
.dpad { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); gap: 6px; }
.d { background: #0d1336; border: 1px solid var(--line); border-radius: 14px; font-size: 1.5rem; color: var(--me); touch-action: none; }
.d:active { background: color-mix(in srgb, var(--me) 35%, #0d1336); }
.up { grid-area: 1 / 2; } .left { grid-area: 2 / 1; } .right { grid-area: 2 / 3; } .down { grid-area: 3 / 2; }
.boost { width: 118px; height: 118px; border-radius: 50%; font-weight: 900; font-size: 1.1rem; letter-spacing: .08em;
  background: radial-gradient(circle, var(--me), color-mix(in srgb, var(--me) 40%, #000)); color: #05060f;
  box-shadow: 0 0 28px var(--me); touch-action: none; transition: filter .2s, box-shadow .2s; }
.boost:active { transform: scale(.95); }
.boost.cooling { filter: grayscale(1) brightness(.5); box-shadow: none; }
@media (max-height: 560px) { .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); } .boost { width: 92px; height: 92px; } }

/* ================= HOST / TV ================= */
body.host { display: flex; overflow: hidden; }
.stage { flex: 1; position: relative; min-width: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(3,4,12,.72); backdrop-filter: blur(4px); padding: 2vw; }
.lobby-card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 2.2vw 3vw;
  display: flex; flex-direction: column; align-items: center; gap: 1.6vw; max-width: 1100px; width: 100%;
  box-shadow: 0 0 60px rgba(60,100,255,.15); }
.join-row { display: flex; align-items: center; gap: 3vw; }
#qr { width: clamp(150px, 16vw, 260px); aspect-ratio: 1; border-radius: 14px; background: #fff; padding: 6px; }
.join-text { display: flex; flex-direction: column; gap: .4vw; }
.label { color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.5rem); }
.url { font-size: clamp(1.4rem, 2.6vw, 2.6rem); font-weight: 700; color: var(--text); }
.code { font-size: clamp(3.5rem, 9vw, 9rem); font-weight: 900; letter-spacing: .15em; line-height: 1; color: var(--accent);
  text-shadow: 0 0 20px var(--accent), 0 0 60px rgba(0,240,255,.5); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .6vw; min-height: 3rem; }
.chip { display: inline-flex; align-items: center; gap: .5em; padding: .45em .9em; border-radius: 999px;
  border: 1px solid var(--c); color: var(--c); font-weight: 700; font-size: clamp(.9rem, 1.3vw, 1.4rem);
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 40%, transparent); cursor: pointer; animation: popin .3s; }
.chip .dot { background: var(--c); }
.chip.off { opacity: .35; }
.spectator .chip { cursor: default; }
.empty { color: var(--muted); }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }
.lobby-actions { display: flex; align-items: center; gap: 1.2rem; }
.keyhint { color: var(--muted); font-size: .9rem; }
.spectator .lobby-actions, .spectator .side-foot { display: none; }

.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 22vh; font-weight: 900; color: #fff; text-shadow: 0 0 30px var(--accent), 0 0 80px var(--accent2); }
.countdown.pop { animation: cd 1s ease-out; }
@keyframes cd { from { transform: scale(1.6); opacity: 0; } 20% { transform: scale(1); opacity: 1; } to { opacity: .2; } }

.results-card { max-width: 720px; }
.winner { font-size: clamp(2rem, 4vw, 3.6rem); font-weight: 900; display: flex; align-items: center; gap: .4em; }
.standings { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; gap: .4rem 1.5rem;
  font-size: clamp(.9rem, 1.3vw, 1.25rem); }
.standings li { display: flex; align-items: center; gap: .6em; padding: .25em 0; border-bottom: 1px solid rgba(110,150,255,.1); }
.standings .pl { width: 1.8em; color: var(--muted); font-weight: 800; }
.standings .nm { flex: 1; font-weight: 700; }
.standings .kl { color: var(--accent2); font-size: .85em; }
.standings .sc { font-weight: 900; }

.sidebar { width: clamp(200px, 17vw, 300px); background: #070918; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; }
.side-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.side-code { color: var(--muted); }
.side-code b { color: var(--accent); font-size: 1.6rem; letter-spacing: .12em; margin-left: .3em; text-shadow: 0 0 10px var(--accent); }
.round-no { color: var(--muted); font-size: .9rem; }
.board { list-style: none; margin: 0; padding: 8px 0; flex: 1; overflow: auto; }
.board li { display: flex; align-items: center; gap: .6em; padding: .45em 18px; font-size: clamp(.9rem, 1.1vw, 1.2rem); color: var(--c); font-weight: 700; transition: opacity .3s; }
.board li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .sc { color: var(--text); font-weight: 900; }
.board li.dead { opacity: .35; text-decoration: line-through; }
.board li.off { opacity: .3; font-style: italic; }
.side-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

/* ---- Home ---- */
#home { align-items: center; justify-content: center; gap: 1.4rem; padding: 24px; touch-action: auto; text-align: center; }
.tagline { color: var(--muted); margin: 0; line-height: 1.5; }
.home-buttons { display: flex; flex-direction: column; gap: 1rem; width: min(100%, 380px); margin-top: .6rem; }
.choice { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-decoration: none; font-size: 1.5rem; padding: 1em; }
.choice small { font-size: .8rem; font-weight: 600; letter-spacing: 0; opacity: .75; }
.host-choice { background: transparent; color: var(--accent); border: 2px solid var(--accent);
  box-shadow: 0 0 20px rgba(0,240,255,.25), inset 0 0 20px rgba(0,240,255,.1); }
.back { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; }
@media (min-width: 760px) { .home-buttons { flex-direction: row; width: min(100%, 720px); } .choice { flex: 1; } }

/* ---- Host page on small screens / phones ---- */
.home-link { color: var(--muted); text-decoration: none; font-size: 1.6rem; line-height: 1; margin-right: .4rem; }
@media (max-width: 820px) {
  body.host { flex-direction: column; height: 100dvh; }
  .stage { flex: 1; min-height: 0; }
  .sidebar { width: 100%; max-height: 32dvh; border-left: 0; border-top: 1px solid var(--line); }
  .board { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); padding: 4px 0; }
  .board li { padding: .3em 12px; }
  .side-head, .side-foot { padding: 8px 12px; }
  .overlay { padding: 10px; align-items: flex-start; overflow-y: auto; }
  .lobby-card { padding: 18px; gap: 14px; border-radius: 16px; }
  .join-row { flex-direction: column; gap: 10px; text-align: center; }
  .join-text { align-items: center; gap: 4px; }
  #qr { width: 140px; }
  .code { font-size: 3.2rem; }
  .url { font-size: 1.1rem; word-break: break-all; }
  .chips { gap: 6px; }
  .chip { font-size: .85rem; }
  .lobby-actions { flex-direction: column; gap: 8px; }
  .keyhint { display: none; }
  .standings { grid-template-columns: 1fr; grid-auto-flow: row; grid-template-rows: none !important; }
  .countdown { font-size: 14vh; }
}

/* ---- Phone live map ---- */
.touch { background: #04050c; }
.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.status { position: absolute; inset: 0; justify-content: center; background: rgba(3,4,12,.55); transition: background .3s; }
body.riding .status { background: transparent; }
body.riding #statusSmall:empty { display: none; }
#statusBig:empty { display: none; }
.small-note { font-size: .9rem !important; opacity: .7; }
.phone button, .phone a, .phone input { touch-action: manipulation; }

/* ---- Swipe-only phone layout: map fills the screen, boost floats in the corner ---- */
.phone .touch { border-bottom: 0; }
.phone .boost { position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 3;
  width: 92px; height: 92px; font-size: .95rem; opacity: .85; }
.phone .hint { bottom: calc(14px + env(safe-area-inset-bottom)); left: 16px; right: auto; text-align: left; }
body.riding .hint { opacity: 0; }
.phone #status { padding-bottom: 80px; }

/* ---- Host bot controls ---- */
.bot-row { display: flex; align-items: center; gap: 10px; }
.botbtn { width: 44px; height: 44px; font-size: 1.4rem; padding: 0; color: var(--text); }
.botbtn:disabled, .bot-row .small:disabled { opacity: .3; }
.bot-count { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.4rem; color: var(--accent); }
.spectator .bot-row { display: none; }
.botbtn { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }

/* ---- Polish: kill feed ---- */
.feed { position: absolute; top: 18px; left: 22px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 5; }
.feed-item { background: rgba(5,6,15,.78); border: 1px solid var(--line); border-radius: 10px; padding: .35em .8em;
  font-size: clamp(.85rem, 1.1vw, 1.15rem); color: var(--muted); animation: feedin .25s ease-out; transition: opacity .6s, transform .6s; }
.feed-item b { font-weight: 800; }
.feed-item.gone { opacity: 0; transform: translateX(-12px); }
@keyframes feedin { from { opacity: 0; transform: translateX(-16px); } }

/* ---- Polish: host settings ---- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-left: 10px; }
.seg button { background: transparent; color: var(--muted); padding: .45em .8em; font-size: .9rem; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: rgba(0,240,255,.15); color: var(--accent); font-weight: 700; }
.toggle { display: inline-flex; align-items: center; gap: .6em; color: var(--muted); cursor: pointer; font-size: .95rem; }
.toggle input { width: 1.1em; height: 1.1em; accent-color: var(--accent); }
.spectator .toggle { display: none; }
@media (max-width: 820px) { .bot-row { flex-wrap: wrap; justify-content: center; } .feed { top: 8px; left: 8px; } }

/* ---- Polish: boost recharge ring ---- */
.phone .boost { --p: 100%; position: absolute; }
.phone .boost::before { content: ''; position: absolute; inset: -6px; border-radius: 50%;
  background: conic-gradient(var(--me) var(--p), rgba(255,255,255,.08) 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%); mask: radial-gradient(circle, transparent 62%, #000 63%); }
.phone .boost.cooling { filter: none; box-shadow: none; background: radial-gradient(circle, #2a2f45, #10131f); color: var(--muted); }

/* ---- Polish: sideways phones get a slim header so the map is as big as possible ---- */
@media (orientation: landscape) and (max-height: 500px) {
  .phone .bar { padding: 4px 12px; }
  .phone .swatch { width: 18px; height: 18px; }
  .phone .me { font-size: 1rem; }
  .phone .boost { width: 76px; height: 76px; }
  .phone .hint { display: none; }
}

/* ======== Polish 3: phone layout = map on top, controls underneath ======== */
.phone .touch { display: flex; flex-direction: column; background: #04050c; }
.phone .mapwrap { position: relative; flex: 1; min-height: 0; }
.phone #status { padding-bottom: 0; }
.phone .controls { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.phone .controls .hint { position: static; flex: 1; text-align: center; font-size: .75rem; opacity: .5; }
.phone .boost { position: relative; right: auto; bottom: auto; width: 108px; height: 108px; font-size: 1rem; opacity: 1; flex: none; }
.phone .dpad { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 5px; flex: none; }
.phone .d { touch-action: none; user-select: none; -webkit-user-select: none; }
.phone .d.hit, .phone .d:active { background: color-mix(in srgb, var(--me) 45%, #0d1336); transform: scale(.94); }
#mute { padding: .35em .6em; font-size: 1rem; }
@media (max-height: 700px) and (orientation: portrait) {
  .phone .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); }
  .phone .boost { width: 90px; height: 90px; }
}
/* sideways: controls float over the map corners so the map gets the full height */
@media (orientation: landscape) and (max-height: 500px) {
  .phone .controls { position: absolute; left: 0; right: 0; bottom: 0; border-top: 0; pointer-events: none; padding: 8px 14px; }
  .phone .controls > * { pointer-events: auto; }
  .phone .controls .hint { display: none; }
  .phone .dpad { opacity: .6; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); }
  .phone .boost { width: 72px; height: 72px; opacity: .85; }
}

/* ======== Host: feed in sidebar, pips, alive counter ======== */
.sidebar .feed { position: static; padding: 8px 12px; gap: 6px; border-top: 1px solid var(--line); min-height: 0; }
.sidebar .feed:empty { display: none; }
.sidebar .feed-item { font-size: .85rem; padding: .3em .6em; }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: .6em; height: .6em; border-radius: 50%; border: 1.5px solid var(--c); opacity: .7; }
.pips i.on { background: var(--c); box-shadow: 0 0 6px var(--c); opacity: 1; }
.round-no { text-align: right; line-height: 1.3; }
.round-no b { color: var(--text); font-size: 1.1rem; }
#subwin { margin-top: -6px; }

/* ---- Lobby waiting animation on phones ---- */
.waiting { display: flex; align-items: flex-end; justify-content: center; gap: 2px; font-size: 1.05rem; color: var(--text); }
.dots { display: inline-flex; gap: 5px; margin-left: 6px; padding-bottom: .3em; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--me); box-shadow: 0 0 8px var(--me);
  animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: .3; } 40% { transform: translateY(-7px); opacity: 1; } }
.riders { display: block; margin-top: .6rem; font-size: .9rem; color: var(--muted); }
body[data-phase="lobby"] #statusBig { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { text-shadow: 0 0 30px var(--me), 0 0 60px var(--me); } }

/* ======== Polish 4: phone screen structure ======== */
/* the map area must stretch to full width (this was collapsing the map) */
.phone .touch { align-items: stretch; justify-content: flex-start; }
body.dead .touch { filter: none; }
.phone #status { padding: 16px; gap: .5rem; }
.phone #statusBig { font-size: clamp(2rem, 9vw, 3rem); line-height: 1.1; }
.phone #statusSmall { max-width: 20em; line-height: 1.4; }

/* lobby: a centered card */
body[data-phase="lobby"] #status { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--me) 12%, transparent), transparent 70%); }
.waiting { flex-wrap: wrap; align-items: baseline; }

/* countdown: barely dim, so you can find your bike on the map */
body[data-phase="countdown"] #status { background: rgba(3,4,12,.2); justify-content: flex-start; padding-top: 10px; }
body[data-phase="countdown"] #statusBig { font-size: 3.2rem; }

/* crashed / round over: small banner at the top, the live map stays fully visible */
body.dead[data-phase="playing"] #status, body[data-phase="roundover"] #status { background: none; justify-content: flex-start; padding-top: 10px; }
body.dead[data-phase="playing"] #statusBig, body[data-phase="roundover"] #statusBig { font-size: 1.5rem; }
body.dead[data-phase="playing"] #statusSmall, body[data-phase="roundover"] #statusSmall {
  background: rgba(5,6,15,.8); border: 1px solid var(--line); border-radius: 999px; padding: .3em .9em; font-size: .85rem; }
body[data-phase="roundover"] #statusSmall:empty { display: none; }

/* controls look switched off until you're riding */
.phone .controls .d, .phone .controls .boost { transition: opacity .25s, filter .25s; }
body:not(.riding) .phone .controls .d, body:not(.riding) .phone .controls .boost,
body.phone:not(.riding) .controls .d, body.phone:not(.riding) .controls .boost { opacity: .3; filter: saturate(.15); }
body.phone[data-phase="countdown"] .controls .d { opacity: .55; }

/* boost recharge shows seconds left */
.phone .boost.cooling { font-size: 2.2rem; font-weight: 900; }

.host-notice { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; background: #1a1030; border: 1px solid var(--accent2);
  color: var(--text); padding: .7em 1.2em; border-radius: 12px; box-shadow: 0 0 30px rgba(255,43,214,.3); font-weight: 600; }

/* ======== Review fixes (mobile) ======== */
/* fallbacks for browsers without color-mix() (iOS < 16.2, older Android Chrome) */
.phone .boost { background: var(--me); }
@supports (background: color-mix(in srgb, red 50%, blue)) {
  .phone .boost { background: radial-gradient(circle, var(--me), color-mix(in srgb, var(--me) 40%, #000)); }
}
.phone .d.hit, .phone .d:active { background: #24306a; }
@supports (background: color-mix(in srgb, red 50%, blue)) {
  .phone .d.hit, .phone .d:active { background: color-mix(in srgb, var(--me) 45%, #0d1336); }
}
.phone .boost.cooling { background: radial-gradient(circle, #2a2f45, #10131f); }
/* only the game screen blocks scrolling; home/join can scroll on short landscape screens */
body.phone { touch-action: auto; }
#pad { touch-action: none; }
#home, #join { justify-content: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#home > :first-child, #join > .logo { margin-top: auto; }
#home > :last-child, #join > form { margin-bottom: auto; }
@media (max-height: 500px) { #join .logo { display: none; } #home .tagline { display: none; } }
/* safe-area already applied by the screen; don't add it twice */
.phone .controls { padding-bottom: 14px; }
.back { left: calc(12px + env(safe-area-inset-left)); }
body.riding .controls .hint { opacity: 0; }

/* ---- Swipe-only controls bar: hint on the left, boost on the right ---- */
.phone .controls .swipe-hint { text-align: left; font-size: .95rem; opacity: .7; display: flex; align-items: center; gap: .6em; }
.swipe-icon { font-size: 1.6rem; display: inline-block; animation: swipehint 2.4s ease-in-out infinite; }
@keyframes swipehint { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(14px, 0); } 50% { transform: translate(0, 0); } 75% { transform: translate(0, -10px); } }
body.riding .controls .swipe-hint { opacity: .35; }
body.riding .swipe-icon { animation: none; }
body.phone:not(.riding) .controls .swipe-hint { filter: none; }

/* ======== miniparty.cc brand ======== */
.logo.brand { letter-spacing: .02em; text-transform: none; font-size: 2.6rem; color: #fff; text-shadow: 0 0 18px rgba(0,240,255,.55); }
.logo.brand span { color: var(--accent2); margin-left: 0; text-shadow: 0 0 14px var(--accent2), 0 0 34px rgba(255,43,214,.5); }
.logo.brand em { font-style: normal; color: var(--accent); text-shadow: 0 0 14px var(--accent); font-size: .7em; }
.logo.brand.big { font-size: clamp(2.6rem, 5vw, 4.6rem); }

/* ======== TV lobby: game picker + ready status ======== */
.section-title { align-self: flex-start; width: 100%; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; font-weight: 700;
  display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.ready-count { text-transform: none; letter-spacing: 0; font-size: 1.05rem; color: var(--text); }
.ready-count b { color: #39ff14; font-size: 1.3rem; }
.games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.game-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px 16px;
  background: #0a0e28; border: 2px solid var(--line); border-radius: 14px; color: var(--text); transition: border-color .2s, box-shadow .2s, transform .15s; }
.game-card:not(:disabled):hover { transform: translateY(-2px); border-color: var(--accent); }
.game-card.on { border-color: var(--accent); box-shadow: 0 0 24px rgba(0,240,255,.35), inset 0 0 20px rgba(0,240,255,.08); }
.game-card.soon { opacity: .4; cursor: default; }
.game-card .gi { font-size: 1.8rem; }
.game-card .gn { font-weight: 800; font-size: 1.15rem; }
.game-card .gb { color: var(--muted); font-size: .85rem; }
.game-card .gsel { position: absolute; top: 10px; right: 12px; font-size: .7rem; font-weight: 800; letter-spacing: .1em; color: #05060f; background: var(--accent); border-radius: 999px; padding: .2em .6em; }

/* READY must be obvious from across the room */
.chip { position: relative; }
.chip .rtag { margin-left: .5em; font-size: .7em; font-weight: 900; letter-spacing: .08em; padding: .15em .5em; border-radius: 999px; }
.chip.ready { background: var(--c); color: #05060f; border-color: var(--c); box-shadow: 0 0 18px var(--c); }
.chip.ready .dot { background: #05060f; box-shadow: none; }
.chip.ready .rtag { background: #05060f; color: #39ff14; }
.chip.notready { background: transparent; border: 2px dashed rgba(180,190,230,.45); color: var(--muted); box-shadow: none; }
.chip.notready .dot { opacity: .5; }
.chip.notready .rtag { color: #ff6b8a; border: 1px solid rgba(255,107,138,.5); }
@media (max-width: 820px) { .games { grid-template-columns: 1fr; } }

/* ======== Phone lobby card: ready + leave ======== */
.gamepill { display: inline-block; margin: .2rem auto .6rem; padding: .35em .9em; border-radius: 999px; border: 1px solid var(--line); background: rgba(10,14,40,.8);
  color: var(--text); font-weight: 700; font-size: .95rem; }
.ready-btn { display: block; margin: .4rem auto; min-width: 220px; font-size: 1.35rem; padding: 1em 1.4em; pointer-events: auto;
  background: #39ff14; color: #05060f; box-shadow: 0 0 26px rgba(57,255,20,.45); animation: readypulse 1.6s ease-in-out infinite; }
@keyframes readypulse { 50% { box-shadow: 0 0 40px rgba(57,255,20,.75); transform: scale(1.03); } }
.ready-badge { display: inline-block; margin: .2rem auto .5rem; padding: .35em 1em; border-radius: 999px; background: #39ff14; color: #05060f; font-weight: 900; letter-spacing: .08em; }
.small-btn { display: block; margin: .6rem auto 0; padding: .45em 1em; font-size: .85rem; pointer-events: auto; }
.leave-btn { color: #ff6b8a; border-color: rgba(255,107,138,.45); }
.phone #statusSmall .riders { margin-top: .5rem; }
.phone #statusSmall { display: flex; flex-direction: column; align-items: center; }
.phone-toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60; background: #1a1030;
  border: 1px solid var(--accent2); border-radius: 12px; padding: .6em 1.1em; font-weight: 700; box-shadow: 0 0 24px rgba(255,43,214,.35); white-space: nowrap; }

.legend { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--muted); display: inline-flex; align-items: center; gap: .45em; }
.legend .lg { width: 1.4em; height: .9em; border-radius: 999px; display: inline-block; margin-left: .8em; }
.legend .lg.in { background: #39ff14; box-shadow: 0 0 8px #39ff14; }
.legend .lg.out { border: 2px dashed rgba(180,190,230,.6); }
.out-badge { display: inline-block; margin: .2rem auto .4rem; padding: .35em 1em; border-radius: 999px; border: 2px dashed rgba(255,107,138,.7); color: #ff6b8a; font-weight: 900; letter-spacing: .08em; }
/* in-game phones get a solid green line under the header, not-in phones a red one */
body.phone.is-in #pad .bar { box-shadow: inset 0 -3px 0 #39ff14; }
body.phone.is-out #pad .bar { box-shadow: inset 0 -3px 0 rgba(255,107,138,.7); }
.inout { font-size: .72rem; font-weight: 900; letter-spacing: .06em; padding: .3em .65em; border-radius: 999px; white-space: nowrap; }
.inout.in { background: #39ff14; color: #05060f; }
.inout.out { border: 1.5px dashed rgba(255,107,138,.8); color: #ff6b8a; }

/* ======== Lobby layout fixes ======== */
button.big.ready-btn { background: #39ff14; color: #05060f; }
/* phone lobby: hide the empty arena behind the card so it reads cleanly */
body.phone[data-phase="lobby"] .map { opacity: 0; }
body.phone[data-phase="lobby"] #statusBig { font-size: clamp(1.8rem, 7.5vw, 2.6rem); }
/* TV lobby: compact so everything fits on a 16:9 screen */
.host #lobby .lobby-card { gap: clamp(8px, 1.1vh, 18px); padding: clamp(14px, 2.2vh, 32px) clamp(18px, 3vw, 44px); max-height: calc(100vh - 32px); overflow-y: auto; }
.host #lobby .logo.brand.big { font-size: clamp(2.2rem, 6vh, 4rem); }
.host #lobby #qr { width: clamp(110px, 17vh, 220px); }
.host #lobby .code { font-size: clamp(2.8rem, 11vh, 7.5rem); }
.host #lobby .url { font-size: clamp(1.2rem, 3.4vh, 2.4rem); }
.host #lobby .label { font-size: clamp(.9rem, 2vh, 1.3rem); }
.host #lobby .game-card { padding: clamp(8px, 1.4vh, 14px) 16px; }
.host #lobby .game-card .gi { font-size: clamp(1.3rem, 3vh, 1.8rem); }
.host #lobby .small-note { font-size: .85rem !important; }
.host .overlay { overflow-y: auto; }

/* ======== Ring countdown timer ======== */
.ring-timer { --rt: var(--accent); --size: 220px; position: relative; width: var(--size); height: var(--size); }
.ring-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.rt-bg { fill: rgba(5,6,15,.72); stroke: rgba(255,255,255,.1); stroke-width: 9; }
.rt-fg { fill: none; stroke: var(--rt); stroke-width: 9; stroke-linecap: round; filter: drop-shadow(0 0 8px var(--rt)); }
.rt-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.rt-num { font-size: calc(var(--size) * .38); font-weight: 900; line-height: 1; color: #fff; text-shadow: 0 0 18px var(--rt); }
.rt-lbl { font-size: calc(var(--size) * .075); font-weight: 800; letter-spacing: .16em; color: var(--muted); }
.ring-timer.tick .rt-num { animation: rtpop .35s ease-out; }
@keyframes rtpop { from { transform: scale(1.35); opacity: .4; } }
.ring-timer.urgent { --rt: #ffe600; }
.ring-timer.go { --rt: #39ff14; }
.ring-timer.go .rt-num { font-size: calc(var(--size) * .3); color: #39ff14; }
.ring-timer.paused { --rt: rgba(180,190,230,.4); }
.ring-timer.paused .rt-lbl { font-size: calc(var(--size) * .1); color: var(--text); }

/* TV: pre-round countdown in the middle of the arena */
.host .countdown { font-size: inherit; text-shadow: none; }
.host .cd-ring .ring-timer { --size: min(42vh, 380px); }
/* TV: next-round ring on the results card */
.auto-ring .ring-timer { --size: clamp(120px, 20vh, 190px); }
.auto-ring.hidden { display: none; }

/* Phone: ring sits in the middle of the map area */
.ptimer { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; pointer-events: none; }
.ptimer .ring-timer { --size: min(52vw, 230px); }
.ptimer.hidden { display: none; }
/* round over on the phone: banner at the top, ring lower so they don't overlap */
body.timing-next .ptimer { top: 62%; }
body.timing-next .ptimer .ring-timer { --size: min(40vw, 170px); }

/* phone ring lives in the empty space under the map so it never hides your bike */
.ptimer { top: auto; bottom: 12px; transform: translateX(-50%); }
.ptimer .ring-timer, body.timing-next .ptimer .ring-timer { --size: min(38vw, 160px); }
body.timing-next .ptimer { top: auto; }
.ptimer .rt-bg { fill: rgba(5,6,15,.85); }
@media (orientation: landscape) and (max-height: 500px) {
  .ptimer { left: auto; right: 12px; bottom: auto; top: 50%; transform: translateY(-50%); }
  .ptimer .ring-timer, body.timing-next .ptimer .ring-timer { --size: 110px; }
}
/* TV results title on one centred line */
.winner { flex-wrap: wrap; justify-content: center; text-align: center; }
