:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #1a1a1a;
  --subtle: #505968;
  --line: #d5d9e1;
  --control-line: #79818e;
  --brand: #244182;
  --action: #f6edb8;
  --action-hover: #f0e49e;
  --danger: #a23126;
  --page-width: 55rem;
  --gutter: clamp(1rem, 4.4vw, 2.5rem);
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-variant-numeric: tabular-nums;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
body[data-role="board"] {
  color-scheme: dark;
  --paper: #121822;
  --ink: #f4f5f8;
  --subtle: #b8c1d1;
  --line: #48546a;
  --control-line: #818da5;
  --brand: #b4c9f7;
  --page-width: 100rem;
}

h1, h2, p, dl, dd, ul { margin: 0; }
h1, h2 { line-height: 1.25; }
h1 { font-size: clamp(1.65rem, 3.3vw, 2.5rem); }
h2 { font-size: 1.125rem; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { color: inherit; font: inherit; }
button, .button, summary, .host-join { touch-action: manipulation; }
button, .button {
  display: inline-flex;
  min-block-size: 48px;
  min-inline-size: 48px;
  align-items: center;
  justify-content: center;
  padding: .5rem .75rem;
  border: 1px solid var(--control-line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: .48; cursor: default; }
button:not(:disabled):active, .button:active { background: var(--line); }
.primary {
  border-color: var(--ink);
  background: var(--action);
  color: #1a1a1a;
  font-weight: 700;
}
.primary:not(:disabled):active { background: var(--action-hover); }
.danger { border-color: var(--danger); color: var(--danger); font-weight: 700; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

input:not([type="checkbox"], [type="file"]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: .55rem .625rem;
  border: 1px solid var(--control-line);
  border-radius: 0;
  background: var(--paper);
  font-size: 1rem;
}
textarea { resize: vertical; }
label { display: grid; gap: .25rem; min-width: 0; font-size: .875rem; font-weight: 600; }
.check { display: inline-flex; min-height: 48px; align-items: center; gap: .5rem; }
.check input {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--brand);
}
.quiet { color: var(--subtle); font-size: .875rem; }
.number { white-space: nowrap; }
.unit { font-size: .75em; margin-inline-start: .14em; }
.score-total .unit, .display-total .unit, .player-score .unit { font-size: .5em; }
.rank { display: inline-flex; align-items: baseline; gap: .25em; white-space: nowrap; }
.rank .number { font-size: 1.15em; font-weight: 700; }

.shell {
  width: min(100%, var(--page-width));
  min-height: 100svh;
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.masthead {
  display: flex;
  min-height: 56px;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: .625rem;
  min-width: 0;
  font-weight: 700;
}
#room-label {
  overflow: hidden;
  color: var(--subtle);
  font-size: .75rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#connection { flex: 0 0 auto; color: var(--subtle); font-size: .75rem; }
.host-join { display: inline-flex; min-height: 48px; align-items: center; color: var(--brand); font-size: .8125rem; white-space: nowrap; }
main { display: block; padding: 1rem 0 2.5rem; }
main:focus { outline: none; }
body[data-role="host"] main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
#navigation {
  z-index: 1;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, var(--page-width));
  margin-inline: auto;
  padding: .25rem max(.375rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(.375rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
#navigation button {
  min-inline-size: 0;
  min-block-size: 52px;
  padding-inline: .125rem;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--subtle);
  font-size: .8125rem;
}
#navigation button[aria-current] { border-bottom-color: var(--brand); color: var(--brand); font-weight: 700; }
#message {
  position: fixed;
  z-index: 2;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: .625rem 1rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  pointer-events: none;
}
#message[data-error="true"] { background: var(--danger); color: #fff; }
body[data-role="host"] #message { bottom: calc(4rem + env(safe-area-inset-bottom)); }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .25rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.score-heading-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; }
.compact { font-size: .8125rem; }
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .5rem; }
.segments button { min-inline-size: 0; overflow-wrap: anywhere; color: var(--subtle); }
.segments[aria-label="加減点の対象"] button { padding-inline: .375rem; font-size: .875rem; }
.segments button[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 -3px var(--brand); color: var(--brand); font-weight: 700; }
.team-scores { margin-top: 1rem; }
.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.5rem, .68fr);
  gap: .5rem 1rem;
  align-items: center;
  padding: .875rem 0;
  border-top: 1px solid var(--line);
}
.score-row:last-child { border-bottom: 1px solid var(--line); }
.score-label, .team-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.score-label { justify-content: start; align-items: baseline; flex-wrap: wrap; }
.score-label h2, .team-heading h2 { overflow-wrap: anywhere; min-width: 0; }
.score-label .rank { color: var(--subtle); font-size: .8125rem; }
.score-total { justify-self: end; font-size: clamp(2rem, 12vw, 2.75rem); line-height: .95; }
.subtotals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto auto; gap: .125rem .5rem; }
.subtotals > div { display: grid; grid-row: span 2; grid-template-rows: subgrid; }
.subtotals dt { color: var(--subtle); font-size: .75rem; overflow-wrap: anywhere; }
.subtotals dd { font-size: 1rem; font-weight: 700; }
.subtotals .chosen dt { color: var(--brand); font-weight: 700; }
.score-controls { display: grid; grid-template-columns: minmax(48px, .8fr) minmax(48px, 1fr); gap: .5rem; }
.score-controls button { min-height: 56px; padding-inline: .25rem; font-size: 1.125rem; }
.score-controls .minus { color: var(--subtle); }
.score-controls .number[data-long], .subtotals .number[data-long] {
  font-size: .75rem;
  overflow-wrap: anywhere;
  white-space: normal;
}
.score-total .number[data-long] { font-size: .6em; }
.score-tools, .split-buttons, .setting-tools, .game-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.score-tools { margin: .75rem 0; }
.score-tools button { flex: 1; }
.inline-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 8rem; }
.history, .manual { border-block-start: 1px solid var(--line); margin-top: .75rem; }
summary { align-content: center; min-height: 48px; font-weight: 700; cursor: pointer; }
summary .quiet { margin-inline-start: .25rem; font-weight: 400; }
.history-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .75rem;
  align-items: center;
  border-block-start: 1px solid var(--line);
  padding: .5rem 0;
}

