/* MySkate Inline Freestyle: black, orange, white (from the MySkate badge) */
:root {
  --ink: #111111; --bg: #F4F4F2; --orange: #F58232; --accent: #B5530F; --gold: #D9A21B; --coral: #C0392B;
  --card: #FFFFFF; --muted: #5E5E5E; --line: #E4E4E0; --green: #2F7D4F; --amber: #B7791F;
  --silver: #8E8E8E; --bronze: #A0643A; --soft: #EBEBE7;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.07);
  --head: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--body); }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 700; margin: 0; letter-spacing: .01em; }
h1 { font-size: 32px; text-transform: uppercase; } h2 { font-size: 22px; } h3 { font-size: 18px; } h4 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.note { color: var(--muted); font-size: 14px; margin-top: 8px; }
.note.ok, .ok { color: var(--green); } .note.err, .err { color: var(--coral); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: #0B0B0B; color: #fff; border-bottom: 3px solid var(--orange);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand img { border-radius: 50%; display: block; }
.brand strong { display: block; font: 800 20px var(--head); line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
.brand small { display: block; font: 700 13px var(--head); color: var(--orange); text-transform: uppercase; letter-spacing: .08em; }
.topnav { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.topnav a { color: #E6E6E6; text-decoration: none; font: 600 15px var(--body); padding: 8px 12px; border-radius: 10px; white-space: nowrap; }
.topnav a:hover { background: rgba(255,255,255,.1); }
.topnav a.active { background: var(--orange); color: #111; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }

/* forms and buttons */
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; font: 500 15px var(--body); color: var(--ink);
  background: #fff; border: 1px solid #C9D8DF; border-radius: 10px; }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid rgba(245,130,50,.55); outline-offset: 2px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 10px; font: 600 15px var(--body); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--orange); color: #111; } .btn.primary:hover { background: #E8721F; }
.btn.ink { background: var(--ink); color: #fff; }
.btn.ghost { background: var(--soft); color: var(--ink); } .btn.green { background: var(--green); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font: 500 14px var(--body); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--coral); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.comp-card { display: block; color: inherit; text-decoration: none; margin: 0; transition: transform .12s ease; }
.comp-card:hover { transform: translateY(-2px); }
.comp-card h3 { margin: 6px 0 4px; font-size: 18px; }
.comp-date { font: 700 15px var(--head); color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.comp-card { border-top: 4px solid var(--orange); }
.hero { display: flex; align-items: center; gap: 18px; background: #0B0B0B; color: #fff; border-radius: 18px; padding: 20px; margin-bottom: 20px; }
.hero img { width: 104px; height: 104px; flex: none; }
.hero h1 { color: #fff; } .hero p { color: #D0D0D0; }
.hero .accent { color: var(--orange); }
@media (max-width: 560px) { .hero { flex-direction: column; text-align: center; } }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }

/* chips and pills */
.chip { display: inline-block; background: var(--soft); color: var(--ink); border-radius: 999px; padding: 2px 10px; font: 600 12px var(--body); white-space: nowrap; }
.pill { display: inline-block; font: 600 12px var(--body); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.open, .pill.approved, .pill.ok { background: #DDF1E4; color: #1F6B3F; }
.pill.pending, .pill.closed { background: #FBEFC8; color: #7A5410; }
.pill.live { background: #F8DEDB; color: #9C3A33; }
.pill.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-right: 5px; vertical-align: 1px; animation: pulse 1.4s infinite; }
.pill.finished, .pill.withdrawn, .pill.draft { background: var(--soft); color: var(--muted); }
.pill.rejected, .pill.dq { background: #F8DEDB; color: #9C3A33; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .pill.live::before { animation: none; } .comp-card { transition: none; } }

/* tabs */
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; overflow-x: auto; margin-bottom: 14px; }
.tabs button { flex: none; border: 0; background: transparent; font: 600 14px var(--body); color: var(--ink); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: #fff; box-shadow: var(--shadow); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; min-height: 40px; }

/* tables */
.tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.place { width: 44px; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font: 700 13px var(--head); background: var(--soft); }
.medal.m1 { background: var(--gold); color: #fff; } .medal.m2 { background: var(--silver); color: #fff; } .medal.m3 { background: var(--bronze); color: #fff; }
.who strong { display: block; } .who small { display: block; color: var(--muted); font-size: 12px; }
.bib { display: inline-block; min-width: 30px; text-align: center; font: 700 13px var(--head); background: var(--ink); color: var(--orange); border-radius: 6px; padding: 1px 6px; }
tr.me td { background: #FFF3EA; }
tr.waiting td { color: var(--muted); }

/* judging */
.score-row { display: grid; grid-template-columns: 1fr repeat(3, 92px); gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.score-row input { text-align: center; font-size: 18px; min-height: 48px; }
.score-row .who { min-width: 0; }
.score-row.head { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.score-row.saved input { border-color: #7DC298; }
@media (max-width: 560px) { .score-row { grid-template-columns: 1fr repeat(3, 70px); } }
.pen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }
.pen-grid label { margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--soft); font: 700 18px var(--body); cursor: pointer; }
.stepper output { min-width: 26px; text-align: center; font: 700 18px var(--head); }
.run-grid { display: grid; grid-template-columns: 1fr repeat(2, minmax(150px, 190px)); gap: 8px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.run-cell { display: grid; grid-template-columns: 1fr 58px; gap: 4px; }
.run-cell select { grid-column: 1 / -1; min-height: 36px; font-size: 13px; }
@media (max-width: 640px) { .run-grid { grid-template-columns: 1fr; } }
.heat { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.heat h4 { margin-bottom: 8px; }
.pos-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.pos-row select { width: 80px; }
.jump-card { display: flex; gap: 6px; flex-wrap: wrap; }
.jump-card input { width: 70px; text-align: center; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(244,244,242,.96); padding: 10px 0; margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flag { display: inline-block; font-size: 12px; background: #FBEFC8; color: #7A5410; border-radius: 6px; padding: 1px 6px; }

/* dialogs and toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal h3 { margin-bottom: 8px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-err { color: var(--coral); font-size: 14px; margin-top: 10px; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: var(--coral); }

/* profile / ranking */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 12px; padding: 12px; }
.stat strong { display: block; font: 700 22px var(--head); }
.stat span { font-size: 12px; color: var(--muted); }
.world { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: #FDE9DB; color: #8A3D0A; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.login-box { max-width: 420px; margin: 6vh auto 0; }
.foot { margin-top: 30px; text-align: center; font-size: 12px; color: var(--muted); }
