/* SPARK IGNITION — clear type, flat surfaces, restrained geometry. */
:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #57595e;
  --paper: #ffffff;
  --ground: #f3f3f1;
  --line: #d4d4d0;
  --accent: #4c2e91;
  --accent-hover: #352065;
  --danger: #a51d27;
  --success: #17603c;
}
* { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif; font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.4; font-weight: 750; }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
button, .button { min-height: 48px; padding: 12px 20px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--ink); font-weight: 700; cursor: pointer; line-height: 1.5; touch-action: manipulation; }
button:hover, .button:hover { border-color: var(--ink); }
button:disabled { opacity: .55; cursor: default; }
button:disabled:hover { border-color: var(--line); }
.button { display: inline-flex; justify-content: space-between; align-items: center; gap: 20px; text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:disabled { cursor: wait; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
input:not([type="hidden"]) { width: 100%; min-width: 0; min-height: 52px; padding: 12px 14px; border: 1px solid #83858a; border-radius: 3px; background: #fff; color: var(--ink); font-size: 16px; line-height: 1.5; }
input::placeholder { color: #6b6d72; opacity: 1; }
label, .field-label { display: block; margin-bottom: 10px; font-weight: 700; font-size: 15px; }
.site-header { min-height: 80px; display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 20px clamp(20px, 5vw, 72px); border-bottom: 1px solid var(--line); background: #fff; }
.wordmark { font-size: 15px; font-weight: 850; letter-spacing: .09em; line-height: 1.5; white-space: nowrap; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-header a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
.event-caption { color: var(--muted); font-size: 13px; }
.section-rule { width: 44px; height: 5px; margin-bottom: 24px; background: var(--accent); }
.page-heading { margin-bottom: 28px; }
.page-heading h1, .login-main h1 { font-size: clamp(26px, 4vw, 36px); }
.page-intro { max-width: 760px; color: var(--muted); line-height: 1.9; margin: 0 0 32px; }
.notice, .error, .success { padding: 16px 18px; margin: 20px 0; border: 1px solid var(--line); border-left: 4px solid var(--ink); background: #fff; line-height: 1.7; }
.error { color: var(--danger); border-left-color: var(--danger); font-weight: 700; }
.success { color: var(--success); border-left-color: var(--success); font-weight: 700; }
.entry-page, .login-page, .completion-page { min-height: 100svh; background: #fff; }
.entry-main { width: min(100% - 48px, 520px); margin: clamp(44px, 8svh, 96px) auto 64px; }
.entry-main h1 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; font-size: clamp(46px, 9vw, 76px); line-height: 1.2; letter-spacing: -.04em; }
.entry-main h1 span { color: var(--accent); }
.entry-lead { margin-top: 24px; font-size: 22px; font-weight: 700; }
.entry-description { margin-top: 14px; color: var(--muted); }
.start-form { margin-top: 40px; }
.start-form button { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding: 17px 22px; min-height: 60px; font-size: 19px; letter-spacing: .06em; }
.entry-main > .button { width: 100%; margin-top: 20px; }
.login-main { width: min(100% - 48px, 440px); margin: clamp(44px, 9svh, 110px) auto 64px; }
.login-main form { margin-top: 36px; }
.login-main button { display: flex; justify-content: space-between; width: 100%; margin-top: 24px; }
/* Game: one place each for the question number, clock and answer. */
.question-page { min-height: 100svh; background: var(--ground); padding-bottom: env(safe-area-inset-bottom, 0px); }
.game-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px max(24px, calc((100vw - 1040px) / 2)); border-bottom: 1px solid var(--line); background: #fff; }
.live-time { flex-shrink: 0; text-align: right; }
.timer-label { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
.live-time strong { display: block; font-size: clamp(26px, 4vw, 36px); font-variant-numeric: tabular-nums; font-weight: 750; letter-spacing: -.03em; line-height: 1.25; }
.question-panel { width: min(100% - 48px, 1040px); margin: 24px auto; }
.question-heading { font-size: 22px; margin-bottom: 18px; }
.question-heading strong { font-size: 30px; color: var(--accent); }
.question-heading > span { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.image-frame { height: clamp(180px, calc(100svh - 365px), 560px); min-height: 180px; background: #fff; border: 1px solid var(--line); }
.image-zoom-trigger { display: flex; justify-content: center; align-items: center; position: relative; height: 100%; width: 100%; min-height: 0; padding: 16px 16px 40px; border: 0; border-radius: 0; background: #fff; }
.image-zoom-trigger:hover { background: #fff; outline: 1px solid var(--ink); outline-offset: -1px; }
.question-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.zoom-hint { position: absolute; right: 12px; bottom: 8px; display: flex; align-items: center; gap: 12px; padding: 2px 8px; color: var(--accent); background: #fff; font-size: 13px; font-weight: 700; }
.image-placeholder { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }
.answer-area { margin-top: 24px; }
.answer-controls { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 12px; }
.answer-controls input { min-height: 56px; }
.answer-controls button { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 56px; }
#message:empty { display: none; }
#message { margin: 16px 0 0; }
.hint-note { margin-top: 20px; font-size: 14px; color: var(--muted); }
/* Existing pinch/fullscreen behavior uses these same viewer hooks. */
html.image-viewer-open, body.image-modal-open { overflow: hidden; }
.image-modal { display: none; position: fixed; inset: 0; z-index: 1000; background: #151619; }
.image-modal.open { display: block; }
.image-modal-viewport { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; touch-action: none; }
.image-modal-viewport img { position: absolute; left: 50%; top: 50%; width: auto; height: auto; max-width: 94vw; max-height: 80svh; transform: translate(-50%, -50%); transform-origin: center; }
.image-modal-close { position: absolute; z-index: 1002; top: max(16px, env(safe-area-inset-top)); right: 16px; color: #fff; background: #202124; border-color: #8d8e93; }
.image-modal-close:hover { border-color: #fff; }
.image-modal-help { position: absolute; z-index: 1001; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 8px 16px; color: #fff; background: #202124; font-size: 13px; white-space: nowrap; pointer-events: none; }
.completion-main { width: min(100% - 48px, 600px); margin: 48px auto 64px; }
.completion-main h1 { color: var(--accent); font-size: clamp(56px, 10vw, 88px); line-height: 1.15; letter-spacing: -.04em; }
.congrats { margin-top: 24px; font-size: 18px; }
.clear-time-box { display: flex; flex-direction: column; gap: 10px; padding: 28px 0 32px; margin-top: 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.time-label { color: var(--muted); font-size: 14px; }
.clear-time { font-size: clamp(48px, 10vw, 76px); font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: -.04em; }
.personal-awards { display: grid; grid-template-columns: 1fr auto; align-items: center; padding-top: 24px; gap: 16px; }
.personal-awards > strong { font-size: 36px; }
.personal-awards > strong small { font-size: 16px; font-weight: 400; margin-left: 8px; }
.award-list { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.award-label { display: inline-block; color: var(--accent); font-weight: 750; font-size: 13px; line-height: 1.7; padding: 3px 9px; border: 1px solid var(--accent); border-radius: 2px; }
.prize-note { font-size: 14px; color: var(--muted); margin-top: 24px; }
.staff-check { margin: 32px 0 20px; font-weight: 700; }
.completion-main > .button { width: 100%; }
.results-main { width: min(100% - 48px, 1040px); margin: 48px auto 64px; }
.results-table-wrap { border-top: 2px solid var(--ink); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 20px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--ground); }
.rank-cell { width: 76px; font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.result-name { font-weight: 700; }
.you-label { display: block; font-size: 12px; font-weight: 700; color: var(--accent); margin-top: 4px; }
.is-me .rank-cell { border-left: 4px solid var(--accent); }
.result-record strong { font-size: 17px; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.result-record small { display: block; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
.award-cell { width: 230px; }
.award-cell .award-label { display: table; margin: 5px 0; }
.no-award { color: var(--muted); }
.empty-state { border-top: 1px solid var(--line); padding: 48px 0; }
.empty-state h2 { font-size: 22px; }
.empty-state p { color: var(--muted); margin-top: 14px; }
/* Staff: separated tasks and roomy, labeled fields. */
.wide { width: min(100% - 48px, 1120px); margin: 40px auto 80px; }
.staff-section { margin-top: 48px; }
.staff-section > h2, .staff-section-heading h2 { font-size: 24px; }
.staff-section > .page-intro { margin-top: 16px; }
.staff-section-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.state-label { font-size: 14px; font-weight: 700; border-left: 2px solid var(--accent); padding-left: 14px; }
.staff-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; margin-bottom: 24px; }
.danger-button { color: var(--danger); border-color: var(--danger); }
.danger-button:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.participant-table-wrap { max-width: 100%; overflow-x: auto; border-top: 2px solid var(--ink); }
.participant-table-wrap table { min-width: 480px; }
.participant-table-wrap th, .participant-table-wrap td { padding: 16px 20px; }
.participant-table-wrap td:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); border-radius: 2px; white-space: nowrap; }
.badge.clear { border-color: var(--success); color: var(--success); }
.qform { padding: 28px 32px 32px; margin: 24px 0; background: #fff; border: 1px solid var(--line); }
.qform h2 { margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 21px; }
.question-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.admin-image { display: block; max-width: 100%; width: auto; max-height: 240px; object-fit: contain; margin-bottom: 20px; }
input[type="file"] { font-size: 14px; padding: 10px; border-color: var(--line); }
input[type="file"]::file-selector-button { font: inherit; border: 1px solid #83858a; border-radius: 2px; background: #fff; padding: 8px 12px; margin-right: 12px; cursor: pointer; }
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; margin-bottom: 12px; }
.answer-row button { min-height: 52px; padding: 8px; font-size: 24px; font-weight: 400; }
.add-answer { margin-top: 4px; font-size: 14px; }
.bulk-save-bar { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; padding: 16px 0 max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--ground); }
.bulk-save-bar button { min-width: 240px; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
/* Stage: flat dark surface with clear, large records. */
.stage-body { min-height: 100svh; background: #18191d; color: #fff; }
.stage-body .site-header { background: #18191d; color: #fff; border-color: #45464c; }
.stage-body .site-header a { color: #fff; }
.stage-main { max-width: 1600px; padding: 40px clamp(20px, 4vw, 64px) 64px; margin: auto; }
.stage-heading { display: flex; align-items: center; gap: 20px; font-size: 32px; margin-bottom: 36px; }
.stage-heading > span { font-size: 12px; border: 1px solid #c4c4ca; padding: 4px 9px; letter-spacing: .08em; }
.stage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.stage-grid.is-final { grid-template-columns: 1fr; }
.stage-panel { min-width: 0; }
.stage-panel h2 { font-size: 20px; color: #dedee2; padding-bottom: 20px; border-bottom: 2px solid #96969e; }
.player, .rank { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 20px 0; border-bottom: 1px solid #45464c; font-size: 21px; }
.player strong, .rank strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.rank { grid-template-columns: 40px minmax(0, 1fr) auto; }
.rank b { font-size: 28px; }
.rank small { display: block; font-size: 12px; font-weight: 400; color: #d0d0d5; margin-top: 6px; }
.stage-empty { padding-top: 24px; color: #d0d0d5; }
.stage-status { padding: 20px; border: 1px solid #96969e; }
@media (max-width: 700px) {
  .site-header { min-height: 72px; padding: 14px 20px; gap: 16px; }
  .wordmark { font-size: 12px; letter-spacing: .06em; }
  .event-caption { font-size: 12px; }
  .site-header nav { gap: 4px 16px; }
  .site-header a { font-size: 12px; }
  .entry-main { margin-top: 44px; }
  .entry-main, .login-main, .completion-main { width: calc(100% - 48px); }
  .entry-main h1 { font-size: clamp(42px, 12vw, 64px); }
  .entry-lead { font-size: 20px; }
  .entry-description { font-size: 15px; line-height: 1.9; }
  .start-form { margin-top: 32px; }
  .game-header { padding: 14px 20px; gap: 12px; }
  .question-panel { width: calc(100% - 32px); margin: 20px auto 24px; }
  .question-heading { margin-bottom: 16px; font-size: 20px; }
  .question-heading strong { font-size: 26px; }
  .question-heading > span { font-size: 14px; }
  .image-frame { height: clamp(180px, calc(100svh - 350px), 520px); }
  .image-zoom-trigger { padding: 12px 12px 36px; }
  .answer-area { margin-top: 20px; }
  .answer-area label { margin-bottom: 8px; }
  .answer-controls { grid-template-columns: minmax(0, 1fr) 116px; gap: 8px; }
  .answer-controls button { justify-content: center; padding: 12px 10px; }
  .answer-controls button b { display: none; }
  .hint-note { margin-top: 16px; font-size: 13px; }
  .completion-main, .results-main { margin-top: 36px; }
  .clear-time { font-size: clamp(44px, 13vw, 72px); }
  .congrats { font-size: 16px; }
  .results-main, .wide { width: calc(100% - 32px); }
  .results-main .page-intro { font-size: 14px; }
  .results-table { display: block; background: transparent; }
  .results-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .results-table tbody { display: block; }
  .results-table tr { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px 12px; padding: 20px 12px; background: #fff; border-bottom: 1px solid var(--line); align-items: start; }
  .results-table td { display: block; padding: 0; border: 0; }
  .results-table .rank-cell { width: auto; font-size: 24px; line-height: 1.3; }
  .result-name { font-size: 15px; }
  .result-record { text-align: right; }
  .result-record strong { font-size: 15px; }
  .results-table .award-cell { grid-column: 2 / -1; width: auto; display: flex; flex-wrap: wrap; gap: 8px; }
  .award-cell .award-label { margin: 0; font-size: 12px; }
  .award-cell:has(.no-award) { display: none; }
  .results-table .is-me { border-left: 3px solid var(--accent); padding-left: 9px; }
  .staff-section { margin-top: 40px; }
  .staff-section-heading { gap: 16px; }
  .staff-section > h2, .staff-section-heading h2 { font-size: 22px; }
  .staff-actions { align-items: stretch; flex-direction: column; }
  .staff-actions form button, .staff-actions > button { width: 100%; }
  .staff-actions > .danger-button { margin-top: 8px; }
  .participant-table-wrap th, .participant-table-wrap td { padding: 14px 12px; font-size: 14px; }
  .qform { padding: 24px 20px; }
  .qform h2 { margin-bottom: 24px; font-size: 20px; }
  .question-fields { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .admin-image { max-height: 200px; }
  .bulk-save-bar button { width: 100%; }
  .stage-main { padding: 28px 20px 48px; }
  .stage-heading { font-size: 26px; margin-bottom: 28px; }
  .stage-grid { grid-template-columns: 1fr; gap: 40px; }
  .player, .rank { font-size: 17px; gap: 12px; }
  .player strong, .rank strong { font-size: 16px; }
  .rank { grid-template-columns: 28px minmax(0, 1fr) auto; }
}
@media (max-width: 360px) {
  .site-header { padding-left: 16px; padding-right: 16px; }
  .wordmark { font-size: 11px; }
  .entry-main h1 { gap: 8px; }
  .entry-main, .login-main, .completion-main { width: calc(100% - 40px); }
  .game-header { padding-left: 16px; padding-right: 16px; }
  .live-time strong { font-size: 26px; }
  .answer-controls { grid-template-columns: minmax(0, 1fr) 100px; }
  .result-record strong { font-size: 14px; }
  .results-table tr { gap: 8px; padding-right: 8px; padding-left: 8px; }
}

/* Spark identity: bold type and angular accents without visual noise. */
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.brand-spark { width: 23px; height: 23px; flex-shrink: 0; color: var(--accent); }
.stage-body .brand-spark { color: #fff; }
.entry-kicker { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.entry-kicker .entry-lead { margin: 0; font-size: 21px; }
.hero-spark { width: 88px; height: 88px; flex-shrink: 0; color: var(--accent); transform: rotate(8deg); }
.entry-main h1 { font-weight: 900; }
.start-form button b { font-size: 26px; font-weight: 400; line-height: 1; }
.completion-rule { width: 64px; height: 6px; margin-bottom: 28px; background: var(--accent); transform: skewX(-24deg); }
@media (max-width: 700px) {
  .brand-spark { width: 20px; height: 20px; }
  .wordmark { gap: 8px; }
  .hero-spark { width: 64px; height: 64px; }
  .entry-kicker { gap: 16px; margin-bottom: 24px; }
  .entry-kicker .entry-lead { font-size: 18px; }
}
@media (max-width: 360px) {
  .hero-spark { width: 52px; height: 52px; }
  .entry-kicker .entry-lead { font-size: 16px; }
  .brand-spark { width: 16px; height: 16px; }
  .wordmark { gap: 6px; }
}
