:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --cell: #fafafa;
  --ink: #222222;
  --muted: #6e6e6e;
  --line: #dededb;
  --coral: #d94841;
  --coral-dark: #b63732;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --mono: var(--sans);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(217, 72, 65, 0.3);
  outline-offset: 3px;
}

.site-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 30px;
}

.site-header,
.brand,
.lead,
.lead-actions,
.panel-header,
.panel-footer,
.site-footer {
  display: flex;
  align-items: center;
}

.site-header {
  justify-content: space-between;
  min-height: 40px;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 3px;
  color: #fff;
  background: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.brand-name,
.brand-meta {
  display: block;
}

.brand-name {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-meta {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button:hover {
  border-color: #bdbdb9;
}

.button:active {
  opacity: 0.8;
}

.button--quiet {
  border-color: var(--line);
  color: var(--ink);
  background: var(--panel);
}

.button--quiet:hover {
  border-color: #bdbdb9;
  background: var(--panel);
}

.button--primary {
  color: #fff;
  background: var(--ink);
}

.button--primary:hover {
  background: #444;
}

.page-main {
  padding-top: 63px;
}

.lead {
  justify-content: space-between;
  gap: 25px;
  padding: 0 4px 29px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.panel-label,
.panel-count,
.source-note,
.site-footer,
.obs-exit-panel {
  font-family: var(--mono);
}

.eyebrow,
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.13em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin: 14px 0 11px;
  font-size: clamp(42px, 8vw, 68px);
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 0.95;
}

h1 em {
  color: inherit;
  font-family: inherit;
  font-style: normal;
  font-weight: 700;
  letter-spacing: -0.07em;
}

.lead-text {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.lead-actions {
  align-self: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.bingo-panel {
  margin-top: 25px;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.panel-header,
.panel-footer {
  justify-content: space-between;
}

.panel-header {
  padding: 0 1px 15px;
  border-bottom: 1px solid var(--line);
}

.panel-count {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.panel-count span {
  color: var(--ink);
}

.bingo-letters,
.bingo-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.bingo-letters {
  margin: 17px 0 8px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.bingo-cell {
  position: relative;
  display: grid;
  min-height: clamp(62px, 8vw, 100px);
  padding: 8px 6px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e4e4e1;
  border-radius: 9px;
  color: var(--ink);
  background: var(--cell);
  cursor: pointer;
  font-size: clamp(9px, 1.35vw, 13px);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.bingo-cell:hover {
  border-color: #bdbdb9;
  background: #fff;
}

.bingo-cell:active {
  transform: scale(0.98);
}

.bingo-cell.is-marked {
  border-color: var(--coral-dark);
  color: #fff;
  background: var(--coral);
}

.bingo-cell.is-free {
  border-color: #cfcfcb;
  color: var(--muted);
  background: #eeeeeb;
  cursor: default;
}

.bingo-cell.is-free:hover {
  border-color: #cfcfcb;
  background: #eeeeeb;
  transform: none;
}

.free-label {
  display: grid;
  gap: 4px;
  place-items: center;
  font-size: 9px;
}

.free-label strong {
  color: var(--ink);
  font-size: 11px;
}

.panel-footer {
  min-height: 36px;
  padding: 13px 1px 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

#bingo-status.is-bingo {
  color: var(--coral-dark);
  font-weight: 800;
}

.reset-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
}

.reset-button:hover {
  color: var(--coral-dark);
}

.source-note {
  margin: 19px 4px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.source-note a {
  color: var(--ink);
  text-underline-offset: 3px;
}

.site-footer {
  justify-content: space-between;
  gap: 15px;
  padding: 19px 4px 0;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  color: #9b9299;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.obs-exit-panel {
  display: none;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  z-index: 5;
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 7px;
  color: #fff;
  background: rgba(44, 40, 48, 0.94);
  font-family: var(--sans);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* OBS Browser Source mode: only the board remains visible. */
body.obs-mode {
  background: transparent;
}

body.obs-mode .site-shell {
  width: 100%;
  padding: 0;
}

body.obs-mode .site-header,
body.obs-mode .lead,
body.obs-mode .source-note,
body.obs-mode .site-footer,
body.obs-mode .panel-footer {
  display: none;
}

body.obs-mode .page-main {
  display: grid;
  min-height: 100vh;
  padding: clamp(10px, 3vw, 40px);
  place-items: center;
}

body.obs-mode .bingo-panel {
  width: min(92vw, 82vh);
  margin: 0;
  padding: clamp(12px, min(2.6vw, 2.4vh), 24px);
  border: 0;
  border-radius: clamp(12px, 1.7vw, 22px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

body.obs-mode .panel-header {
  padding-bottom: clamp(10px, 1.4vw, 16px);
}

body.obs-mode .bingo-letters {
  gap: clamp(5px, 0.8vw, 10px);
  margin: clamp(12px, 1.8vw, 20px) 0 clamp(6px, 0.8vw, 10px);
  font-size: clamp(15px, 2vw, 24px);
}

body.obs-mode .bingo-board {
  gap: clamp(5px, 0.8vw, 10px);
}

body.obs-mode .bingo-cell {
  min-height: clamp(48px, min(12vw, 9vh), 140px);
  padding: clamp(5px, min(1vw, 1.3vh), 10px);
  border-radius: clamp(7px, 1vw, 13px);
  font-size: clamp(9px, min(1.8vw, 2.4vh), 22px);
  line-height: 1.15;
}

body.obs-mode .free-label {
  font-size: clamp(8px, 1.2vw, 14px);
}

body.obs-mode .free-label strong {
  font-size: clamp(11px, 1.55vw, 19px);
}

body.obs-mode .obs-exit-panel {
  display: flex;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 4;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(44, 40, 48, 0.9);
  font-size: 8px;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 150ms ease;
}

body.obs-mode .obs-exit-panel:hover,
body.obs-mode .obs-exit-panel:focus-within {
  opacity: 1;
}

body.obs-mode .obs-exit-panel button {
  padding: 3px 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 10px;
}

body.obs-mode .toast {
  display: none;
}

@media (max-width: 640px) {
  .site-shell {
    width: min(100% - 24px, 520px);
    padding-top: 16px;
  }

  .page-main {
    padding-top: 48px;
  }

  .lead {
    display: block;
    padding-right: 0;
    padding-left: 0;
  }

  h1 {
    margin-top: 12px;
    font-size: clamp(43px, 15vw, 64px);
  }

  .lead-actions {
    margin-top: 22px;
  }

  .lead-actions .button {
    flex: 1;
  }

  .bingo-panel {
    margin-top: 16px;
    border-radius: 12px;
  }

  .bingo-letters,
  .bingo-board {
    gap: 5px;
  }

  .bingo-cell {
    min-height: 57px;
    border-radius: 7px;
    font-size: 8px;
  }

  .panel-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

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