:root {
  --green: #0D3D2B; --green2: #145236; --green3: #1F6B47;
  --sun: #FCBF16; --salmon: #F49E6E; --salmon2: #C9612F;
  --cream: #FFF8EC; --paper: #FFFFFF; --ink: #10241B; --muted: #4E6158; --line: #E8DFCF;
  --l1: #F49E6E; --l2: #F8A951; --l3: #3E9B6B; --l4: #FCBF16;
  --r: 14px;
  --head: 'Archivo Black', 'Arial Black', sans-serif;
  --body: Montserrat, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--cream); font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--green3); }
h1, h2, h3 { font-family: var(--head); font-weight: 400; margin: 0; letter-spacing: .3px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.top { background: var(--green); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.top-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.logo-full { height: 54px; width: auto; display: block; }
.session { font-size: 12px; color: #CFE3D8; font-weight: 600; line-height: 1.3; }
.nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; padding: 9px 14px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center; }
.nav a:hover { background: rgba(255,255,255,.1); }
.nav a.on { background: var(--sun); color: var(--green); }
.mode { background: var(--salmon); color: var(--green); font-size: 12px; font-weight: 800; text-align: center; padding: 6px 10px; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 40px; }
.section { margin-top: 22px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-head h2 { font-size: 20px; color: var(--green); }
.sec-head .sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.card { background: var(--paper); border-radius: var(--r); border: 1px solid var(--line); padding: 14px; }
.grid { display: grid; gap: 12px; }
.courts { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.queues { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Level chips */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.chip.l1 { background: var(--l1); color: #3A1A08; }
.chip.l2 { background: var(--l2); color: #3A2205; }
.chip.l3 { background: var(--l3); color: #fff; }
.chip.l4 { background: var(--l4); color: var(--green); }
.chip.ghost { background: #F1EBDF; color: var(--muted); }

/* Court card */
.court { position: relative; overflow: hidden; }
.court::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 5px; background: var(--line); }
.court.l1::before { background: var(--l1); } .court.l2::before { background: var(--l2); }
.court.l3::before { background: var(--l3); } .court.l4::before { background: var(--l4); }
.court-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; white-space: nowrap; }
.court-no { font-family: var(--head); font-size: 22px; color: var(--green); }
.court-no small { font-family: var(--body); font-weight: 700; font-size: 11px; color: var(--muted); letter-spacing: .5px; display: block; line-height: 1; }
.time { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted); }
.teams { display: grid; gap: 6px; }
.team { background: #F7F2E8; border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.team .names { flex: 1; }
.vs { text-align: center; font-family: var(--head); font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.idle { color: var(--muted); font-weight: 600; padding: 18px 0; text-align: center; }
.court.off { opacity: .55; }
.hl { background: #FFF1C2 !important; outline: 2px solid var(--sun); }

/* Queues */
.queue h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--green); }
.queue h3 .count { margin-left: auto; white-space: nowrap; font-family: var(--body); font-weight: 800; font-size: 12px; color: var(--muted); }
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-top: 1px solid #F1EBDF; font-weight: 600; }
.qlist li:first-child { border-top: 0; }
.qlist .pos { width: 22px; height: 22px; border-radius: 50%; background: #F1EBDF; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.qlist li.next .pos { background: var(--green); color: #fff; }
.qlist .w { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.qlist .w.long { color: #A33B10; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 4px; }

/* Find me */
.find { display: flex; gap: 8px; }
.find input { flex: 1; }
.me { margin-top: 10px; display: grid; gap: 8px; }
.me .card { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.me .big { font-family: var(--head); font-size: 18px; color: var(--green); }

input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], select {
  border: 1.5px solid #D9CFBD; border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--sun); outline-offset: 1px; }
label { font-weight: 700; font-size: 13px; color: var(--muted); }

/* Buttons */
.btn { border: 0; border-radius: 10px; padding: 10px 16px; min-height: 44px; font-weight: 800; cursor: pointer; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--green3); }
.btn.sun { background: var(--sun); color: var(--green); } .btn.sun:hover { background: #FFD24D; }
.btn.light { background: #F1EBDF; color: var(--ink); } .btn.light:hover { background: #E8DFCF; }
.btn.warn { background: #FBE3D6; color: #8A2E07; } .btn.warn:hover { background: #F7CDB7; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.win { min-width: 96px; }

/* Streaks + champions */
.streaks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.streak { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.dots { display: flex; gap: 4px; margin-left: auto; flex: none; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #EDE5D6; border: 2px solid #E0D5C1; }
.dot.on { background: var(--sun); border-color: #D99E00; }
.champs { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.champ { background: var(--green); color: #fff; border-radius: 18px; overflow: hidden; border: 3px solid var(--sun); }
.champ .ph { aspect-ratio: 1 / 1; background: var(--green2); display: flex; align-items: center; justify-content: center; }
.champ .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.champ .ini { font-family: var(--head); font-size: 64px; color: var(--sun); }
.champ .info { padding: 10px 12px 14px; }
.champ .nm { font-family: var(--head); font-size: 18px; }
.champ .lb { color: var(--sun); font-weight: 800; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; }
.slot { border: 2px dashed #D9CFBD; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 200px; color: var(--muted); font-weight: 700; text-align: center; padding: 16px; gap: 6px; }
.slot b { font-family: var(--head); font-weight: 400; font-size: 26px; color: #CBBFA8; }
.prize { background: var(--green); color: #fff; border-radius: var(--r); padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.prize .logo-icon { width: 56px; height: 56px; flex: none; }
.prize strong { color: var(--sun); }

/* Tables */
.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; min-width: 560px; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid #F1EBDF; white-space: nowrap; }
th { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); background: #FBF7EF; border-top: 0; }
td.num, th.num { text-align: center; }
tr.top3 td:first-child { font-family: var(--head); color: var(--green); }

/* Control */
.checkin { background: var(--green); border-radius: var(--r); padding: 14px; color: #fff; }
.checkin h2 { color: var(--sun); font-size: 18px; margin-bottom: 8px; }
.checkin form { display: flex; gap: 8px; flex-wrap: wrap; }
.checkin input[type=text] { flex: 1 1 220px; font-size: 17px; color: var(--ink); }
.checkin select { color: var(--ink); }
.checkin select { flex: 0 0 auto; }
.checkin .hint { color: #CFE3D8; font-size: 12px; margin-top: 8px; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin: 16px 0 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: #F1EBDF; border-radius: 999px; padding: 9px 16px; font-weight: 800; cursor: pointer; min-height: 42px; }
.tabs button.on { background: var(--green); color: #fff; }
.tabs .badge { background: var(--salmon); color: var(--green); border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.ctl-team { display: grid; grid-template-columns: minmax(0, 1fr) 58px 84px; gap: 6px; align-items: center; }
.ctl-team .win { min-width: 0; padding: 10px 8px; }
.courts.ctl { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.score { width: 64px; text-align: center; }
.swap { background: none; border: 0; color: var(--salmon2); font-weight: 800; font-size: 12px; cursor: pointer; padding: 4px 6px; min-height: 32px; text-decoration: underline; }
.court-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.res { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.res .t { font-weight: 800; color: var(--muted); font-size: 12px; text-align: center; min-width: 54px; }
.res .w { color: var(--green); font-weight: 800; }
.res .l { color: var(--muted); }
.res-list { display: grid; gap: 8px; }
.res.void { opacity: .5; text-decoration: line-through; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; color: var(--ink); font-size: 14px; }
.check input { width: 22px; height: 22px; margin-top: 1px; }
.court-map { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.login { max-width: 420px; margin: 30px auto; }
.login form { display: grid; gap: 10px; }
.warnbox { background: #FBE3D6; color: #6E2405; border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 13px; }

/* Toast + celebration */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(140%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: min(92vw, 560px); z-index: 60; transition: transform .25s ease; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: #8A2E07; }
#celebrate { position: fixed; inset: 0; z-index: 80; background: rgba(8, 36, 25, .92); display: flex; align-items: center; justify-content: center; padding: 20px; cursor: pointer; overflow: hidden; }
#celebrate[hidden] { display: none; }
.cel-box { text-align: center; color: #fff; position: relative; z-index: 2; max-width: 640px; }
.cel-box .logo-icon { width: 120px; height: 120px; }
.cel-box .kick { color: var(--sun); font-family: var(--head); letter-spacing: 4px; font-size: clamp(16px, 3vw, 24px); margin-top: 14px; }
.cel-box .nm { font-family: var(--head); font-size: clamp(40px, 9vw, 96px); line-height: 1; margin: 10px 0; }
.cel-box .ph { width: min(60vw, 320px); aspect-ratio: 1/1; border-radius: 24px; overflow: hidden; border: 5px solid var(--sun); margin: 16px auto 0; }
.cel-box .ph img { width: 100%; height: 100%; object-fit: cover; }
.conf { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; z-index: 1; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { .conf { display: none; } #toast { transition: none; } }

/* Footer */
.foot { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.foot img { width: 52px; height: 52px; }

/* TV */
body.tv { background: var(--green); color: #fff; }
body.tv .top, body.tv .foot, body.tv .mode { display: none; }
body.tv main { max-width: none; padding: 0; }
.tvwrap { padding: 1.4vw; display: grid; gap: 1.2vw; grid-template-columns: 2.1fr 1fr; min-height: 100vh; }
.tvhead { grid-column: 1 / -1; display: flex; align-items: center; gap: 2vw; }
.tvhead .logo-full { height: 6vw; min-height: 50px; }
.tvhead .clock { margin-left: auto; font-family: var(--head); font-size: 3vw; color: var(--sun); }
.tvhead .msg { font-weight: 700; font-size: 1.3vw; color: #CFE3D8; }
.tv .courts { grid-template-columns: repeat(4, 1fr); gap: 1vw; }
.tv .card { background: #10492F; border-color: #1C5E3E; color: #fff; padding: .8vw; }
.tv .court-no { color: #fff; font-size: 2vw; }
.tv .court-no small, .tv .time, .tv .muted, .tv .idle, .tv .vs { color: #A9C8B8; }
.tv .team { background: #0B3624; font-size: 1vw; min-height: 0; padding: .6vw .8vw; }
.tv .chip { font-size: .66vw; padding: .2vw .5vw; letter-spacing: .3px; }
.tv .time { font-size: .72vw; flex: none; }
.tv .court-head { gap: .4vw; }
.tv .sec-head h2 { color: var(--sun); font-size: 1.6vw; }
.tv .sec-head .sub { color: #A9C8B8; font-size: 1vw; }
.tv .queues { grid-template-columns: repeat(4, 1fr); gap: 1vw; }
.tv .queue h3 { color: #fff; font-size: 1.2vw; }
.tv .qlist li { border-color: #1C5E3E; font-size: 1.05vw; padding: .35vw .2vw; }
.tv .qlist .pos { background: #1C5E3E; color: #fff; width: 1.6vw; height: 1.6vw; font-size: .8vw; }
.tv .qlist li.next .pos { background: var(--sun); color: var(--green); }
.tv .qlist .w { color: #A9C8B8; font-size: .9vw; }
.tv .empty { color: #A9C8B8; font-size: 1vw; }
.tv .champs { grid-template-columns: repeat(2, 1fr); gap: 1vw; }
.tv .champ .nm { font-size: 1.3vw; }
.tv .champ .lb { font-size: .75vw; }
.tv .slot { min-height: 8vw; border-color: #2B6E4D; color: #A9C8B8; font-size: 1vw; }
.tv .streak { font-size: 1.1vw; }
.tv .streaks { grid-template-columns: 1fr; }
.tv .dot { width: 1vw; height: 1vw; background: #0B3624; border-color: #2B6E4D; }
.tv .dot.on { background: var(--sun); border-color: var(--sun); }

@media (max-width: 640px) {
  .top { position: static; padding: 8px 12px 6px; }
  .logo-full { height: 40px; }
  .top-in { gap: 6px 12px; }
  .nav { margin-left: -6px; width: calc(100% + 12px); flex-wrap: nowrap; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav a { padding: 6px 12px; font-size: 13px; min-height: 36px; flex: none; }
  .courts.ctl { grid-template-columns: 1fr; }
  .prize .logo-icon { width: 44px; height: 44px; }
  .prize { font-size: 14px; }
  main { padding: 14px 12px 30px; }
  .win { min-width: 76px; }
}
