/* Look and feel recreated from last year's Viking Games site:
   mint gradient background, white rounded panels, emerald outlines and buttons, Dosis type.
   Calculator inputs keep their colour coding (blue, green, yellow, purple). */

:root {
  --ink: #1e2a38;
  --muted: #5d6b7b;
  --line: #34d399;
  --line-soft: #cfe9dd;
  --mint-1: #e9fbf2;
  --mint-2: #f4fdf8;
  --green: #10b981;
  --green-dark: #059669;
  --green-tint: #e8f7f1;
  --surface: #ffffff;
  --focus: #0b63c5;
  --bad: #b3261e;
  --warn-bg: #fff1c9;
  --radius: 14px;
  --display: 'Dosis', 'Trebuchet MS', 'Segoe UI', system-ui, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--display); font-size: 19px; line-height: 1.4; font-weight: 500;
  background: linear-gradient(135deg, var(--mint-1) 0%, var(--mint-2) 55%, var(--mint-1) 100%) fixed;
  min-height: 100vh;
}
h1, h2, h3 { font-weight: 700; line-height: 1.1; margin: 0 0 .6rem; }
h1 { font-size: 2.6rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 .8rem; }
a { color: var(--green-dark); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- top strip ---------- */
#header { position: sticky; top: 0; z-index: 20; background: rgba(244, 253, 248, .92); backdrop-filter: blur(4px); border-bottom: 1px solid var(--line-soft); }
.bar { max-width: 1100px; margin: 0 auto; padding: .35rem 1rem; display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; min-height: 48px; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--green-dark); text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; }
.brand svg { width: 28px; height: 28px; }
.status { margin-left: auto; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .95rem; }
.who { display: inline-flex; gap: .6rem; align-items: center; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--green-dark); text-decoration: underline; font: inherit; font-weight: 600; cursor: pointer; padding: .3rem; min-height: 40px; }
.pill { display: inline-block; padding: .1rem .7rem; border-radius: 99px; font-size: .9rem; font-weight: 700; }
.pill-demo { background: var(--warn-bg); color: #6b4b00; }
.pill-sync.is-synced { background: #d9f5e8; color: var(--green-dark); }
.pill-sync.is-pending { background: var(--warn-bg); color: #6b4b00; }

main { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

/* ---------- shared parts ---------- */
.panel, .card { background: var(--surface); border-radius: var(--radius); padding: 1.3rem; box-shadow: 0 4px 18px rgba(16, 90, 60, .08); }
.btn {
  font: inherit; font-weight: 700; font-size: 1.15rem; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .6rem 1.2rem; min-height: 50px; cursor: pointer; text-decoration: none; text-align: center; display: inline-block;
}
.btn:hover { background: var(--green-tint); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-dark { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-dark:hover { background: #047857; }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: #fbeceb; }
.btn-quiet { border-color: var(--line-soft); color: var(--ink); }
.btn-block { display: block; width: 100%; }
.back { display: inline-block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: .6rem 1.2rem; min-height: 48px; font-weight: 600; margin-bottom: 1rem; }
.back:hover { background: var(--green-tint); }

label { display: block; font-weight: 600; margin: .9rem 0 .35rem; }
input[type=text], input[type=password], input[type=number], select {
  font: inherit; width: 100%; padding: .6rem .8rem; min-height: 52px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input::placeholder { color: #9aa6b4; }
input:focus, select:focus { border-color: var(--green-dark); outline: none; box-shadow: 0 0 0 3px rgba(16,185,129,.28); }
.form-error { color: var(--bad); font-weight: 700; min-height: 1.4em; margin: .4rem 0; }
.note { background: var(--warn-bg); padding: .5rem .7rem; border-radius: 8px; }

.gate-wrap { display: flex; justify-content: center; padding-top: 3vh; }
.gate { width: 100%; max-width: 440px; }
.gate .btn { width: 100%; margin-top: .6rem; }
.error-card { border: 2px solid var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 10px; font-weight: 700; transition: opacity .15s, transform .15s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- home ---------- */
.hero { text-align: center; padding: 1rem 0 1.2rem; }
.hero .logo { width: 110px; height: 110px; margin: 0 auto .4rem; display: block; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); margin-bottom: .3rem; }
.hero p { color: var(--muted); font-size: 1.15rem; margin: 0; }
.event-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; margin: 1.6rem 0 1.4rem; }
.event-btn {
  font: inherit; font-weight: 700; font-size: 1.7rem; color: var(--ink); text-decoration: none; text-align: center;
  background: var(--surface); border: 2.5px solid var(--line); border-radius: var(--radius); padding: 2.2rem 1rem; box-shadow: 0 3px 10px rgba(16,90,60,.08);
  display: flex; align-items: center; justify-content: center; cursor: pointer; min-width: 0; overflow-wrap: anywhere;
}
.event-btn:hover { background: var(--green-tint); }
.home-actions { display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.home-actions .btn { min-width: min(100%, 320px); font-size: 1.25rem; }
@media (max-width: 760px) { .event-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; } .event-btn { font-size: 1.4rem; padding: 1.6rem .6rem; } }
@media (max-width: 420px) { .event-btn { font-size: 1.2rem; } }

/* ---------- event page ---------- */
.event-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .4rem 1rem; margin-bottom: 1rem; }
.event-head h1 { margin: 0; }
.judge-id { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.judge-id label { margin: 0; font-weight: 500; font-size: .95rem; }
.judge-id input { width: 7rem; min-height: 42px; padding: .3rem .6rem; }
.event-panel { max-width: 840px; margin: 0 auto; }
.alliance { background: var(--green-tint); border-radius: 12px; text-align: center; padding: 1rem; margin: 1rem 0; }
.alliance .al-label { color: var(--ink); font-weight: 500; }
.alliance .al-teams { font-size: 2.4rem; font-weight: 700; color: var(--green-dark); line-height: 1.2; overflow-wrap: anywhere; }
.alliance .al-names { color: var(--muted); font-size: 1rem; min-height: 1.3em; }
.calc { border: 2.5px solid var(--line); border-radius: 14px; padding: 1.1rem; background: #f8faff; margin: 1rem 0; }
.calc h2 { text-align: center; font-size: 1.5rem; }
.calc label { margin-top: .8rem; }
.calc input[type=number] { border: 0; text-align: center; font-weight: 700; font-size: 1.4rem; min-height: 64px; }
.tone-blue input { background: linear-gradient(135deg, #bfdcff, #93c5fd); }
.tone-green input { background: linear-gradient(135deg, #cfe9d2, #a8d5ad); }
.tone-yellow input { background: linear-gradient(135deg, #fff6b8, #ffe96a); }
.tone-purple input { background: linear-gradient(135deg, #eadbff, #d4b3fb); }
.tone-gray input { background: linear-gradient(135deg, #eceef2, #d3d7df); }
.calc-total { display: flex; justify-content: space-between; align-items: center; border-top: 2.5px solid var(--line); margin-top: 1rem; padding-top: .8rem; font-weight: 700; }
.calc-total .num { font-size: 2.2rem; color: var(--green-dark); }
.calc .btn { margin-top: .6rem; }
.entry-state { min-height: 1.6em; margin: .6rem 0 0; font-weight: 700; text-align: center; }
.entry-state.ok { color: var(--green-dark); }
.entry-state.bad { color: var(--bad); }
.entry-extra { text-align: center; margin-top: .4rem; }

.schedule { max-width: 1100px; margin: 1.6rem auto 0; }
.schedule h2 { margin-bottom: .8rem; }
.schedule-list { max-height: 420px; overflow-y: auto; padding-right: .6rem; display: flex; flex-direction: column; gap: .7rem; }
.sched-row {
  font: inherit; font-weight: 500; text-align: left; color: var(--ink); background: #fff; border: 2.5px solid var(--line); border-radius: 12px;
  padding: .85rem 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; cursor: pointer; min-height: 56px;
}
.sched-row:hover { background: var(--green-tint); }
.sched-row b { color: var(--green-dark); }
.sched-row[aria-current="true"] { background: var(--green-tint); box-shadow: 0 0 0 3px rgba(16,185,129,.35); }
.sched-row .got { font-weight: 700; color: var(--green-dark); white-space: nowrap; }
.sched-row .todo { color: var(--muted); font-weight: 500; white-space: nowrap; }

/* ---------- VR coding page ---------- */
.challenge-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.challenge-btn { font: inherit; color: var(--ink); background: #fff; border: 2.5px solid var(--line); border-radius: 12px; padding: .9rem .4rem; cursor: pointer; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; }
.challenge-btn .cname { font-weight: 700; font-size: 1.3rem; }
.challenge-btn .cmax { font-size: .95rem; color: var(--muted); }
.challenge-btn:hover { background: var(--green-tint); }
.challenge-btn[aria-pressed="true"] { background: var(--green); border-color: var(--green-dark); color: #fff; }
.challenge-btn[aria-pressed="true"] .cmax { color: #eafff6; }
.target-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip-t { font: inherit; font-weight: 700; font-size: 1.3rem; min-width: 56px; min-height: 56px; padding: .3rem .9rem; border-radius: 10px; border: 2.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.chip-t:hover { background: var(--green-tint); }
.chip-t[aria-pressed="true"] { background: var(--green); border-color: var(--green-dark); color: #fff; }
.chip-none[aria-pressed="true"] { background: #5b6b80; border-color: #5b6b80; }
.finish-toggle { font: inherit; font-weight: 600; font-size: 1.15rem; display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 56px; padding: .5rem .9rem; border-radius: 10px; border: 2.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.finish-toggle .box { width: 28px; height: 28px; border-radius: 6px; border: 2.5px solid var(--green-dark); background: #fff; flex: none; display: inline-block; position: relative; }
.finish-toggle[aria-pressed="true"] { background: var(--green-tint); border-color: var(--green-dark); }
.finish-toggle[aria-pressed="true"] .box { background: var(--green-dark); }
.finish-toggle[aria-pressed="true"] .box::after { content: ''; position: absolute; left: 7px; top: 2px; width: 7px; height: 14px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
@media (max-width: 520px) { .challenge-btn .cname { font-size: 1.1rem; } .challenge-btn .cmax { font-size: .8rem; } }

/* ---------- run schedule helpers ---------- */
.sched-box { background: var(--green-tint); border-radius: 12px; padding: .8rem 1rem 1rem; margin-bottom: 1rem; }
.sched-box label { margin-top: 0; }
.sched-box select { max-width: 11rem; }
.sched-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; min-height: 1.5rem; }
.sched-chip { font: inherit; font-weight: 700; font-size: 1.1rem; color: var(--ink); background: #fff; border: 2.5px solid var(--line); border-radius: 10px; padding: .4rem .9rem; min-height: 48px; cursor: pointer; }
.sched-chip:hover { background: #fff; border-color: var(--green-dark); }
.sched-chip.done { background: #d9f5e8; border-color: #8fdcb8; }
.sched-chip[aria-current="true"] { box-shadow: 0 0 0 3px rgba(16,185,129,.35); }
.sched-none { color: var(--muted); }
.al-sched { color: var(--muted); font-size: 1rem; }
.sched-note { display: block; font-weight: 500; font-size: .9rem; color: var(--muted); }

/* ---------- tables (standings, autonomous) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 4px 18px rgba(16,90,60,.08); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .45rem .7rem; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { font-weight: 700; background: #f4faf7; }
th.l, td.l { text-align: left; }
thead th { position: sticky; top: 0; z-index: 2; }
tbody tr:last-child td { border-bottom: 0; }
.score-table th, .score-table td { text-align: center; }
.score-table th.l, .score-table td.l { text-align: left; }
.score-table .rank { font-weight: 700; font-size: 1.5rem; width: 3.2rem; }
.score-table .team { font-weight: 700; font-size: 1.4rem; }
.score-table .total { font-weight: 700; font-size: 1.5rem; background: #eefaf4; }
.score-table tr.top1 td { background: #fff6d6; }
.score-table tr.top1 td.total { background: #ffecaa; }
.score-table tr.top2 td, .score-table tr.top3 td { background: #f6fbf8; }
.score-table .sticky1 { position: sticky; left: 0; background: inherit; z-index: 1; }
.score-table td.sticky1 { background: #fff; }
.score-table tr.top1 td.sticky1 { background: #fff6d6; }
.score-table .grp th { color: #fff; border-bottom: 0; }
.grp .g-auto { background: #5b6b80; } .grp .g-none { background: transparent; }
.dim { color: #8a95a6; }

.winner { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem; background: #fff6d6; border: 2px solid #e8c24a; border-radius: var(--radius); padding: .8rem 1.2rem; margin-bottom: 1rem; }
.winner .big { font-weight: 700; font-size: 2.2rem; line-height: 1; }
.progress-line { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin: .8rem 0 1rem; color: var(--muted); }
.progress-line b { color: var(--ink); }
.tools { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 2px solid var(--line-soft); }
.tab { font: inherit; font-weight: 700; background: none; border: 0; border-bottom: 4px solid transparent; padding: .6rem 1rem; min-height: 48px; cursor: pointer; color: var(--muted); margin-bottom: -2px; }
.tab[aria-selected="true"] { color: var(--green-dark); border-bottom-color: var(--green); }

.round-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: .4rem; margin-top: .6rem; }
.rpill { border: 2px solid var(--line-soft); background: #fff; border-radius: 8px; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; padding: .2rem; }
.rpill .rn { font-size: .8rem; color: var(--muted); }
.rpill .rs { font-weight: 700; font-size: 1.4rem; min-height: 1.4rem; }
.rpill .rt { font-size: .68rem; color: var(--muted); }
.rpill.has { background: #d9f5e8; border-color: #8fdcb8; }
.rpill.miss { border-style: dashed; }
.game-progress { margin-bottom: 1.4rem; }
.game-progress h3 { display: flex; align-items: center; gap: .5rem; }
.game-progress .count { font-size: .95rem; font-weight: 500; color: var(--muted); }
.dot { width: .85rem; height: .85rem; border-radius: 50%; display: inline-block; }

.auto-table input { width: 6rem; min-height: 42px; text-align: right; padding: .2rem .5rem; }
.auto-table td, .auto-table th { padding: .35rem .7rem; }
.team-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1.2rem; }
.team-names .row { display: flex; align-items: center; gap: .6rem; }
.team-names .row b { font-size: 1.5rem; width: 2.6rem; }
.danger { border: 2px solid #e7b9b5; margin-top: 2rem; }

@media (max-width: 640px) {
  body { font-size: 18px; }
  h1 { font-size: 2.1rem; }
  .bar { padding: .3rem .7rem; }
  .status { font-size: .85rem; gap: .4rem; }
  .link-btn { min-height: 34px; }
  .panel, .card { padding: 1rem; }
  .alliance .al-teams { font-size: 2rem; }
}

@media print {
  #header, .tools, .tabs, .toast, .no-print, .back { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .table-wrap { box-shadow: none; overflow: visible; }
  th, td { padding: .25rem .4rem; font-size: 11pt; }
  .score-table .sticky1 { position: static; }
  thead th { position: static; }
}
