:root {
  --bg: #101114;
  --card: #1a1c21;
  --card-2: #23262d;
  --line: #2e323b;
  --text: #f1efe9;
  --muted: #9a9fab;
  --accent: #f5b83d;
  --accent-ink: #1b1403;
  --ok: #58c98b;
  --bad: #ef6b63;
  --wa: #25d366;
  --radius: 16px;
  --tabs: 62px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
body.app { padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 16px); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.9rem; line-height: 1.15; margin: 4px 0 16px; letter-spacing: -.02em; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 26px 0 10px; }
h2 small, summary small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.card h2 { margin-top: 0; }
p { margin: 0 0 10px; }
code { background: var(--card-2); padding: 2px 6px; border-radius: 6px; font-size: .88em; overflow-wrap: anywhere; }
small, .small { font-size: .84rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.eyebrow { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 2px; display: block; }
.eyebrow a { color: inherit; }

.wrap { max-width: 720px; margin: 0 auto; padding: 14px 14px 8px; }
.wrap.narrow { max-width: 420px; padding-top: 8vh; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(16, 17, 20, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: -.03em; color: var(--text); font-size: 1.15rem; }
.brand::after { content: "."; color: var(--accent); }
.brand.big { font-size: 2.4rem; text-align: center; margin: 0 0 6px; display: block; }
.who { color: var(--muted); font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; display: block; color: inherit; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > * { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.wrap-row { flex-wrap: wrap; margin: 4px 0 14px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; color: var(--muted); }
input, textarea, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); font-size: 16px;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); font-size: .96rem; }
label.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-weight: 600; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
.btn.danger { color: var(--bad); }
.btn.wa { background: transparent; border-color: var(--wa); color: var(--wa); }
.btn[disabled] { opacity: .5; }
.link { background: none; border: 0; padding: 4px; color: var(--accent); cursor: pointer; font-size: .86rem; }

.flash { padding: 12px 14px; border-radius: 12px; background: rgba(88, 201, 139, .14); border: 1px solid rgba(88, 201, 139, .4); }
.flash.error { background: rgba(239, 107, 99, .14); border-color: rgba(239, 107, 99, .45); }

.callout { display: flex; gap: 12px; align-items: flex-start; border-color: rgba(245, 184, 61, .45); background: rgba(245, 184, 61, .08); }
.callout-icon { font-size: 1.5rem; line-height: 1.2; }

.hero { background: linear-gradient(160deg, #262018, var(--card) 60%); }
.hero h1 { font-size: 2.3rem; margin: 2px 0 8px; }
.deadline { color: var(--muted); }
.deadline strong { color: var(--accent); font-weight: 600; white-space: nowrap; }
.players { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.players li { display: flex; align-items: center; gap: 8px; }
.players b { color: var(--muted); font-weight: 600; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--card-2); display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
.avatar.me { background: var(--accent); color: var(--accent-ink); }

.mine { padding: 0; overflow: hidden; }
.mine .ph img { width: 100%; max-height: 60vh; object-fit: cover; }
.mine details { padding: 12px 16px; }
.mine summary { display: flex; justify-content: space-between; gap: 10px; }
.mine summary span:first-child { overflow-wrap: anywhere; font-weight: 600; }
.mine form { margin-top: 12px; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
details.card > summary { display: flex; justify-content: space-between; align-items: center; }
details.card > summary::after { content: "＋"; color: var(--muted); }
details.card[open] > summary::after { content: "－"; }
details.card > summary h2 { margin: 0; }
details.card[open] > summary { margin-bottom: 12px; }

.drop { border: 2px dashed var(--line); border-radius: 14px; min-height: 150px; align-items: center; justify-content: center; text-align: center; cursor: pointer; position: relative; overflow: hidden; color: var(--text); }
.drop input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.drop-empty { font-size: 1.1rem; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.drop-empty small { color: var(--muted); font-weight: 400; }
.drop img { max-height: 46vh; width: 100%; object-fit: contain; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

.result-card { display: flex; gap: 14px; align-items: center; }
.result-card img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; flex: none; }
.result-card > span { display: flex; flex-direction: column; min-width: 0; }

.verdict { text-align: center; border-color: rgba(245, 184, 61, .45); }
.verdict-title { font-size: 1.4rem; display: block; margin-bottom: 10px; }
.scores { list-style: none; margin: 0 0 10px; padding: 0; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.scores li { background: var(--card-2); border-radius: 14px; padding: 10px 18px; display: flex; flex-direction: column; min-width: 110px; }
.scores li.win { outline: 2px solid var(--accent); }
.scores b { font-size: 1.8rem; line-height: 1.1; }
.scores small { color: var(--muted); }

.photo { padding: 0; overflow: hidden; scroll-margin-top: 70px; }
.photo > a { position: relative; display: block; background: #000; }
.photo > a img { width: 100%; max-height: 80vh; object-fit: contain; }
.photo-body { padding: 14px 16px 16px; }
.photo-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.photo-head > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.score { font-size: 1.5rem; color: var(--accent); line-height: 1; }
.exif { color: var(--muted); font-size: .8rem; }
.given { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .9rem; }
.given b { color: var(--text); }
.badge { position: absolute; left: 10px; top: 10px; background: rgba(0, 0, 0, .7); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.gold { background: var(--accent); color: var(--accent-ink); }

.rate { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 12px 0; }
.rate button { min-height: 44px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; cursor: pointer; }
.rate button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rate.busy { opacity: .6; pointer-events: none; }

.comments { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.comment { font-size: .94rem; overflow-wrap: anywhere; }
.comment form { display: inline; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; min-width: 0; }

.gweek { margin-bottom: 22px; }
.gweek-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; color: var(--text); margin-bottom: 8px; }
.gweek-head strong { font-size: 1.2rem; overflow-wrap: anywhere; }
.gweek-head > span:first-child { min-width: 0; }
.pill { background: var(--card-2); border-radius: 999px; padding: 4px 12px; font-size: .84rem; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid .ph { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--card); }
.grid img { width: 100%; height: 100%; object-fit: cover; }
.grid .badge { left: 6px; top: 6px; padding: 1px 7px; }

.table-card { overflow-x: auto; }
.standings { width: 100%; border-collapse: collapse; }
.standings th, .standings td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.standings th { color: var(--muted); font-size: .78rem; font-weight: 500; }
.standings td:nth-child(2), .standings th:nth-child(2) { text-align: left; }
.pts { color: var(--accent); font-size: 1.15rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.cols .card { margin: 0; }
.player-card dl, .kv { margin: 0 0 12px; display: grid; gap: 6px; }
.player-card dl div, .kv div { display: flex; justify-content: space-between; gap: 10px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }
.form { display: flex; gap: 4px; align-items: center; }
.form i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.form .fW { background: var(--ok); }
.form .fD { background: var(--accent); }
.form .fL { background: var(--bad); }
.best { position: relative; display: block; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.best img { width: 100%; height: 100%; object-fit: cover; }

.list { list-style: none; padding: 4px 16px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.list li:last-child { border-bottom: 0; }
.list li > a { display: flex; justify-content: space-between; gap: 10px; width: 100%; color: inherit; flex-wrap: wrap; }
.list .eyebrow { display: inline; }
.list.numbered { counter-reset: n; }
.list.numbered li::before { counter-increment: n; content: counter(n); color: var(--muted); width: 1.4em; flex: none; }
.list.numbered li span { flex: 1; }
.list.log { padding: 0; }
.log small { display: block; color: var(--muted); }
.steps { padding-left: 20px; display: grid; gap: 8px; margin: 12px 0; }
.copy { display: inline-block; margin-top: 4px; user-select: all; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--bad); }
.checks .warn { color: var(--accent); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(22, 23, 27, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { height: var(--tabs); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: .72rem; }
.tabs a.on { color: var(--accent); }
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }

#lightbox { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; align-items: center; justify-content: center; touch-action: pan-y pinch-zoom; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close, .lb-nav { position: absolute; z-index: 2; background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 50%; width: 46px; height: 46px; font-size: 1.3rem; cursor: pointer; }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .85)); display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.lb-info span { color: #c9ccd3; font-size: .84rem; }
.lb-info span:empty, .lb-info strong:empty { display: none; }
body.lb-open { overflow: hidden; }

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .rate button { transition: background-color .15s, transform .1s; }
  .btn:active, .rate button:active { transform: scale(.97); }
}