.round-title { margin: 0 0 1rem; }
.round-title h1 { overflow-wrap: anywhere; }
.eyebrow { color: var(--subtle); margin-bottom: .75rem; font-size: .875rem; font-weight: 600; }
.eyebrow span:not(:empty)::before { content: ' / '; margin-inline: .4rem; }
.game-actions { margin-block: 1rem; }
.game-actions:empty { display: none; }
.grow { flex: 1; }
.chooser { margin-block: 1rem; }
.game-teams { display: grid; grid-template-columns: 1fr; margin-block: 1rem; }
.game-team { padding: .75rem 0; border-top: 1px solid var(--line); }
.tally { white-space: nowrap; }
.team-answers { display: grid; gap: .25rem; margin-top: .5rem; }
.team-answers li { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr); gap: .75rem; align-items: baseline; overflow-wrap: anywhere; }
.team-answers strong, .own-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.team-answers .quiet { text-align: end; }
.judging { margin-top: .5rem; display: grid; gap: .375rem; }
.verdict { display: block; margin-block: .5rem; color: var(--brand); font-weight: 700; }
.claim-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; font-size: clamp(1rem, 3vw, 1.5rem); }
.claim-line strong { font-size: 1.25em; overflow-wrap: anywhere; }
.song-meta { margin-bottom: .75rem; overflow-wrap: anywhere; color: var(--subtle); }
.song-meta:empty, .song-answer p:empty { display: none; }
.song-answer { overflow-wrap: anywhere; }
#media { margin-block: .75rem; }
#media iframe, .youtube-frame iframe { display: block; width: 100%; max-width: 42rem; min-height: 200px; aspect-ratio: 16 / 9; border: 0; }

