:root {
  --bg: #0a0a0a;
  --bg-2: #121212;
  --card: #171717;
  --line: #2a2a2a;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --orange: #ff5a1f;
  --orange-2: #ff7a45;
  --gold: #f5c518;
  --silver: #c0c7d1;
  --bronze: #cd7f32;
  --ok: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange); }
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }

.top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg, .brand img { width: 40px; height: 40px; flex: 0 0 auto; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line);
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
}

.wrap { padding: 8px 16px 28px; }
h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 12px; letter-spacing: -.03em; }
h2 { font-size: 18px; margin: 18px 0 10px; }
.lead { color: var(--muted); margin: 0 0 20px; line-height: 1.45; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; border-radius: 14px; border: 0;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 16px;
  padding: 0 16px;
}
.btn:disabled { opacity: .45; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.btn.dark { background: #fff; color: #111; }
.btn.small { min-height: 42px; width: auto; padding: 0 14px; font-size: 14px; }
.btn.danger { background: transparent; border: 1px solid #7f1d1d; color: #fca5a5; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 0 0 10px;
}
.card.tap { width: 100%; text-align: left; color: inherit; display: block; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; background: #24160f; color: var(--orange-2);
}
.badge.ok { background: #052e16; color: #86efac; }
.badge.muted { background: #222; color: var(--muted); }

label.field { display: block; margin: 0 0 14px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=tel], textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 14px; font-size: 16px;
}
textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  border-radius: 999px; padding: 10px 14px; min-height: 42px; font-weight: 600;
}
.chip.on { border-color: var(--orange); background: #2a140c; color: #fff; }

.toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0;
}
.toggle p { margin: 0; font-size: 13px; color: var(--muted); }
.switch {
  width: 48px; height: 28px; border-radius: 999px; border: 0; background: #333; position: relative;
}
.switch:after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: .15s;
}
.switch.on { background: var(--orange); }
.switch.on:after { left: 23px; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  background: var(--card); padding: 6px; border-radius: 14px; margin: 8px 0 14px;
  border: 1px solid var(--line);
}
.tabs button {
  border: 0; background: transparent; color: var(--muted); min-height: 40px;
  border-radius: 10px; font-weight: 700;
}
.tabs button.on { background: #222; color: #fff; }

.match {
  display: block; width: 100%; text-align: left; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; margin: 0 0 10px;
}
.match .meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.pname { font-weight: 700; font-size: 16px; }
.pname.win { color: var(--ok); }
.pname.muted { color: var(--muted); font-weight: 600; }
.vs-lab { color: var(--muted); font-size: 12px; font-weight: 800; }
.scoreline { color: var(--muted); font-size: 13px; margin-top: 8px; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
}
.sheet {
  width: min(640px, 100%); background: #141414; border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  max-height: 92dvh; overflow: auto;
}
.handle { width: 42px; height: 4px; background: #333; border-radius: 99px; margin: 4px auto 12px; }
.set-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin: 8px 0; }
.step {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
}
.step button {
  width: 44px; height: 44px; border: 0; background: #222; border-radius: 10px; font-size: 22px;
}
.step b { min-width: 28px; text-align: center; font-size: 20px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; align-items: end; margin: 8px 0 18px; }
.pod {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px; text-align: center; min-height: 96px;
}
.pod.gold { border-color: #5c4a10; background: #1a1608; min-height: 124px; }
.pod .place { font-size: 12px; color: var(--muted); }
.pod .who { font-weight: 800; margin-top: 6px; }

.list-place { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-place .n { width: 28px; color: var(--muted); font-weight: 800; }
.err { color: #fca5a5; font-size: 14px; margin: 8px 0; }
.okmsg { color: #86efac; }
.pin { letter-spacing: .4em; text-align: center; font-size: 28px !important; }

.actions { display: grid; gap: 8px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

body.is-print { background: #fff; }
body.is-print #app { max-width: 720px; background: #fff; }
.print-bar { padding: 16px 16px 8px; background: #fff; }
.print-bar .btn { margin-bottom: 8px; }
.print-bar .hint { color: #4b5563; }

.paper {
  background: #fff;
  color: #1a1a1a;
  width: 100%;
  margin: 0;
  padding: 8px 16px 28px;
  box-shadow: none;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
}
.paper + .paper { border-top: 8px solid #f3f4f6; padding-top: 22px; }
.school-logo {
  display: block;
  width: 62%;
  max-width: 220px;
  height: auto;
  margin: 8px auto 14px;
}
.doc-kicker {
  margin: 0;
  text-align: center;
  color: #163a82;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
}
.paper h1 {
  margin: 6px 0 0;
  text-align: center;
  color: #141414;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.doc-meta {
  margin: 8px 0 0;
  text-align: center;
  color: #4b5563;
  font-size: 12.5px;
  line-height: 1.45;
}
.doc-rule {
  height: 2px;
  width: 42px;
  margin: 14px auto 16px;
  background: #163a82;
  border: 0;
}
.paper h2 {
  margin: 16px 0 8px;
  color: #163a82;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.paper h2:first-of-type { margin-top: 0; }
.doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
  margin: 0 0 16px;
}
.doc-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #163a82;
  font-weight: 700;
  padding: 7px 8px;
  border-bottom: 1.5px solid #163a82;
}
.doc-table td {
  padding: 8px 8px;
  border-bottom: 1px solid #e6e8ee;
  vertical-align: middle;
  color: #1a1a1a;
}
.doc-table .num { width: 14%; color: #163a82; font-weight: 700; font-variant-numeric: tabular-nums; text-align: left !important; }
.doc-table th.deg { text-align: right; width: 36%; }
.doc-table td.deg { text-align: right; color: #374151; width: 36%; white-space: normal; }
.doc-table th.sc, .doc-table td.sc { text-align: center; font-variant-numeric: tabular-nums; color: #374151; width: 22%; }
.doc-table th.right, .doc-table td.right { text-align: right; }
.doc-table tr.is-1 td, .doc-table tr.is-2 td, .doc-table tr.is-3 td,
.doc-table td.is-win { font-weight: 700; }
.doc-table tr.is-1 .deg, .doc-table tr.is-2 .deg, .doc-table tr.is-3 .deg { color: #163a82; }
.doc-table tr.wave td {
  padding: 10px 8px 4px;
  border-bottom: 0;
  color: #6b7280;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 700;
}
.doc-note { margin: -8px 0 14px; color: #4b5563; font-size: 12.5px; }
.doc-foot {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid #e6e8ee;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #6b7280;
  font-size: 11px;
}

@page { size: A4 portrait; margin: 10mm 12mm; }
@media print {
  html, body, #app, .paper {
    background: #fff !important;
    color: #111 !important;
    zoom: 1 !important;
    width: auto !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.is-print #app { max-width: none; }
  .no-print { display: none !important; }
  .paper {
    margin: 0 !important;
    padding: 0 !important;
    break-after: auto;
    page-break-after: auto;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .paper + .paper {
    border-top: 0;
    break-before: page;
    page-break-before: always;
    padding-top: 0 !important;
  }
  .school-logo { width: 34mm !important; max-width: 34mm !important; margin: 0 auto 2mm !important; }
  .doc-kicker { font-size: 9pt; letter-spacing: .12em; }
  .paper h1 { font-size: 16pt; margin: 1mm 0 0; }
  .doc-meta { font-size: 9pt; margin: 1mm 0 0; line-height: 1.3; }
  .doc-rule { margin: 2mm auto 3mm; }
  .paper h2 { font-size: 10pt; margin: 3mm 0 1mm; }
  .doc-table { font-size: 10pt; margin: 0 0 2mm; }
  .doc-table th { font-size: 8pt; padding: 1mm 1.5mm; }
  .doc-table td { padding: 1.1mm 1.5mm; }
  .doc-note { margin: 0 0 2mm; font-size: 9pt; }
  .doc-foot { margin-top: 3mm; padding-top: 1.5mm; font-size: 8pt; }
  .doc-table tr { break-inside: avoid; page-break-inside: avoid; }
}
