:root {
  --bg: #0f0f13; --panel: #18181f; --panel2: #22222b; --line: #2e2e39;
  --text: #f2f2f5; --muted: #9a9aa8; --accent: #ff4f7b; --accent2: #ffb03b; --ok: #3ad29f;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }

header { position: sticky; top: 0; z-index: 10; background: rgba(15,15,19,.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.bar { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 999px; margin-left: auto; }
.tabs a { padding: 6px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a.on { background: var(--panel2); color: var(--text); }
.who { font-size: 13px; color: var(--muted); width: 100%; display: flex; justify-content: space-between; gap: 8px; }
.who button { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.progress { height: 6px; border-radius: 6px; background: var(--panel2); overflow: hidden; margin: 4px 0 16px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.rated { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.cover { position: relative; aspect-ratio: 3/4; background: var(--panel2); cursor: zoom-in; border: 0; padding: 0; width: 100%; display: block; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .count { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.65); padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.cover .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.card .body { padding: 12px 14px 14px; }
.card h3 { margin: 0 0 10px; font-size: 18px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 small { color: var(--ok); font-size: 14px; font-weight: 700; }
.scores { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.scores button { aspect-ratio: 1; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; cursor: pointer;
  font-weight: 700; font-size: 14px; padding: 0; transition: transform .08s, background .15s; }
.scores button:active { transform: scale(.9); }
.scores button.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #111; }
.scores button.fill { background: color-mix(in srgb, var(--accent) 22%, var(--panel2)); }
.scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Lightbox */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 50; display: none; flex-direction: column; }
.lb.open { display: flex; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.lb-top b { font-size: 18px; }
.lb-top span { color: var(--muted); font-size: 14px; margin-left: 8px; }
.lb-x { background: var(--panel2); border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lb-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; touch-action: pan-y; user-select: none; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; width: 48px; height: 48px;
  border-radius: 50%; font-size: 26px; cursor: pointer; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-thumbs { display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; justify-content: center; }
.lb-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; opacity: .45; cursor: pointer; border: 2px solid transparent; flex: none; }
.lb-thumbs img.on { opacity: 1; border-color: var(--accent); }
.lb-rate { padding: 0 16px 16px; max-width: 520px; width: 100%; margin: 0 auto; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; place-items: center; z-index: 60; padding: 16px; }
.modal.open { display: grid; }
.modal form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: min(400px, 100%); }
.modal h2 { margin: 0 0 6px; }
.modal p { color: var(--muted); margin: 0 0 16px; }
input[type=text], input[type=password] { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); outline: none; }
input:focus { border-color: var(--accent); }
.btn { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #111; border: 0; padding: 12px 18px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #3a1820; color: #ff8fa6; border: 1px solid #5a2430; }
.modal .btn { width: 100%; margin-top: 12px; }

/* Results */
.podium { display: grid; gap: 10px; }
.rank { display: grid; grid-template-columns: 36px 56px 1fr auto; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; }
.rank .pos { font-size: 22px; font-weight: 800; text-align: center; color: var(--muted); }
.rank:nth-child(1) .pos { color: #ffd34d; } .rank:nth-child(2) .pos { color: #d6d6e0; } .rank:nth-child(3) .pos { color: #e09a5b; }
.rank img, .rank .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--panel2); }
.rank .name { font-weight: 700; }
.rank .meter { height: 6px; background: var(--panel2); border-radius: 6px; margin-top: 6px; overflow: hidden; }
.rank .meter div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.rank .avg { font-size: 24px; font-weight: 800; text-align: right; }
.rank .avg small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
h2.sec { margin: 28px 0 10px; font-size: 18px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
thead th { background: var(--panel); color: var(--muted); font-weight: 600; }
td.hi { color: var(--ok); font-weight: 700; } td.lo { color: var(--accent); font-weight: 700; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 16px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(80px); background: var(--panel2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; transition: transform .25s; z-index: 70; font-size: 14px; }
.toast.show { transform: translateX(-50%) translateY(0); }
