:root {
  color-scheme: light;
  --ink: #141414;
  --muted: #666a73;
  --line: #d9dde5;
  --paper: #ffffff;
  --surface: #f4f6f9;
  --charcoal: #18191d;
  --charcoal-2: #24262c;
  --red: #d8323c;
  --gold: #f5ba3d;
  --green: #138a55;
  --teal: #087e8b;
  --blue: #2768d8;
  --shadow: 0 16px 45px rgba(16, 18, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.scoreboard-page {
  background: var(--charcoal);
  color: #fff;
}

.scoreboard-shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 32px;
}

.scoreboard-header,
.admin-header {
  display: grid;
  grid-template-columns: minmax(150px, 260px) minmax(240px, 560px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.header-title {
  min-width: 0;
}

.scoreboard-header h1,
.admin-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 2.2rem);
  line-height: 1.05;
}

.event-banner-slot {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 88px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.event-banner-slot img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 88px;
  object-fit: contain;
}

.admin-header .event-banner-slot {
  border-color: var(--line);
}

.status-pill,
.connection-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
}

.status-pill::before,
.connection-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.status-pill.active::before,
.connection-dot::before {
  background: var(--green);
}

.status-pill.ended::before {
  background: var(--red);
}

.status-pill.offline::before,
.connection-dot.offline::before {
  background: var(--red);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  margin-bottom: 20px;
}

.round-panel,
.last-ball-panel,
.drawn-strip-section {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--charcoal-2);
  box-shadow: var(--shadow);
}

.round-panel {
  display: grid;
  align-content: center;
  min-height: 240px;
  padding: 32px;
}

