:root {
  color-scheme: dark;
  --deep: #160d28;
  --panel: #251440;
  --panel-light: #32204f;
  --line: #51406c;
  --ink: #fff8ed;
  --muted: #d2c5e3;
  --gold: #ffd644;
  --green: #abeb8a;
  font-family: "Trebuchet MS", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--deep); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: wait; opacity: .56; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
a { color: var(--gold); }
.home {
  min-height: 100svh;
  padding: 0 clamp(18px, 4.8vw, 76px);
  background: radial-gradient(ellipse at 92% 16%, #422258 0%, transparent 44%), radial-gradient(ellipse at 10% 75%, #261940, transparent 65%), var(--deep);
}
.site-frame { max-width: 1320px; margin: auto; }
.topbar { height: 83px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #584569; }
.wordmark { display: flex; align-items: center; gap: 10px; line-height: 1; letter-spacing: .045em; }
a.wordmark { color: inherit; text-decoration: none; }
.wordmark img { border-radius: 12px; }
.wordmark strong { display: block; font-weight: 900; font-size: 16px; }
.wordmark small { display: block; margin-top: 5px; color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.local-tag { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; letter-spacing: .12em; font-size: 10px; border: 1px solid #584569; padding: 9px 13px; border-radius: 40px; white-space: nowrap; }
.local-tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.local-tag:has([data-online="true"]) i { background: var(--green); }
.icon-button { border: 1px solid #604b77; background: #ffffff0c; display: grid; place-items: center; font-size: 23px; line-height: 1; border-radius: 13px; width: 44px; height: 44px; }
.icon-button:hover { background: #ffffff26; }
.hero { display: grid; grid-template-columns: minmax(310px,.72fr) minmax(0,1.25fr); align-items: center; gap: clamp(24px, 3.4vw, 62px); padding: clamp(27px, 5vw, 71px) 0 clamp(25px, 3.7vw, 49px); }
.eyebrow { font-weight: 900; font-size: 11px; letter-spacing: .18em; color: #e3cbfa; display: inline-flex; align-items: center; gap: 9px; }
.eyebrow > span { width: 18px; height: 2px; background: var(--gold); display: inline-block; border-radius: 2px; }
h1 { font-family: "Arial Black", "Trebuchet MS", sans-serif; font-weight: 1000; font-size: clamp(48px, 5.6vw, 95px); letter-spacing: -.079em; line-height: .9; margin: 18px 0 12px; }
h1 em { color: var(--gold); display: block; font-size: 1.26em; font-style: normal; text-shadow: 0 5px #a95e2c, 0 9px #36204e; }
h1 em span { color: #b47af0; text-shadow: 0 5px #633794; }
.byline { font-weight: 800; font-size: clamp(15px, 1.75vw, 25px); margin: 19px 0 12px; }
.intro { color: var(--muted); max-width: 34ch; font-size: clamp(14px, 1.32vw, 18px); margin: 0 0 23px; line-height: 1.5; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 47px; border-radius: 12px; padding: 9px 15px; font-weight: 900; text-decoration: none; }
.primary { background: var(--gold); color: #2d1849; border: 1px solid #ffe481; box-shadow: 0 4px #a9672c; }
.primary:hover { background: #ffe586; transform: translateY(-1px); }
.primary:active { box-shadow: 0 1px #a9672c; transform: translateY(3px); }
.secondary { border: 1px solid #725c90; background: #412b61; }
.secondary:hover { background: #54397a; }
.home-play { min-height: 60px; display: flex; width: min(100%, 293px); gap: 14px; font-size: 19px; padding-inline: 19px; }
.home-play span:first-child { font-size: 16px; }
.home-play span:last-child { margin-left: auto; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1px 20px; margin-top: 13px; }
.hero-actions button, .footer button { background: none; border: 0; padding: 0; min-height: 44px; font-weight: 800; }
.hero-actions button { text-decoration: underline; text-decoration-color: #aa79d5; text-underline-offset: 5px; }
.hero-actions button:hover, .footer button:hover { color: var(--gold); }
.hero-art { align-self: center; margin: 0; border: 1px solid #9775c0; border-radius: 23px; padding: 6px; background: #7842a1; box-shadow: 0 18px 50px #0b061773; overflow: hidden; }
.hero-art img { display: block; width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 17px; }
.info-row { display: grid; grid-template-columns: .74fr 1fr 1.3fr; border-block: 1px solid #574268; background: #29194186; }
.info-cell { min-height: 79px; padding: 12px clamp(12px, 2vw, 30px); display: flex; align-items: center; gap: 13px; }
.info-cell + .info-cell { border-left: 1px solid #574268; }
.info-symbol { display: grid; place-items: center; font-size: 19px; flex: 0 0 36px; height: 36px; border-radius: 10px; color: var(--gold); background: #4b2b69; }
.micro { display: block; color: #c7aedc; font-size: 9px; font-weight: 800; letter-spacing: .13em; margin-bottom: 4px; }
.info-cell strong { font-size: clamp(13px, 1.35vw, 17px); }
.footer { min-height: 55px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #cbb8dd; font-size: 12px; }

.race { position: fixed; inset: 0; touch-action: none; overflow: hidden; background: #94d0f5; user-select: none; }
#world { display: block; width: 100%; height: 100%; outline: none; }
.hud, .race-status { position: absolute; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 7px; align-items: flex-start; pointer-events: none; }
.hud { top: max(12px, env(safe-area-inset-top)); justify-content: space-between; }
.hud-stats { display: flex; gap: 6px; }
.hud-box { color: white; background: #281044eb; box-shadow: 0 3px 8px #24113e40; border: 1px solid #d7b8ffa0; border-radius: 12px; padding: 8px 11px; }
.hud-box small { display: block; font-weight: 900; color: #e4d0f7; font-size: 9px; letter-spacing: .09em; }
.hud-box strong { display: block; font-weight: 900; font-variant-numeric: tabular-nums; margin-top: 2px; font-size: 17px; }
.hud-box.points { min-width: 100px; }
.hud-box.points strong { color: var(--gold); font-size: 28px; line-height: 1.04; }
.hud-box.points span { display: block; margin-top: 5px; font-size: 11px; color: #e4d0f7; }
.pause { pointer-events: auto; color: var(--gold); font-weight: 900; }
.race-status { top: calc(max(12px, env(safe-area-inset-top)) + 86px); }
/* En partidas oficiales el marcador lleva el nombre y es más alto. */
.race:has(.hud-name:not([hidden])) .race-status { top: calc(max(12px, env(safe-area-inset-top)) + 105px); }
.lives { color: #ff7d9a; font-size: 18px; letter-spacing: 2px; white-space: nowrap; }
.lives span { color: #af95c4; }
.powers { color: #ffe987; font-size: 13px; }
.biome { position: absolute; left: 50%; top: max(85px, calc(env(safe-area-inset-top) + 76px)); transform: translateX(-50%); border-radius: 24px; background: #261040e8; color: #fff8df; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; padding: 10px 17px; border: 1px solid #f7d879; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .25s; }
.biome.show { opacity: 1; }
.tip { pointer-events: none; position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); background: #260f40ed; padding: 9px 13px; border-radius: 20px; text-align: center; white-space: nowrap; color: #fff1d5; font-size: 12px; }
.touch-controls { display: none; position: absolute; inset: auto max(14px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); justify-content: space-between; pointer-events: none; }
.touch-controls div { display: flex; gap: 7px; }
.touch-controls button { pointer-events: auto; background: #2c1745c9; border: 1px solid #eddaff; box-shadow: 0 3px #170c2b80; border-radius: 13px; width: 49px; height: 49px; font-size: 22px; font-weight: 900; }

dialog { width: min(92vw, 545px); max-height: 90dvh; overflow: auto; padding: clamp(19px, 5vw, 29px); color: var(--ink); background: linear-gradient(153deg,#362052,#20122f); border: 1px solid #936ebc; border-radius: 22px; box-shadow: 0 15px 65px #120821bb; }
dialog::backdrop { background: #120b23b5; }
dialog.race-result::backdrop { background: #170c2d58; }
dialog.race-result { margin-top: max(20px, env(safe-area-inset-top)); }
@media (min-width: 860px) {
  dialog.race-result { margin: auto 4vw auto auto; width: min(44vw, 445px); }
}
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
dialog h2 { margin: 8px 0 13px; font-size: clamp(24px, 6vw, 37px); line-height: 1.05; letter-spacing: -.034em; }
dialog p, dialog ul { color: var(--muted); line-height: 1.55; }
dialog li { margin-bottom: 5px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 15px 0 4px; }
.instructions, .options { display: grid; gap: 8px; }
.instructions > div, .options label { padding: 9px; border-radius: 11px; border: 1px solid #624880; display: flex; align-items: center; gap: 11px; }
.instructions b { border-radius: 8px; background: #4a2d6c; color: var(--gold); min-width: 52px; padding: 9px 4px; text-align: center; }
.instructions strong, .instructions small { display: block; }
.instructions small { margin-top: 4px; color: var(--muted); line-height: 1.35; }
.options label { justify-content: space-between; min-height: 50px; }
.options input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--gold); }
.options select, #nickname { min-height: 43px; padding: 7px 10px; border-radius: 8px; border: 1px solid #9275b6; background: #221338; color: white; }
#nickname { width: min(100%, 300px); }
.alert { border-radius: 10px; padding: 9px 11px; background: #7c1f46; color: #fff2ee; font-size: 14px; margin-top: 11px; }
.result-points { color: var(--gold); font-size: clamp(42px, 13vw, 76px); font-weight: 1000; line-height: 1; margin: 14px 0; letter-spacing: -.06em; }
.result-points span { font-size: .34em; letter-spacing: 0; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.result-grid div { background: #ffffff11; border-radius: 9px; padding: 10px; }
.result-grid small, .result-grid b { display: block; }
.result-grid small { color: #d4c2ec; margin-bottom: 4px; }
.new-best { font-weight: 900; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.rank-list { list-style: none; margin: 12px 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 2em 1fr max-content; gap: 10px; padding: 7px 9px; border-bottom: 1px solid #694c88; overflow-wrap: anywhere; }
.rank-list b { color: var(--gold); }
.countdown { font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.status-message { min-height: 1.4em; }

/* ===== Logos de la campaña ===== */
.brand-logos { gap: 14px; }
.brand-logos img { border-radius: 0; width: auto; display: block; }
.brand-logos .logo-dco { height: 62px; }
.brand-logos .logo-madeline { height: 38px; }

/* ===== Concurso ===== */
.contest-banner { display: grid; gap: 3px; margin: 2px 0 16px; padding: 12px 15px; border: 1px solid #ffd64466; border-radius: 14px; background: linear-gradient(135deg, #ffd6441f, #ffd64408); max-width: 420px; }
.contest-banner strong { font-size: 18px; color: #fff; }
.contest-banner small { color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; font-weight: 800; cursor: pointer; }
.register-form { display: grid; gap: 11px; margin-top: 10px; }
.form-field { display: grid; gap: 5px; font-weight: 800; }
.form-field input { min-height: 46px; padding: 8px 12px; border-radius: 10px; border: 1px solid #9275b6; background: #221338; color: white; font-size: 16px; color-scheme: dark; }
.form-field input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.form-field input[aria-invalid="true"] { border-color: #ff7a9c; box-shadow: 0 0 0 2px #ff7a9c55; }
.form-field small { color: var(--muted); font-weight: 400; }
.form-check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; color: var(--muted); line-height: 1.45; }
.form-check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--gold); }
.form-check[hidden] { display: none; }
/* Nombre del participante en el marcador: aparece cuando se desvanece el de la cabeza. */
.hud-name { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 13px; font-weight: 900; line-height: 1.2; margin-bottom: 3px; opacity: 0; transform: translateY(6px); transition: opacity .45s ease, transform .45s ease; }
.hud-name.show { opacity: 1; transform: none; }
/* Nombre en el panel de fin de partida. */
dialog .result-player { display: inline-block; margin: -4px 0 8px; padding: 4px 12px; border: 1px solid var(--gold); border-radius: 30px; background: #ffd64414; color: #fff; font-weight: 900; font-size: 17px; line-height: 1.3; }
.rank-list li.winner { background: #ffd64414; }
.rank-list li.winner span::after { content: " 🏆"; }
@media (max-width: 770px) {
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .hero-copy { display: grid; grid-template-columns: 1fr; justify-items: start; }
  h1 em { display: inline; font-size: 1em; }
  .hero-art { width: 100%; max-width: 640px; }
  .info-row { grid-template-columns: 1fr 1fr; }
  .info-cell:last-child { grid-column: span 2; border-left: 0; border-top: 1px solid #574268; }
}
@media (max-width: 520px) {
  .brand-logos { gap: 9px; }
  .brand-logos .logo-dco { height: 48px; }
  .brand-logos .logo-madeline { height: 28px; }
  .local-tag { padding: 8px 10px; letter-spacing: .06em; }
}
@media (max-width: 400px) {
  .brand-logos .logo-dco { height: 42px; }
  .brand-logos .logo-madeline { height: 23px; }
  h1 { font-size: clamp(38px, 12vw, 48px); }
  .hud-box { padding: 6px 7px; }
  .hud-box.points { min-width: 75px; }
  .hud-box small { font-size: 8px; }
  .hud-box strong { font-size: 14px; }
  .hud-box.points strong { font-size: 23px; }
  .hud-stats, .hud { gap: 3px; }
  .pause { width: 41px; }
}
@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .tip { bottom: max(78px, calc(env(safe-area-inset-bottom) + 65px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
