  :root {
    --bg: #14091f;
    --card: #221338;
    --card2: #2d1b4a;
    --text: #f4ecff;
    --muted: #a995c4;
    --accent: #ff8a1f;
    --accent-ink: #1a0b00;
    --good: #5be28a;
    --bad: #ff5c7a;
    --gold: #ffd54a;
    --silver: #cfd8e3;
    --bronze: #e0955a;
    --radius: 16px;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
  body { padding: calc(env(safe-area-inset-top) + 24px) 16px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
  h1 { font-size: 20px; margin: 16px 0 4px; }
  h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
  .sub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
  .card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
  label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  input, select, button { font: inherit; color: inherit; }
  input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%; background: var(--card2); border: 2px solid transparent; border-radius: 12px;
    padding: 12px; min-height: 48px; outline: none; }
  input:focus, select:focus, textarea:focus { border-color: var(--accent); }
  button { border: 0; border-radius: 12px; min-height: 48px; padding: 0 16px; background: var(--card2); cursor: pointer; font-weight: 600; }
  button.primary { background: var(--accent); color: var(--accent-ink); }
  button.danger { background: transparent; color: var(--bad); }
  button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
  button:active { transform: scale(.97); }
  .row { display: flex; gap: 10px; align-items: flex-end; }
  .row > * { flex: 1; }
  .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .iv input { text-align: center; font-size: 28px; font-weight: 700; padding: 8px; min-height: 64px; }
  .toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--card2); border-radius: 12px; padding: 12px 14px; min-height: 56px; margin: 12px 0; cursor: pointer; user-select: none; }
  .toggle.on { background: #4a2a07; outline: 2px solid var(--accent); }
  .switch { width: 48px; height: 28px; border-radius: 14px; background: #5b4a73; position: relative; transition: .15s; flex: none; }
  .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; }
  .toggle.on .switch { background: var(--accent); }
  .toggle.on .switch::after { left: 23px; }
  .preview { text-align: center; font-size: 15px; color: var(--muted); margin: 8px 0 12px; }
  .preview b { color: var(--accent); font-size: 32px; display: block; }
  .rank { display: flex; align-items: center; gap: 12px; }
  .pos { width: 36px; height: 36px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-weight: 800; flex: none; }
  .p1 .pos { background: var(--gold); color: #3a2c00; }
  .p2 .pos { background: var(--silver); color: #222; }
  .p3 .pos { background: var(--bronze); color: #2a1300; }
  .rank .who { flex: 1; min-width: 0; }
  .rank .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rank .meta { font-size: 12px; color: var(--muted); }
  .rank .pts { font-size: 26px; font-weight: 800; color: var(--accent); }
  .entries { margin-top: 10px; border-top: 1px solid var(--card2); padding-top: 8px; }
  .entry { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 14px; }
  .tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--card2); color: var(--muted); }
  .tag.cos { background: #4a2a07; color: var(--accent); }
  .banner { background: #3a1d5a; border: 2px dashed var(--accent); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; font-size: 14px; }
  .banner button { margin-top: 8px; width: 100%; }
  .empty { text-align: center; color: var(--muted); padding: 28px 0; }
  .prize { display: flex; gap: 10px; margin-bottom: 10px; }
  .prize .medal { font-size: 28px; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; background: #0e0616; border-top: 1px solid var(--card2);
    display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
  nav button { flex: 1 1 0; min-width: 0; padding: 0 2px; background: none; border-radius: 0; min-height: 64px; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
  nav button span { font-size: 22px; }
  nav button.active { color: var(--accent); }
  .toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
    background: var(--good); color: #052b12; padding: 10px 18px; border-radius: 24px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
  .toast.show { opacity: 1; transform: translateX(-50%); }
  .view { display: none; } .view.active { display: block; }
  ul.rules { padding-left: 18px; margin: 6px 0; } ul.rules li { margin: 4px 0; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); vertical-align: middle; margin-left: 6px; }
.dot.on { background: var(--good); }
.toast.bad { background: var(--bad); color: #fff; }
[hidden] { display: none !important; }
#login { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 20; align-items: center; justify-content: center; padding: 16px; }
#login.show { display: flex; }
#login form { width: 100%; max-width: 360px; }
.err { color: var(--bad); min-height: 1.4em; margin: 8px 0; font-size: 14px; }

/* utilities (the CSP forbids inline style attributes) */
.w100 { width: 100%; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.pt0 { padding-top: 0; }
button.big { min-height: 56px; font-size: 18px; }

/* rows with a label and action buttons: buttons never wrap, long names do */
.entry > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.entry > span:last-child { flex: none; white-space: nowrap; }
.entry button.small { min-width: 40px; }

.logrow { padding: 10px 14px; font-size: 14px; overflow-wrap: anywhere; }
.logrow.warn { border-left: 4px solid var(--bad); }
.logmeta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
nav button { font-size: 11px; }
nav button span { font-size: 20px; }
.meta { font-size: 12px; color: var(--muted); }
/* a card that is also a row keeps the card padding (.entry alone would zero the sides) */
.card.entry { padding: 12px 14px; }
.mb10 { margin-bottom: 10px; }
input:disabled, button:disabled { opacity: .5; }
.pairline { padding: 5px 0; overflow-wrap: anywhere; font-size: 14px; }

.ivrow { margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button { min-height: 56px; font-size: 22px; font-weight: 800; padding: 0; }
.seg button.sel { background: var(--accent); color: var(--accent-ink); }
button.link { background: none; color: var(--muted); min-height: 40px; padding: 0; font-weight: 500; text-decoration: underline; }
/* label on the left of its four buttons: keeps Guardar reachable without scrolling */
.ivrow { display: grid; grid-template-columns: 68px 1fr; align-items: center; gap: 8px; }
.ivrow label { margin: 0; color: var(--text); font-weight: 600; }
.seg button { min-height: 52px; }
.preview { margin: 4px 0 10px; } .preview b { font-size: 28px; line-height: 1.2; }
#f-player { margin-top: 10px; }

input[type=date] { appearance: none; -webkit-appearance: none; text-align: left; }
.card.arch { cursor: pointer; }

textarea { font: inherit; color: inherit; resize: vertical; line-height: 1.4; }
.rulestext p { margin: 6px 0; }

.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-weight: 800; line-height: 1.1; }
.brand img { width: 48px; height: 48px; flex: none; }
.brand small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.loginlogo { display: block; width: 120px; height: 120px; margin: 0 auto 8px; }
#login form { text-align: left; }
