:root {
  --paper: #f6f3ee;
  --paper-deep: #eee9e0;
  --ink: #17222b;
  --muted: #71808a;
  --line: rgba(23, 34, 43, .12);
  --coral: #e85f4a;
  --coral-dark: #c94838;
  --teal: #2f8b82;
  --yellow: #f2bd4d;
  --white: #fffdfa;
  --shadow: 0 14px 36px rgba(35, 42, 48, .10);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding: 18px 18px calc(94px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 18px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--white); background: var(--ink); font-size: 20px; font-weight: 800; border-radius: 13px; transform: rotate(-4deg); }
.brand-copy { min-width: 0; }
.eyebrow, .section-kicker { margin: 0; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.brand-copy h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.1; letter-spacing: 0; }
.live-state { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--teal); font-size: 11px; font-weight: 700; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(47,139,130,.13); }

.hero-strip { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 20px; border-radius: 20px; background: var(--ink); color: var(--white); box-shadow: var(--shadow); }
.hero-kicker { margin: 0; font-size: 18px; line-height: 1.4; font-weight: 800; }
.hero-subtitle { margin: 7px 0 0; color: rgba(255,253,250,.68); font-size: 12px; }
.hero-note { flex: 0 0 auto; padding: 9px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; color: rgba(255,253,250,.72); font-size: 10px; line-height: 1.4; text-align: right; }
.hero-note strong { display: block; color: var(--yellow); font-size: 12px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 18px 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--line); }
.stat-item { padding: 12px 10px; background: rgba(255,253,250,.68); }
.stat-label { display: block; color: var(--muted); font-size: 10px; }
.stat-item strong { display: block; margin-top: 2px; font-size: 21px; line-height: 1.1; }
.stat-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.stat-accent strong { color: var(--coral); }

.view-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.view-tab { position: relative; border: 0; padding: 0 0 12px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; }
.view-tab.is-active { color: var(--ink); }
.view-tab.is-active::after { content: ""; position: absolute; height: 3px; left: 0; right: 0; bottom: -1px; border-radius: 3px 3px 0 0; background: var(--coral); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 4px 0 0; font-size: 22px; line-height: 1.15; }
.refresh-stamp, .count-note { color: var(--muted); font-size: 11px; }

