:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #737373;
  --line: #e8e8e8;
  --soft: #f7f7f7;
  --green: #20a765;
  --green-soft: #e9f8f0;
  --danger: #b33a3a;
  --shadow: 0 22px 60px rgba(20,20,20,.10);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: #fff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.site-shell { min-height: 100vh; display: flex; flex-direction: column; padding: 24px clamp(18px,4vw,64px) 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--ink); font-size: 10px; letter-spacing: 0; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link, .nav-button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: #5e5e5e; background: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; cursor: pointer; }
.nav-link:hover, .nav-button:hover { color: var(--ink); border-color: #aaa; }
.nav-link.primary { color: #fff; border-color: var(--ink); background: var(--ink); }
.progress-track { height: 4px; overflow: hidden; margin-top: 18px; border-radius: 999px; background: #f0f0f0; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--ink); transition: width .4s ease; }
.page-main { width: min(1120px,100%); flex: 1; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; padding: 46px 0 76px; }

.hero { text-align: center; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 12px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(32px,5vw,58px); line-height: 1.03; letter-spacing: -.05em; }
.hero-copy { max-width: 620px; margin: 14px auto 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.selector-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; width: min(820px,100%); margin: 42px auto 0; }
.cup-entry { position: relative; min-height: 250px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: 0 10px 32px rgba(20,20,20,.05); transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease; }
.cup-entry:hover { transform: translateY(-5px); border-color: #c9c9c9; box-shadow: var(--shadow); }
.cup-entry::after { content: ""; position: absolute; right: -55px; bottom: -75px; width: 220px; aspect-ratio: 1; border-radius: 50%; background: var(--entry-gradient); opacity: .15; }
.cup-index { position: relative; z-index: 1; color: var(--green); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.cup-entry h2 { position: relative; z-index: 1; margin: 0; font-size: clamp(28px,4vw,42px); letter-spacing: -.045em; }
.cup-action { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 800; }
.cup-arrow { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--ink); font-size: 16px; }
.selector-tools { display: flex; justify-content: center; gap: 9px; margin-top: 24px; flex-wrap: wrap; }
.small-note { margin: 14px 0 0; color: #999; font-size: 11px; text-align: center; }

.game-head { margin-bottom: 34px; text-align: center; }
.game-head h1 { font-size: clamp(30px,4vw,50px); }
.game-hint { margin: 11px 0 0; color: var(--muted); font-size: 14px; }
.match-area { position: relative; animation: rise .4s ease both; }
.cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(18px,3vw,40px); width: min(850px,100%); margin: 0 auto; align-items: start; }
.cards.four { grid-template-columns: repeat(4,minmax(0,1fr)); width: min(1120px,100%); gap: clamp(12px,1.7vw,24px); }
.star-card { position: relative; min-width: 0; border: 0; padding: 0; color: inherit; background: transparent; text-align: center; cursor: pointer; outline: none; transition: opacity .42s ease, filter .42s ease, transform .42s ease; }
.portrait-shell { position: relative; transition: transform .42s cubic-bezier(.22,1,.36,1); }
.portrait { position: relative; aspect-ratio: 4/5; overflow: hidden; border: 3px solid transparent; border-radius: 22px; background: var(--card-gradient); box-shadow: 0 8px 26px rgba(20,20,20,.06); transition: border-color .28s ease, box-shadow .35s ease; }
.portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.94); }
.initials { font-size: clamp(38px,7vw,76px); font-weight: 900; letter-spacing: -.06em; text-shadow: 0 4px 18px rgba(0,0,0,.12); }
.cards.four .initials { font-size: clamp(28px,4vw,50px); }
.slot-chip { position: absolute; z-index: 2; top: 13px; left: 13px; padding: 7px 9px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; color: #fff; background: rgba(0,0,0,.22); font-size: 10px; font-weight: 900; backdrop-filter: blur(8px); }
.choice-icon { position: absolute; z-index: 4; top: -17px; left: 50%; width: 42px; height: 42px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 50%; color: #fff; background: var(--green); box-shadow: 0 8px 22px rgba(32,167,101,.28); font-size: 22px; font-weight: 900; opacity: 0; transform: translate(-50%,8px) scale(.55); transition: opacity .25s ease, transform .4s ease; }
.star-name { margin-top: 15px; font-size: clamp(16px,2vw,21px); font-weight: 800; letter-spacing: -.02em; }
.cards.four .star-name { font-size: clamp(14px,1.4vw,18px); }
.star-card:hover:not(.selected):not(.faded) .portrait-shell { transform: translateY(-5px); }
.star-card:focus-visible .portrait { outline: 3px solid var(--ink); outline-offset: 4px; }
.star-card.selected .portrait-shell { transform: scale(1.045) translateY(-4px); }
.star-card.selected .portrait { border-color: var(--green); box-shadow: 0 24px 54px rgba(32,167,101,.18); }
.star-card.selected .choice-icon { opacity: 1; transform: translate(-50%,0) scale(1); }
.star-card.faded { opacity: .22; filter: grayscale(.65); transform: scale(.975); }
.vs { position: absolute; left: 50%; top: 51%; z-index: 5; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: #777; background: #fff; box-shadow: 0 8px 24px rgba(20,20,20,.07); font-size: 10px; font-weight: 900; transform: translate(-50%,-50%); }
.action-bar { position: fixed; z-index: 20; right: clamp(18px,4vw,64px); bottom: 26px; display: flex; align-items: center; gap: 12px; }
.choice-label { color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .2s ease; }
.action-bar.ready .choice-label { opacity: 1; }
.next-button, .solid-button { border: 0; border-radius: 999px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 900; letter-spacing: .05em; cursor: pointer; }
.next-button { min-width: 116px; padding: 16px 21px; opacity: 0; pointer-events: none; transform: translateY(12px); box-shadow: 0 12px 30px rgba(20,20,20,.18); transition: opacity .25s ease, transform .3s ease; }
.action-bar.ready .next-button { opacity: 1; pointer-events: auto; transform: none; }
.sync-note { position: fixed; left: 50%; bottom: 24px; z-index: 19; max-width: min(520px,80vw); padding: 9px 13px; border: 1px solid #f0d7a9; border-radius: 999px; color: #805c17; background: #fff9ec; font-size: 11px; transform: translateX(-50%); }

.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; background: rgba(20,20,20,.34); backdrop-filter: blur(8px); }
.modal.show { display: grid; }
.dialog { width: min(1040px,100%); max-height: 90vh; overflow: auto; border-radius: 24px; background: #fff; box-shadow: 0 32px 90px rgba(0,0,0,.22); animation: rise .3s ease both; }
.dialog-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 23px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(12px); }
.dialog-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; gap: 7px; }
.round-button { padding: 10px 15px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 11px; font-weight: 900; cursor: pointer; }
.round-button.dark { color: #fff; border-color: var(--ink); background: var(--ink); }
.upload-grid { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 13px; padding: 23px; }
.upload-slot { position: relative; min-width: 0; aspect-ratio: 4/5; overflow: hidden; border: 2px dashed #d7d7d7; border-radius: 14px; background: #fafafa; cursor: pointer; outline: none; transition: border-color .2s ease, transform .2s ease; }
.upload-slot.dragging { border-color: var(--green); transform: scale(1.025); }
.upload-slot img { width: 100%; height: 100%; display: block; object-fit: cover; }
.upload-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 5px; color: #999; text-align: center; font-size: 9px; font-weight: 900; }
.upload-plus { color: #555; font-size: 24px; font-weight: 300; }
.upload-number { position: absolute; top: 7px; left: 7px; padding: 5px 7px; border-radius: 999px; color: #fff; background: rgba(0,0,0,.62); font-size: 9px; font-weight: 900; }
.name-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; padding: 23px; }
.name-row { display: grid; grid-template-columns: 40px minmax(0,1fr); align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 13px; }
.name-row:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.name-number { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--ink); font-size: 10px; font-weight: 900; }
.name-input { width: 100%; min-width: 0; border: 0; outline: 0; font-weight: 750; }

.result-view { animation: rise .55s ease both; }
.result-board { position: relative; overflow: hidden; padding: 34px 25px 28px; border: 1px solid var(--line); border-radius: 28px; background: radial-gradient(circle at 50% 55%,rgba(32,167,101,.07),transparent 28%),#fff; box-shadow: 0 24px 70px rgba(20,20,20,.08); text-align: center; }
.result-heading h1 { font-size: clamp(28px,3.5vw,44px); }
.result-heading p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.bracket-scroll { overflow-x: auto; margin-top: 27px; padding-bottom: 5px; }
.bracket-layout { min-width: 1010px; display: grid; grid-template-columns: minmax(0,1fr) 230px minmax(0,1fr); gap: 20px; }
.bracket-side { min-width: 0; display: grid; grid-template-columns: 1.45fr 1.25fr 1fr; gap: 16px; }
.bracket-side.right { grid-template-columns: 1fr 1.25fr 1.45fr; }
.bracket-round { min-width: 0; height: 510px; display: flex; flex-direction: column; }
.round-title { height: 23px; margin: 0; color: #999; font-size: 8px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.node-stack { min-height: 0; flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 4px; }
.result-node { position: relative; min-width: 0; height: 34px; display: flex; align-items: center; gap: 7px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 8px; color: #888; background: #fafafa; box-shadow: 0 4px 12px rgba(20,20,20,.04); }
.result-node.advanced { color: var(--ink); border-color: #b9dfcc; background: #f2fbf6; }
.result-node.finalist { height: 40px; color: var(--ink); border-color: var(--green); background: var(--green-soft); }
.result-thumb { width: 23px; height: 23px; flex: 0 0 auto; overflow: hidden; display: grid; place-items: center; border-radius: 5px; color: #fff; background: var(--thumb-gradient); font-size: 8px; font-weight: 900; }
.result-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.result-name { min-width: 0; overflow: hidden; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.bracket-side.left .bracket-round:not(:last-child) .result-node::after,.bracket-side.right .bracket-round:not(:first-child) .result-node::before { content: ""; position: absolute; top: 50%; width: 17px; border-top: 1px solid #d9d9d9; }
.bracket-side.left .bracket-round:not(:last-child) .result-node::after { left: 100%; }
.bracket-side.right .bracket-round:not(:first-child) .result-node::before { right: 100%; }
.result-center { min-width: 0; height: 510px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 23px; }
.final-matchup { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; margin-bottom: 18px; }
.final-name { max-width: 85px; overflow: hidden; color: #666; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.final-vs { color: #aaa; font-size: 8px; font-weight: 900; }
.result-crown { position: relative; z-index: 2; margin-bottom: -8px; font-size: 34px; transform: rotate(7deg); }
.winner-portrait { width: 126px; aspect-ratio: 4/5; overflow: hidden; display: grid; place-items: center; border: 3px solid var(--green); border-radius: 23px; color: #fff; background: var(--winner-gradient); box-shadow: 0 0 0 7px rgba(32,167,101,.07),0 18px 45px rgba(20,20,20,.14); font-size: 34px; font-weight: 900; }
.winner-portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.champion-badge { margin-top: 15px; padding: 7px 18px; border-radius: 999px; color: #fff; background: var(--green); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.winner-name { max-width: 210px; margin-top: 9px; font-size: 19px; font-weight: 900; letter-spacing: -.025em; }
.play-again { margin-top: 26px; padding: 14px 20px; }

.leader-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.leader-head h1 { font-size: clamp(34px,5vw,56px); }
.filter-tabs { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-tab { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: #777; background: #fff; font-size: 10px; font-weight: 900; cursor: pointer; }
.filter-tab.active { color: #fff; border-color: var(--ink); background: var(--ink); }
.leader-status { min-height: 260px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.status-box h2 { margin: 0; color: var(--ink); font-size: 20px; }
.status-box p { margin: 8px 0 16px; font-size: 12px; }
.spinner { width: 30px; height: 30px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
.leader-sections { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
.leader-panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 10px 32px rgba(20,20,20,.04); }
.leader-panel h2 { margin: 0 0 17px; font-size: 17px; letter-spacing: -.02em; }
.rank-list { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 28px 43px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 9px; border-radius: 13px; background: var(--soft); }
.rank-number { color: #999; font-size: 11px; font-weight: 900; text-align: center; }
.rank-number.top { color: var(--green); }
.rank-image { width: 43px; height: 43px; overflow: hidden; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--rank-gradient); font-size: 11px; font-weight: 900; }
.rank-image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.rank-meta { min-width: 0; }
.rank-name { overflow: hidden; font-size: 12px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.rank-cup { margin-top: 3px; color: #999; font-size: 9px; font-weight: 750; }
.rank-count { color: var(--green); font-size: 16px; font-weight: 900; }
.rank-label { display: block; color: #999; font-size: 8px; font-weight: 800; text-align: right; }
.local-label { display: inline-flex; margin-top: 18px; padding: 6px 9px; border-radius: 999px; color: #82621f; background: #fff7e3; font-size: 9px; font-weight: 850; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 150; max-width: min(520px,86vw); padding: 11px 15px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 11px; font-weight: 750; transform: translateX(-50%); animation: rise .25s ease both; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .site-shell { padding: 18px 15px 28px; }
  .brand-title { display: none; }
  .nav { gap: 5px; }
  .nav-link, .nav-button { padding: 8px 9px; font-size: 9px; }
  .page-main { justify-content: flex-start; padding-top: 45px; }
  .selector-grid { grid-template-columns: 1fr; margin-top: 30px; }
  .cup-entry { min-height: 190px; }
  .cards { gap: 13px; }
  .cards.four { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px 12px; }
  .portrait { border-width: 2px; border-radius: 16px; }
  .choice-icon { width: 36px; height: 36px; top: -14px; font-size: 18px; }
  .vs { width: 36px; height: 36px; }
  .choice-label { display: none; }
  .action-bar { right: 15px; bottom: 17px; }
  .sync-note { bottom: 76px; }
  .modal { padding: 9px; }
  .dialog { max-height: 95vh; border-radius: 18px; }
  .dialog-head { padding: 16px 14px; }
  .upload-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; padding: 14px; }
  .name-grid { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .result-board { margin: 0 -5px; padding: 25px 13px 21px; border-radius: 20px; }
  .bracket-scroll { margin-right: -13px; margin-left: -13px; padding: 0 13px 5px; }
  .leader-head { display: block; }
  .filter-tabs { margin-top: 20px; }
  .leader-sections { grid-template-columns: 1fr; }
  .leader-panel { padding: 16px 13px; }
}

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