.panel-label {
  margin: 0 0 8px;
  color: #aeb4c0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.round-panel h2 {
  margin: 0 0 26px;
  color: #fff;
  font-size: clamp(2.5rem, 5.4vw, 3.8rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.round-panel strong {
  color: var(--gold);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.last-ball-panel {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 26px;
  text-align: center;
}

.last-ball-panel p:last-child {
  margin: 10px 0 0;
  color: #d4d8df;
  font-size: 1.1rem;
  font-weight: 700;
}

.big-ball {
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  border: 12px solid #fff;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: 3rem;
  font-weight: 900;
  box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.1), 0 20px 38px rgba(0, 0, 0, 0.25);
}

.big-ball[data-letter="b"] {
  background: var(--blue);
  color: #fff;
}

.big-ball[data-letter="i"] {
  background: var(--red);
  color: #fff;
}

.big-ball[data-letter="n"] {
  background: var(--gold);
  color: var(--ink);
}

.big-ball[data-letter="g"] {
  background: var(--green);
  color: #fff;
}

.big-ball[data-letter="o"] {
  background: var(--teal);
  color: #fff;
}

.board-section {
  margin-bottom: 20px;
}

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

.bingo-column {
  display: grid;
  grid-template-rows: 64px repeat(15, 1fr);
  gap: 8px;
  min-width: 0;
}

.bingo-letter,
.score-ball,
.admin-ball {
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 900;
}

.bingo-letter {
  color: #fff;
  font-size: 2rem;
}

.bingo-letter-b {
  background: var(--blue);
}

.bingo-letter-i {
  background: var(--red);
}

.bingo-letter-n {
  background: var(--gold);
  color: var(--ink);
}

.bingo-letter-g {
  background: var(--green);
}

.bingo-letter-o {
  background: var(--teal);
}

.score-ball {
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #2e3138;
  color: #8e95a3;
  font-size: 1.35rem;
}

.score-ball.drawn {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.score-ball.latest {
  outline: 4px solid var(--gold);
  outline-offset: -4px;
}

.drawn-strip-section {
  padding: 18px;
}

.drawn-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.drawn-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 38px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.drawn-chip.latest {
  background: var(--gold);
}

.empty-strip {
  color: #aeb4c0;
  font-weight: 700;
}

.admin-shell {
  width: min(1320px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 36px;
}

.admin-header h1 {
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.connection-dot {
  background: var(--ink);
  color: #fff;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  background: #fff;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.admin-board-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(18, 22, 30, 0.08);
}

.control-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.setup-form,
.ball-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 104, 216, 0.16);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 44px;
  border-radius: 8px;
  border: 0;
  padding: 0 13px;
  font-weight: 900;
}

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

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

.danger-button {
  background: var(--red);
  color: #fff;
}

.text-button {
  background: transparent;
  color: var(--red);
}

.game-summary {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.game-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-summary span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.game-summary strong {
  font-size: 1rem;
  text-align: right;
}

.toast {
  display: none;
  min-height: 38px;
  align-items: center;
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.toast.visible {
  display: flex;
}

.toast.error {
  background: var(--red);
}

.admin-board-section {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.6rem;
}

.admin-board .bingo-column {
  grid-template-rows: 54px repeat(15, 42px);
}

.admin-ball {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}

.admin-ball:not(:disabled):hover {
  border-color: var(--blue);
  background: #eef4ff;
}

.admin-ball.drawn {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.admin-ball.latest {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

@media (max-width: 960px) {
  .scoreboard-header,
  .admin-header {
    grid-template-columns: minmax(150px, 1fr) minmax(260px, 1.4fr);
  }

  .status-pill,
  .header-actions {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .hero-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .round-panel h2 {
    font-size: 2.8rem;
  }
}

@media (max-width: 720px) {
  .scoreboard-shell,
  .admin-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 12px;
  }

  .scoreboard-header,
  .admin-header {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
  }

  .event-banner-slot {
    order: -1;
    min-height: 70px;
  }

  .event-banner-slot img {
    min-height: 70px;
  }

  .status-pill,
  .header-actions {
    grid-column: auto;
    justify-self: stretch;
  }

  .status-pill {
    justify-content: center;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .connection-dot,
  .ghost-link {
    justify-content: center;
    width: 100%;
  }

  .hero-grid {
    gap: 12px;
  }

  .round-panel,
  .last-ball-panel,
  .drawn-strip-section,
  .control-panel,
  .admin-board-section {
    border-radius: 8px;
  }

  .round-panel {
    min-height: 0;
    padding: 18px;
  }

  .round-panel h2 {
    margin-bottom: 18px;
    font-size: clamp(1.55rem, 8vw, 2.1rem);
    line-height: 1.1;
  }

  .round-panel strong {
    font-size: clamp(1.12rem, 5vw, 1.35rem);
  }

  .last-ball-panel {
    order: -1;
    grid-template-columns: 132px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 16px;
    min-height: 0;
    padding: 18px;
    text-align: left;
  }

  .last-ball-panel .panel-label {
    grid-column: 2;
    align-self: end;
  }

  .last-ball-panel p:last-child {
    grid-column: 2;
    align-self: start;
    margin: 4px 0 0;
    font-size: 1rem;
  }

  .big-ball {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 132px;
    height: 132px;
    border-width: 9px;
    font-size: 2rem;
  }

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

  .bingo-column {
    grid-template-rows: 40px repeat(15, clamp(31px, 8.8vw, 36px));
    gap: 5px;
  }

  .bingo-letter {
    font-size: 1.3rem;
  }

  .score-ball {
    min-height: 31px;
    font-size: 0.95rem;
    border-radius: 7px;
  }

  .admin-board .bingo-column {
    grid-template-rows: 40px repeat(15, clamp(30px, 8.2vw, 34px));
  }

  .admin-ball {
    min-height: 30px;
    padding: 0;
    font-size: 0.86rem;
    border-radius: 7px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .scoreboard-shell,
  .admin-shell {
    width: min(100% - 14px, 1320px);
  }

  .last-ball-panel {
    grid-template-columns: 112px minmax(0, 1fr);
    column-gap: 12px;
    padding: 14px;
  }

  .big-ball {
    width: 112px;
    height: 112px;
    border-width: 8px;
    font-size: 1.65rem;
  }

  .bingo-board,
  .admin-board {
    gap: 4px;
  }

  .bingo-column {
    grid-template-rows: 34px repeat(15, 29px);
    gap: 4px;
  }

  .bingo-letter {
    font-size: 1.1rem;
  }

  .score-ball {
    min-height: 29px;
    font-size: 0.84rem;
    border-radius: 6px;
  }

  .admin-board .bingo-column {
    grid-template-rows: 34px repeat(15, 28px);
  }

  .admin-ball {
    min-height: 28px;
    font-size: 0.78rem;
    border-radius: 6px;
  }
}
