:root {
  --bg: #fdf8f5;
  --blush: #f7e6dc;
  --blush-2: #ecc9b8;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #eadfd8;
  --accent: #b4532a;
  --gold: #c08a2b;
  --card: #ffffff;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Heebo', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.top {
  text-align: center;
  padding: 28px 16px 22px;
  background: linear-gradient(180deg, var(--blush) 0%, var(--bg) 100%);
}
.logo { width: 112px; height: 112px; border-radius: 50%; display: block; margin: 0 auto 12px; box-shadow: 0 6px 24px rgba(180, 83, 42, .15); }
h1 { font-size: 28px; font-weight: 800; margin: 0; letter-spacing: -.5px; }
.sub { font-size: 18px; font-weight: 300; color: var(--accent); margin-top: 2px; }
.how { color: var(--muted); font-size: 15px; margin: 10px auto 0; max-width: 420px; }

main { max-width: 820px; margin: 0 auto; padding: 0 16px 24px; }

.leaders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 18px; }
.leader { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.leader .place { font-size: 22px; }
.leader .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader .score { font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.leader .score small { font-size: 12px; font-weight: 400; color: var(--muted); }
.leader.first { border-color: var(--gold); box-shadow: 0 4px 18px rgba(192, 138, 43, .18); }

.bar { display: flex; gap: 10px; margin-bottom: 14px; }
.search { flex: 1; min-width: 0; }

.btn {
  font: inherit; font-weight: 600; font-size: 16px;
  background: var(--ink); color: #fff; border: 0; border-radius: 999px;
  padding: 11px 20px; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #b91c1c; }

input {
  font: inherit; font-size: 16px; width: 100%;
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 10px 12px; color: var(--ink);
}
input:focus { outline: 2px solid var(--blush-2); border-color: var(--blush-2); }
input[type=file] { padding: 8px; font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.form { padding: 18px 16px; margin-bottom: 16px; display: grid; gap: 12px; }
.form h2 { margin: 0; font-size: 20px; }
.form label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.row { display: flex; gap: 10px; }
.msg { font-size: 14px; min-height: 0; }
.msg.err { color: #b91c1c; }
.msg.ok { color: #15803d; }
.progress { position: relative; height: 26px; background: var(--blush); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--blush-2); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; }

.table-wrap { overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 11px 10px; text-align: right; border-bottom: 1px solid var(--line); }
th { background: var(--blush); font-weight: 600; font-size: 13px; color: #57534e; cursor: pointer; user-select: none; white-space: nowrap; }
th:not([data-sort]) { cursor: default; }
th.sorted::after { content: ' ▾'; }
th.sorted.asc::after { content: ' ▴'; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: center; }
td.num { font-weight: 800; font-size: 18px; color: var(--accent); }
td.name { font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.play {
  font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--ink); text-decoration: none; white-space: nowrap; display: inline-block;
}
.del { font: inherit; border: 0; background: none; color: #b91c1c; font-size: 18px; cursor: pointer; padding: 4px 6px; }
.count { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

footer { text-align: center; padding: 10px 16px 32px; }
.link { font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }

.modal { position: fixed; inset: 0; background: rgba(20, 15, 12, .82); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { position: relative; width: 100%; max-width: 720px; }
.modal video { width: 100%; max-height: 78vh; border-radius: 12px; background: #000; display: block; }
.modal-title { color: #fff; font-weight: 600; margin-bottom: 8px; padding-left: 44px; }
.close { position: absolute; top: -6px; left: 0; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #fff; font-size: 24px; line-height: 1; cursor: pointer; }

@media (max-width: 520px) {
  h1 { font-size: 24px; }
  th, td { padding: 10px 6px; }
  table { font-size: 14px; }
  .bar { flex-wrap: wrap; }
  .bar .btn { flex: 1 1 100%; }
  .leader .score { font-size: 22px; }
}