.podium { display: grid; grid-template-columns: 1.06fr .94fr; gap: 12px; margin-bottom: 16px; }
.podium-card { position: relative; overflow: hidden; min-height: 226px; border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.podium-card:first-child { grid-row: span 2; min-height: 300px; }
.podium-image { width: 100%; height: 100%; min-height: 226px; object-fit: contain; display: block; background: var(--paper-deep); }
.podium-card, .rank-row { cursor: zoom-in; }
.podium-card:first-child .podium-image { min-height: 300px; }
.podium-card::after { content: ""; position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgba(10,17,22,.82)); pointer-events: none; }
.podium-meta { position: absolute; z-index: 1; left: 14px; right: 14px; bottom: 14px; color: var(--white); }
.rank-badge { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-bottom: 8px; border-radius: 9px; color: var(--ink); background: var(--yellow); font-size: 14px; font-weight: 800; }
.podium-card:nth-child(2) .rank-badge { background: #d4dce0; }
.podium-card:nth-child(3) .rank-badge { background: #d99b6d; }
.podium-meta h3 { margin: 0; font-size: 19px; line-height: 1.2; }
.podium-meta p { margin: 4px 0 0; color: rgba(255,253,250,.76); font-size: 11px; }
.podium-votes { margin-top: 8px; font-size: 13px; font-weight: 800; }
.podium-vote-button { margin-top: 10px; border: 0; border-radius: 10px; padding: 8px 12px; color: var(--ink); background: var(--yellow); font-size: 11px; font-weight: 800; }
.podium-vote-button:disabled { color: var(--muted); background: rgba(255,253,250,.65); }

.ranking-list { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 38px 76px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,253,250,.76); }
.rank-number { color: var(--muted); font-size: 15px; font-weight: 800; text-align: center; }
.rank-photo { width: 76px; height: 76px; object-fit: contain; border-radius: 13px; background: var(--paper-deep); }
.rank-main { min-width: 0; }
.rank-main h3 { margin: 0; font-size: 15px; line-height: 1.25; }
.rank-main p { display: -webkit-box; overflow: hidden; margin: 5px 0 7px; color: var(--muted); font-size: 11px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.publisher { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.publisher img { width: 18px; height: 18px; border-radius: 50%; object-fit: contain; background: var(--paper-deep); }
.publisher-avatar-fallback { display: inline-block; width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; background: #000; }
.vote-box { display: flex; flex-direction: column; align-items: end; gap: 7px; }
.vote-count { color: var(--ink); font-size: 15px; font-weight: 800; white-space: nowrap; }
.vote-button { border: 0; border-radius: 10px; padding: 8px 10px; color: var(--white); background: var(--coral); font-size: 11px; font-weight: 800; white-space: nowrap; }
.vote-button:disabled { color: var(--muted); background: var(--paper-deep); cursor: not-allowed; }

.empty-state { padding: 44px 18px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; }
.empty-avatar { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 50%; color: var(--coral); background: rgba(232,95,74,.1); font-size: 28px; }
.empty-state h3 { margin: 0; font-size: 16px; }
.empty-state p { margin: 7px 0 15px; color: var(--muted); font-size: 12px; }

.entry-form { padding-bottom: 20px; }
.photo-upload input { display: none; }
.upload-box { display: grid; place-items: center; width: 100%; aspect-ratio: 1.25 / 1; overflow: hidden; border: 1px dashed rgba(23,34,43,.24); border-radius: 18px; background: var(--paper-deep); cursor: pointer; }
.upload-box img { width: 100%; height: 100%; object-fit: contain; background: var(--paper-deep); }
.preview-button { display: block; width: 100%; margin-top: 8px; border: 0; border-radius: 10px; padding: 10px; color: var(--teal); background: rgba(47,139,130,.1); font-size: 11px; font-weight: 800; }
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.upload-placeholder small { font-size: 10px; }
.upload-plus { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--white); background: var(--coral); font-size: 25px; line-height: 1; }
.field-label { display: block; margin: 18px 0 7px; font-size: 12px; font-weight: 800; }
.field-hint { margin-left: 8px; color: var(--muted); font-size: 10px; }
.text-input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; outline: none; color: var(--ink); background: rgba(255,253,250,.78); font-size: 14px; }
.text-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,139,130,.12); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.publisher-heading { margin-top: 18px; }
.publisher-heading .field-label { margin: 0; display: inline; }
.publisher-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.publisher-avatar-preview { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #000; overflow: hidden; }
.publisher-avatar-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.publisher-avatar-preview .publisher-avatar-fallback { width: 100%; height: 100%; border-radius: 50%; }
.publisher-input { min-width: 0; }
.avatar-upload-label { display: inline-flex; align-items: center; margin-top: 10px; border-radius: 10px; padding: 8px 11px; color: var(--teal); background: rgba(47,139,130,.1); font-size: 11px; font-weight: 800; cursor: pointer; }
.avatar-upload-input { display: block; width: 100%; margin-top: 5px; color: var(--muted); font-size: 10px; }
.form-error { margin: 12px 0 0; color: var(--coral-dark); font-size: 11px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 12px; padding: 13px 17px; color: var(--white); background: var(--coral); font-size: 13px; font-weight: 800; box-shadow: 0 8px 16px rgba(232,95,74,.2); }
.primary-button:active { transform: translateY(1px); }
.submit-button { width: 100%; margin-top: 20px; }
.primary-button:disabled { opacity: .55; cursor: wait; }

.rules-list { display: grid; gap: 1px; border-top: 1px solid var(--line); }
.rule-row { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.rule-num { color: var(--coral); font-size: 13px; font-weight: 800; }
.rule-row strong { font-size: 14px; }
.rule-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.local-admin-panel { margin: 22px 0 6px; padding: 16px; border: 1px solid rgba(232,95,74,.28); border-radius: 16px; background: rgba(232,95,74,.06); }
.admin-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.admin-heading h3 { margin: 4px 0 0; font-size: 16px; }
.admin-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.admin-actions { display: flex; flex: 0 0 auto; flex-direction: column; gap: 6px; }
.admin-button { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--ink); background: var(--white); font-size: 10px; font-weight: 800; white-space: nowrap; }
.admin-button.admin-danger { color: var(--coral-dark); border-color: rgba(232,95,74,.32); }
.admin-list { display: grid; gap: 6px; margin-top: 14px; }
.admin-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 28px 66px 28px; gap: 5px; align-items: center; }
.admin-rank { color: var(--coral); font-size: 11px; font-weight: 800; text-align: center; }
.admin-name { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.admin-step { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white); font-size: 16px; line-height: 1; }
.admin-count { width: 66px; height: 28px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white); font-size: 12px; text-align: center; }
.admin-empty { margin: 14px 0 0; color: var(--muted); font-size: 11px; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; gap: 10px; padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(246,243,238,.95); backdrop-filter: blur(14px); }
.bottom-item { display: flex; min-width: 88px; flex-direction: column; align-items: center; gap: 3px; border: 0; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; }
.bottom-item.is-active { color: var(--coral); }
.nav-icon { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 8px; font-size: 11px; font-weight: 800; }
.bottom-item.is-active .nav-icon { color: var(--white); background: var(--coral); }
.nav-plus { border: 1px solid currentColor; font-size: 19px; line-height: 1; }

.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translate(-50%, 15px); max-width: calc(100% - 40px); padding: 10px 14px; border-radius: 10px; color: var(--white); background: rgba(23,34,43,.92); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

.image-viewer { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(12,18,23,.94); }
.image-viewer[hidden] { display: none; }
body.viewer-open { overflow: hidden; }
.viewer-figure { display: flex; width: min(100%, 680px); height: min(88vh, 820px); margin: 0; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.viewer-figure img { width: 100%; height: calc(100% - 34px); object-fit: contain; }
.viewer-figure figcaption { color: rgba(255,253,250,.82); font-size: 12px; text-align: center; }
.viewer-close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; color: var(--white); background: rgba(255,255,255,.12); font-size: 28px; line-height: 1; }

@media (min-width: 640px) {
  .app-shell { padding-right: 28px; padding-left: 28px; }
  .bottom-nav { right: auto; left: 50%; width: min(100%, 720px); transform: translateX(-50%); border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