.join-form, .answer-form { display: grid; gap: .75rem; max-width: 32rem; }
.player-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding-bottom: .5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.player-identity span { overflow-wrap: anywhere; }
.player-score { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 1rem 0; }
.player-score dt { font-size: .875rem; color: var(--subtle); }
.player-score dd { font-size: clamp(2.5rem, 11vw, 4rem); font-weight: 700; line-height: 1.2; }
.player-score dd .rank .number { font-size: 1em; }
body[data-role="player"] .subtotals { max-width: 36rem; margin-bottom: 1.5rem; }
.buzz-button {
  width: 100%;
  min-height: clamp(14rem, calc(100svh - 14rem), 41rem);
  margin-top: .75rem;
  border: 2px solid var(--ink);
  background: var(--action);
  color: #1a1a1a;
  font-size: clamp(2.25rem, 11vw, 5rem);
  font-weight: 700;
}
.buzz-button:not(:disabled):active { background: var(--action-hover); }

body[data-role="board"] .masthead { min-height: 52px; }
body[data-role="board"] main { padding-top: clamp(1rem, 4vw, 3.5rem); }
body[data-role="board"] h1 { font-size: clamp(1.75rem, 4vw, 4.25rem); }
.board-tools { display: flex; justify-content: end; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.board-intro {
  padding: clamp(2rem, 6vw, 5rem) 0 clamp(1.5rem, 4vw, 3rem);
  border-top: 3px solid var(--brand);
}
.board-intro .eyebrow { color: var(--brand); font-size: clamp(1rem, 1.5vw, 1.25rem); }
body[data-role="board"] .board-intro h1 { font-size: clamp(2.25rem, 7vw, 6rem); }
.board-intro .song-answer { font-size: clamp(1.125rem, 2.6vw, 2.5rem); }
.board-intro-status { display: flex; gap: 1rem; align-items: center; color: var(--subtle); }
.board-intro-status span { padding: .25rem .65rem; border: 1px solid var(--line); color: var(--brand); }
.sound-control { font-size: .875rem; }
.board-scores { display: grid; }
.board-team {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .25rem .75rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}
.board-team .team-heading { flex-wrap: wrap; }
.board-team h2 { font-size: clamp(1.25rem, 4vw, 2.25rem); }
.board-team .subtotals { grid-column: 1 / -1; margin-top: .5rem; }
.board-team .subtotals dt { font-size: clamp(.75rem, 1.5vw, 1.125rem); }
.board-team .subtotals dd { font-size: clamp(1.125rem, 2.4vw, 2rem); }
.display-total { font-size: clamp(2.75rem, 9vw, 7.75rem); line-height: 1; }
.display-total .number[data-long] { font-size: .55em; }
body[data-role="board"] .game-team h2 { font-size: clamp(1.125rem, 3vw, 2rem); }
body[data-role="board"] .team-answers li { font-size: clamp(.9375rem, 1.9vw, 1.5rem); }
body[data-role="board"] .team-answers li strong { color: var(--ink); }

.section { padding-block: 1rem; border-top: 1px solid var(--line); }
.section h2 { margin-bottom: .75rem; }
.share-row + .share-row { margin-top: .5rem; }
#join-qr { display: block; width: min(100%, 12rem); height: auto; margin-top: .75rem; image-rendering: pixelated; }
.settings-save {
  z-index: 1;
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-block: .5rem;
  background: var(--paper);
}
.setting-row { padding-bottom: .875rem; display: grid; gap: .5rem; }
.setting-row + .setting-row { padding-top: .875rem; border-top: 1px solid var(--line); }
.two-fields { grid-template-columns: minmax(0, 1fr) minmax(4.5rem, .35fr); }
.setting-tools { justify-content: flex-start; }
#intro-materials { scroll-margin-top: 4.5rem; }
#intro-materials .section-heading h2 { margin: 0; }
.youtube-entry, .song-fields { display: grid; gap: .75rem; }
.youtube-entry { margin: .75rem 0 1rem; }
.youtube-results { display: grid; gap: .5rem; }
.youtube-results li { display: flex; align-items: center; gap: .75rem; overflow-wrap: anywhere; }
.youtube-results button { margin-inline-start: auto; flex: none; }
.song-setting { border-top: 1px solid var(--line); padding-block: .875rem; }
.song-setting-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .75rem; align-items: center; }
.song-setting-head > div { grid-column: 2; overflow-wrap: anywhere; }
.song-setting-head > div:first-child { grid-column: 1 / 3; }
.song-setting-head img { width: 96px; height: 54px; object-fit: cover; }
.song-setting-head h3 { margin: 0; font-size: 1rem; }
.embed-status {
  padding: .15rem .5rem;
  white-space: nowrap;
  color: var(--subtle);
  border: 1px solid currentColor;
  font-weight: 600;
}
.embed-status[data-status="playable"] { color: #246047; background: #eaf4ee; }
.embed-status[data-status="blocked"] { color: var(--danger); background: #fceeed; }
.embed-status[data-status="unverified"] { color: #775213; background: #fbf3df; }
.song-check-summary { margin-bottom: .75rem; color: var(--brand); font-weight: 600; }
.intro-stage > span { display: block; }
#intro-player-dialog { width: min(46rem, calc(100% - 2rem)); padding: 1.25rem; color: var(--ink); border: 1px solid var(--ink); }
#intro-player-dialog::backdrop { background: rgb(18 24 34 / .55); }
#intro-player-dialog output { display: block; margin-block: .5rem; }
#intro-player-dialog .youtube-frame:not(:empty) { margin-block: .5rem; }
#retry-playback { margin-top: .75rem; }
.bulk-entry { margin-top: 1rem; display: grid; justify-items: start; gap: .5rem; }
.bulk-entry label { width: 100%; }
.data-settings .setting-tools + .setting-tools { margin-top: .75rem; }
.reset-confirm { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding-block: .75rem; }
.reset-confirm span { width: 100%; overflow-wrap: anywhere; }
.file-label { position: relative; font-size: 1rem; font-weight: 400; }
.file-label input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-label:focus-within { outline: 2px solid var(--brand); outline-offset: 3px; }

@media (max-width: 359px) {
  .score-row { gap: .375rem .5rem; }
  .score-controls { gap: .25rem; }
  .score-controls button { font-size: 1rem; }
  .subtotals { gap: .25rem; }
}

@media (min-width: 42rem) {
  main { padding-block-start: 1.75rem; }
  .score-row {
    grid-template-columns: minmax(0, 1fr) minmax(8rem, 1.3fr) auto minmax(8rem, .75fr);
    gap: 1rem;
    padding-block: 1.125rem;
  }
  .score-total { grid-column: 3; grid-row: 1; }
  .score-row .subtotals { grid-column: 2; grid-row: 1; }
  .score-tools { justify-content: end; }
  .score-tools button { flex: initial; }
  .game-teams { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-team { padding: .875rem 1rem; }
  .game-team:first-child { padding-inline-start: 0; }
  .game-team + .game-team { border-inline-start: 1px solid var(--line); }
  .game-team:last-child { padding-inline-end: 0; }
  .board-scores { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: clamp(1rem, 5vw, 4.5rem); }
  .board-team { display: block; padding: 1.5rem clamp(1rem, 3vw, 3rem); }
  .board-team:first-child { padding-inline-start: 0; }
  .board-team:last-child { padding-inline-end: 0; }
  .board-team + .board-team { border-inline-start: 1px solid var(--line); }
  .display-total { display: block; margin-block: clamp(1rem, 4vw, 3.5rem); }
  .board-team .subtotals { border-top: 1px solid var(--line); padding-top: .75rem; }
  .team-setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .song-fields { grid-template-columns: minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, .85fr); }
}
