:root {
  --wine: #8f0036;
  --wine-dark: #57001f;
  --amber: #995c00;
  --gold: #d8a22a;
  --ink: #302d31;
  --muted: #6e6870;
  --paper: #f4f3f1;
  --panel: #ffffff;
  --line: #dedbd8;
  --good: #16794e;
  --bad: #bd2c2c;
  --shadow: 0 18px 48px rgba(67, 33, 45, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: "Noto Serif SC", "Songti SC", SimSun, serif; background:
  radial-gradient(circle at 10% 0%, rgba(143,0,54,.08), transparent 26rem),
  linear-gradient(135deg, #f6f5f3, #ececea); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.topbar { min-height: 72px; padding: 10px clamp(18px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: #fff; background: linear-gradient(100deg, var(--wine-dark), var(--wine) 55%, var(--amber)); box-shadow: 0 4px 18px #37001544; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #fff8; transform: rotate(45deg); font-size: 24px; }
.brand-mark::first-letter { transform: rotate(-45deg); }
.brand b, .brand small { display: block; }
.brand b { font-size: 20px; letter-spacing: .14em; }
.brand small { margin-top: 2px; opacity: .75; font-family: system-ui, sans-serif; font-size: 11px; }
.topbar nav { display: flex; gap: 10px; }
.topbar nav a { padding: 9px 14px; border: 1px solid #fff5; border-radius: 999px; color: #fff; text-decoration: none; font-family: system-ui, sans-serif; font-size: 14px; }

.home-shell, .page-shell { width: min(1180px, calc(100% - 32px)); margin: 38px auto 70px; }
.hero-panel { min-height: 420px; padding: clamp(34px, 7vw, 84px); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; position: relative; overflow: hidden; color: #fff; border-radius: 24px; background: linear-gradient(120deg, #4f001b, #8f0036 58%, #995c00); box-shadow: var(--shadow); }
.hero-panel::after { content: "財"; position: absolute; right: 4%; bottom: -30%; font-size: min(40vw, 430px); color: #fff; opacity: .07; line-height: 1; }
.eyebrow { margin: 0 0 10px; color: var(--amber); font-family: system-ui, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.hero-panel .eyebrow { color: #ffd992; }
.hero-panel h1 { margin: 0; font-size: clamp(44px, 8vw, 90px); line-height: .98; letter-spacing: .04em; }
.hero-panel p:not(.eyebrow) { max-width: 620px; margin: 24px 0; font-family: system-ui, sans-serif; font-size: clamp(16px, 2vw, 20px); line-height: 1.7; opacity: .86; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; z-index: 1; }
.primary-button, .secondary-button, .redeem-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 11px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; font-family: system-ui, sans-serif; font-weight: 750; }
.primary-button, .redeem-button { color: #fff; background: var(--wine); box-shadow: 0 8px 22px #8f003644; }
.hero-panel .primary-button { color: var(--wine-dark); background: #fff; }
.secondary-button { color: var(--wine); border-color: #ba8a9a; background: #fff; }
.hero-panel .secondary-button { color: #fff; border-color: #fff8; background: transparent; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 18px; }
.feature-grid article { padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 22px #0000000b; }
.feature-grid b, .feature-grid span { display: block; }
.feature-grid b { color: var(--wine); font-size: 30px; }
.feature-grid span { margin-top: 8px; color: var(--muted); font-family: system-ui, sans-serif; line-height: 1.5; }
.card-rules { scroll-margin-top: 20px; }
.card-rules b { font-size: 24px; }
.visitor-guide { margin-top: 18px; padding: 28px; display: grid; grid-template-columns: minmax(220px, .8fr) 2fr; gap: 36px; align-items: center; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 22px #0000000b; }
.visitor-guide h2 { margin: 0; color: var(--wine); font-size: clamp(26px, 3vw, 38px); }
.visitor-guide ol { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; list-style: none; counter-reset: guide-step; }
.visitor-guide li { position: relative; min-height: 112px; padding: 18px 16px 16px 52px; border-radius: 13px; background: #f7f2f4; counter-increment: guide-step; }
.visitor-guide li::before { content: counter(guide-step); position: absolute; left: 15px; top: 16px; display: grid; place-items: center; width: 26px; height: 26px; color: #fff; border-radius: 50%; background: var(--wine); font: 800 13px system-ui, sans-serif; }
.visitor-guide b, .visitor-guide span { display: block; }
.visitor-guide span { margin-top: 7px; color: var(--muted); font-family: system-ui, sans-serif; line-height: 1.55; }
.demo-note { padding: 14px 18px; border-left: 4px solid var(--gold); color: #6d5315; background: #fff8df; font-family: system-ui, sans-serif; }

.section-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 24px; }
.section-heading h1 { margin: 0; color: var(--wine); font-size: clamp(34px, 5vw, 58px); }
.section-heading > p { max-width: 520px; margin: 0; color: var(--muted); font-family: system-ui, sans-serif; line-height: 1.7; }
.demo-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.demo-card { display: grid; justify-items: center; gap: 7px; padding: 18px; color: var(--wine); text-decoration: none; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 7px 20px #0000000a; transition: transform .15s ease, box-shadow .15s ease; }
.demo-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.demo-card img { width: 150px; max-width: 100%; aspect-ratio: 1; }
.demo-card span { color: var(--muted); font-family: system-ui, sans-serif; }

.vote-body { background: linear-gradient(160deg, #f1e8eb, #f5f3ee 50%, #eadfcb); }
.vote-shell { width: min(640px, calc(100% - 24px)); margin: 26px auto 64px; }
.vote-card { overflow: hidden; border: 1px solid #d9ced2; border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.centered-card { min-height: 360px; padding: 44px 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.centered-card h1 { margin: 10px 0; color: var(--wine); font-size: 36px; }
.centered-card p { color: var(--muted); font-family: system-ui, sans-serif; line-height: 1.7; }
.spinner { width: 50px; height: 50px; border: 5px solid #ead5dd; border-top-color: var(--wine); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-icon { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; color: #fff; font: 700 46px system-ui, sans-serif; }
.status-icon.good { background: var(--good); }
.status-icon.bad { background: var(--bad); }
.result-summary { padding: 14px 18px; color: var(--ink) !important; border-radius: 12px; background: #f2f6f3; font-weight: 700; }
.card-ticket { padding: 15px 22px; display: flex; justify-content: space-between; gap: 20px; color: #fff; background: linear-gradient(100deg, var(--wine-dark), var(--wine), var(--amber)); font-family: system-ui, sans-serif; }
.card-ticket span { opacity: .8; }
.vote-copy { padding: 28px 24px 12px; }
.vote-copy h1 { margin: 0; color: var(--wine); font-size: 34px; }
.vote-copy > p:last-child { margin: 10px 0 0; color: var(--muted); font-family: system-ui, sans-serif; line-height: 1.65; }
.search-field, .transfer-grid label, .admin-panel label { display: grid; gap: 7px; font-family: system-ui, sans-serif; font-weight: 700; }
.search-field { padding: 8px 24px 14px; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); border: 1px solid #cfc7ca; border-radius: 10px; background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--wine); box-shadow: 0 0 0 3px #8f00361a; }
.school-grid { max-height: 390px; padding: 0 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; overflow-y: auto; }
.school-choice { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.school-choice:hover { border-color: #b78296; }
.school-choice.selected { color: var(--wine); border: 2px solid var(--wine); background: #fff1f5; }
.school-choice .avatar { flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #deb8c6; border-radius: 50%; background: #fff; font-size: 19px; }
.avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.school-choice b { font-size: 14px; line-height: 1.35; }
.selection-note { margin: 12px 24px; padding: 11px 13px; color: var(--muted); border-radius: 10px; background: #f3f1f1; font-family: system-ui, sans-serif; }
.transfer-grid { padding: 10px 24px; display: grid; gap: 12px; }
.transfer-arrow { text-align: center; color: var(--wine); font-size: 28px; }
.warning-copy { margin: 0; padding: 12px; color: #754f00; border-radius: 10px; background: #fff4d6; font-family: system-ui, sans-serif; line-height: 1.5; }
.redeem-button { width: calc(100% - 48px); margin: 16px 24px 8px; min-height: 54px; font-size: 17px; }
.redeem-button:disabled { cursor: not-allowed; color: #8c8588; background: #d9d5d6; box-shadow: none; }
.once-note { margin: 6px 24px 24px; color: var(--muted); text-align: center; font-family: system-ui, sans-serif; font-size: 13px; }

.board-body { background: #efefed; }
.board-shell { width: min(1800px, calc(100% - 36px)); margin: 24px auto 40px; }
.board-heading { padding: 22px 26px; display: flex; justify-content: space-between; align-items: center; gap: 30px; border: 1px solid #d1cecb; background: #fff; }
.board-heading h1 { margin: 0; color: var(--wine); font-size: clamp(28px, 3vw, 52px); }
.board-meta { display: grid; justify-items: end; gap: 6px; font-family: system-ui, sans-serif; }
.board-meta small { color: var(--muted); }
.live-pill { padding: 5px 10px; color: #fff; border-radius: 999px; background: var(--good); font-size: 12px; font-weight: 800; }
.live-pill.preparing { background: var(--amber); }
.live-pill.closed { background: var(--bad); }
.live-pill.offline { background: #777; }
.leader-strip { margin-top: 10px; padding: 14px 22px; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; color: #5e4307; border: 1px solid #dfcb8a; background: linear-gradient(90deg, #fff6d8, #fffdf4); }
.leader-strip span { font-family: system-ui, sans-serif; }
.leader-strip b { color: var(--wine); font-size: 22px; }
.leader-school { min-width: 0; display: flex; align-items: center; gap: 12px; }
.leader-school .avatar { width: 46px; height: 46px; flex: 0 0 auto; overflow: hidden; border: 2px solid #b00647; border-radius: 50%; background: #fff; }
.leader-school > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-strip strong { font-size: 30px; }
.board-grid { margin-top: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.board-row { min-height: 66px; padding: 9px 13px; display: grid; grid-template-columns: 42px minmax(120px, 1fr) auto; gap: 10px; align-items: center; border: 1px solid #d8d5d2; background: #fff; }
.board-row.rank-one { border-color: #d9b95c; background: #fff8dc; }
.rank-number { color: var(--muted); text-align: center; font: 800 15px system-ui, sans-serif; }
.rank-number .medal { display: block; font-size: 18px; }
.school-name { min-width: 0; display: flex; align-items: center; gap: 10px; }
.school-name .avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; overflow: hidden; border: 2px solid #b00647; border-radius: 50%; background: #fff; }
.school-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fortune-box { min-width: 90px; text-align: right; }
.fortune-box strong { display: block; color: var(--wine); font-size: 28px; }
.fortune-box small { color: var(--muted); font-family: system-ui, sans-serif; }
.fortune-box strong.negative { color: #156094; }
.board-footer { margin-top: 10px; padding: 12px 16px; display: flex; justify-content: space-between; color: var(--muted); border-top: 1px solid #ccc; font-family: system-ui, sans-serif; font-size: 13px; }

.admin-shell { max-width: 1100px; }
.admin-panel, .admin-summary article { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 7px 20px #0000000a; }
.login-panel { max-width: 520px; margin: 0 auto; }
.login-panel p { color: var(--muted); font-family: system-ui, sans-serif; }
.admin-summary { margin-bottom: 16px; display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.admin-summary article { display: grid; align-content: start; gap: 12px; }
.admin-summary article > span { color: var(--muted); font-family: system-ui, sans-serif; }
.admin-summary article > b { color: var(--wine); font-size: 28px; }
.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.count-grid div { padding: 10px; border-radius: 10px; background: #f4f1f2; font-family: system-ui, sans-serif; }
.count-grid b, .count-grid span { display: block; }
.count-grid b { color: var(--wine); font-size: 20px; }
.admin-panel { margin-bottom: 16px; }
.admin-panel h2 { margin: 0 0 18px; color: var(--wine); }
.admin-form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.admin-form-grid .wide { grid-column: 1 / -1; }
.panel-title { display: flex; justify-content: space-between; align-items: center; }
.operation-log { display: grid; gap: 8px; }
.log-row { padding: 11px 12px; display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; border-radius: 10px; background: #f5f3f3; font-family: system-ui, sans-serif; font-size: 13px; }
.log-row time { color: var(--muted); }
.log-row code { color: var(--wine); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 20px); padding: 12px 18px; color: #fff; border-radius: 10px; background: #252225; opacity: 0; pointer-events: none; transition: .2s ease; font-family: system-ui, sans-serif; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .feature-grid, .board-grid { grid-template-columns: repeat(2, 1fr); }
  .visitor-guide { grid-template-columns: 1fr; }
  .admin-summary { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { min-height: 62px; padding: 8px 14px; }
  .brand small { display: none; }
  .brand b { font-size: 16px; }
  .brand-mark { width: 36px; height: 36px; font-size: 19px; }
  .topbar nav a { padding: 8px 10px; font-size: 12px; }
  .home-shell, .page-shell { width: min(100% - 20px, 1180px); margin-top: 18px; }
  .hero-panel { min-height: 380px; padding: 32px 24px; border-radius: 18px; }
  .feature-grid, .board-grid { grid-template-columns: 1fr; }
  .visitor-guide { padding: 22px 18px; gap: 22px; }
  .visitor-guide ol { grid-template-columns: 1fr; }
  .section-heading, .board-heading { align-items: flex-start; flex-direction: column; }
  .board-meta { justify-items: start; }
  .board-shell { width: calc(100% - 12px); margin: 12px auto 28px; }
  .board-heading { padding: 18px 16px; gap: 16px; }
  .leader-strip { padding: 13px 14px; gap: 10px; }
  .board-row { min-height: 72px; padding: 8px 9px; grid-template-columns: 22px minmax(0, 1fr) 54px; gap: 6px; }
  .rank-number { font-size: 13px; }
  .rank-number .medal { font-size: 15px; }
  .school-name { gap: 7px; }
  .school-name .avatar { width: 40px; height: 40px; }
  .school-name b { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; font-size: 14px; line-height: 1.28; }
  .fortune-box { min-width: 0; }
  .fortune-box strong { font-size: 24px; }
  .fortune-box small { font-size: 11px; }
  .school-grid { grid-template-columns: 1fr; }
  .leader-strip { grid-template-columns: 1fr auto; }
  .leader-strip span { grid-column: 1 / -1; }
  .admin-form-grid, .count-grid { grid-template-columns: 1fr; }
  .admin-form-grid .wide { grid-column: auto; }
  .log-row { grid-template-columns: 1fr; }
}
