:root {
  --blue: #3478f6;
  --blue-deep: #173b8e;
  --ink: #0f172a;
  --muted: #64748b;
  --card: #fff;
  --bg: #eef3fb;
  --line: #e2e8f0;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
}
a { color: var(--blue); text-decoration: none; }
button, input, textarea { font: inherit; }
.page { padding-bottom: calc(88px + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 10px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.8);
}
.topbar .back, .topbar .side {
  min-width: 44px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 15px; font-weight: 700; background: none; border: 0;
}
.topbar .back { font-size: 28px; font-weight: 400; line-height: 1; }
.topbar h1 { margin: 0; flex: 1; text-align: center; font-size: 17px; font-weight: 700; }
.main { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px 18px 18px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(155deg, #102a6b 0%, #1d4ed8 48%, #38bdf8 120%);
  box-shadow: 0 12px 28px rgba(23, 59, 142, .22);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: .45;
  mask-image: linear-gradient(115deg, transparent 18%, #000 88%);
  pointer-events: none;
}
.hero::after {
  content: "PHP";
  position: absolute;
  right: 14px;
  top: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: .08em;
  color: rgba(255,255,255,.14);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.12);
}
.hero h2 { margin: 14px 0 8px; font-size: 24px; line-height: 1.28; letter-spacing: .01em; }
.hero h2 span {
  color: #7dd3fc;
  font-style: normal;
}
.hero p { margin: 0; opacity: .9; font-size: 13px; line-height: 1.65; max-width: 92%; }
.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.hero-chips span {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .22);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.hero-dates { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hero-dates div {
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.08);
}
.hero-dates span { display: block; font-size: 11px; opacity: .75; }
.hero-dates b { display: block; margin-top: 5px; font-size: 13px; font-weight: 800; }

.card {
  background: #fff;
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; }
.pool {
  font-size: 12px;
  font-weight: 700;
  color: #fde68a;
  background: rgba(253, 230, 138, .12);
  padding: 4px 8px;
  border-radius: 999px;
}

.facts li, .fact-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li:last-child, .fact-row:last-child { border-bottom: 0; }
.facts span, .fact-key { width: 78px; color: var(--muted); flex-shrink: 0; }
.facts b, .fact-val { flex: 1; font-weight: 700; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}
.steps li:last-child { padding-bottom: 0; }
.steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: #dbeafe;
}
.steps i {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: #eff6ff;
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  border: 1px solid #dbeafe;
}
.steps strong { display: block; font-size: 14px; }
.steps p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.65; }
.steps em { font-style: normal; color: #1d4ed8; font-weight: 700; }

.prize {
  background: linear-gradient(165deg, #0b1224 0%, #172554 55%, #1e3a8a 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .18);
}
.prize h3 { color: #fff; }
.prize-row { display: flex; gap: 8px; }
.prize-item {
  flex: 1;
  text-align: center;
  padding: 12px 6px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
}
.prize-item.gold {
  background: linear-gradient(180deg, rgba(253,230,138,.2), rgba(255,255,255,.05));
  box-shadow: inset 0 0 0 1px rgba(253,230,138,.28);
}
.prize-item .medal { font-size: 26px; line-height: 1; }
.prize-item .name { display: block; margin-top: 6px; font-size: 12px; font-weight: 800; opacity: .92; }
.prize-item .cash { display: block; margin-top: 6px; font-size: 16px; color: #fde68a; font-weight: 800; letter-spacing: .02em; }
.prize-item .extra { display: block; margin-top: 4px; font-size: 10px; color: #cbd5e1; line-height: 1.4; }
.prize-note {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.5;
}

.form label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 700; }
.form input, .form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #f8fafc;
}
.form textarea { min-height: 88px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 0 0 10px; }
.code {
  margin: 10px 0 0; padding: 12px; border-radius: 12px; background: #0f172a; color: #e2e8f0;
  font-size: 11px; line-height: 1.55; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

.api {
  border-radius: 14px;
  background: #0f172a;
  overflow: hidden;
}
.api-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.method {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
}
.api-head code {
  flex: 1;
  min-width: 0;
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}
.copy-btn {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.api-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}
.api-fields span {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #93c5fd;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.api-sign {
  margin: 0;
  padding: 10px 12px 12px;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

.keys { margin-top: 10px; padding: 12px; border-radius: 12px; background: #eff6ff; font-size: 13px; }
.keys b { display: block; margin-top: 6px; word-break: break-all; }
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.rank-n { width: 28px; font-weight: 800; color: #94a3b8; }
.rank-row.is-1 .rank-n { color: #d97706; }
.rank-row.is-2 .rank-n { color: #64748b; }
.rank-row.is-3 .rank-n { color: #b45309; }
.rank-main { flex: 1; min-width: 0; }
.rank-main .n { font-size: 15px; font-weight: 800; }
.rank-main .m { margin-top: 3px; font-size: 12px; color: var(--muted); }
.rank-score { text-align: right; font-size: 12px; color: #334155; font-weight: 700; line-height: 1.45; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 8px; padding: 10px 14px calc(10px + var(--safe-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.btn {
  flex: 1; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; border: 0;
}
.btn.primary {
  background: linear-gradient(180deg, #4c8dff, #3478f6);
  color: #fff;
  box-shadow: 0 6px 14px rgba(52, 120, 246, .28);
}
.btn.ghost {
  background: #fff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.toast {
  position: fixed; left: 50%; top: 46%; transform: translate(-50%,-50%);
  background: rgba(15,23,42,.88); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 40;
}
.empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; }
