:root {
  --navy: #071524;
  --ink: #132236;
  --muted: #647386;
  --paper: #f4f8fb;
  --panel: #ffffff;
  --line: #dce6ee;
  --teal: #12b9ad;
  --coral: #f2645f;
  --gold: #f3b43f;
  --green: #1f9d55;
  --shadow: 0 16px 42px rgba(19, 34, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #081827, #06101d);
  box-shadow: 0 14px 35px rgba(7, 21, 36, 0.22);
}

.top-brand,
.top-meta,
.room-toolbar,
.winner-banner {
  display: flex;
  align-items: center;
}

.top-brand {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: var(--navy);
  background: linear-gradient(135deg, #29d4df, #ff6961);
  font-size: 28px;
  font-weight: 950;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #29d4df;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.2;
}

.top-brand p {
  margin-top: 4px;
  color: #d2dce6;
  font-size: 13px;
  font-weight: 750;
}

.top-meta {
  gap: 16px;
  margin-left: auto;
}

.meta-block {
  min-width: 122px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 18px;
}

label,
.tiny-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .tiny-label {
  color: #c5d3df;
}

.code-button {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  border: 1px solid rgba(243, 180, 63, 0.34);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.08);
}

.code-button strong {
  font-size: 24px;
  font-weight: 950;
  letter-spacing: 2px;
}

.code-button span {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 10px;
  color: #d2dce6;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.user-count strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.icon-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 900;
}

.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.hero-panel {
  min-height: calc(100vh - 116px);
  padding: 16px;
  border: 1px solid rgba(19, 34, 54, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.lobby-grid,
.game-grid,
.side-stack,
.left-stack,
.form-panel,
.calls-list,
.leaderboard,
.players-list {
  display: grid;
}

.lobby-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.game-grid {
  grid-template-columns: 285px minmax(440px, 1fr) 350px;
  align-items: start;
  gap: 14px;
}

.side-stack,
.left-stack {
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(19, 34, 54, 0.08);
}

.form-panel,
.board-panel,
.call-panel,
.side-stack .panel,
.players-panel {
  padding: 16px;
}

.form-panel {
  gap: 10px;
}

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

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(18, 185, 173, 0.15);
}

button[type="submit"] {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: linear-gradient(180deg, #21c5b9, #0ca89d);
  font-size: 14px;
  font-weight: 900;
}

.winner-banner {
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(243, 180, 63, 0.42);
  border-radius: 8px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(180deg, #0b2236, #071524);
}

.winner-label {
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.room-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.room-toolbar strong,
.line-score strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.bingo-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(58px, 1fr));
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
}

.board-cell {
  position: relative;
  display: grid;
  min-height: 58px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #1599a7;
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdff;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 950;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.board-cell:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: var(--teal);
}

.board-cell:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.board-cell[data-called="true"] {
  background: #fff;
  border-color: rgba(18, 185, 173, 0.72);
}

.board-cell[data-marked="true"] {
  color: var(--ink);
  background: #d9f7f6;
  border-color: #93dfe1;
}

.board-cell[data-marked="true"]::before,
.board-cell[data-marked="true"]::after {
  content: "";
  position: absolute;
  width: 42%;
  height: 3px;
  border-radius: 4px;
  background: var(--ink);
}

.board-cell[data-marked="true"]::before {
  transform: rotate(45deg);
}

.board-cell[data-marked="true"]::after {
  transform: rotate(-45deg);
}

.call-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.called-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.called-strip span {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: #eef3f7;
  font-size: 12px;
  font-weight: 950;
}

.called-strip span[data-called="true"] {
  color: #fff;
  background: var(--teal);
}

.calls-list,
.leaderboard,
.players-list {
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.calls-list li,
.leaderboard li,
.players-list li {
  min-height: 38px;
  border-radius: 8px;
  padding: 7px 9px;
  background: #f7fafc;
}

.calls-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calls-list strong {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--coral);
}

.calls-list span,
.leaderboard strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.players-list li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.players-list li[data-me="true"] {
  border: 1px solid rgba(18, 185, 173, 0.35);
  background: #effefd;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  font-size: 13px;
  font-weight: 950;
}

.player-name,
.leader-name {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.leaderboard li[data-winner="true"] {
  border: 1px solid #f3c260;
  color: #4b2b00;
  background: linear-gradient(90deg, #fff0bf, #fff9e6);
}

.leader-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rank-badge {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  color: #664000;
  background: #ffd36b;
  font-size: 13px;
  font-weight: 950;
}

.empty-row {
  color: var(--muted);
  font-size: 14px;
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 750;
}

.status-line[data-type="good"] {
  color: var(--green);
}

.status-line[data-type="bad"] {
  color: var(--coral);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  padding: 12px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.site-footer a {
  color: var(--teal);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .game-grid {
    grid-template-columns: minmax(260px, 0.7fr) minmax(420px, 1fr);
  }

  .side-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding: 10px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-meta {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .meta-block {
    min-width: 0;
    border-left: 0;
    padding-left: 0;
  }

  .top-brand h1 {
    font-size: 30px;
  }

  .hero-panel {
    min-height: calc(100vh - 20px);
    padding: 10px;
  }

  .lobby-grid,
  .game-grid,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .room-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .call-form {
    grid-template-columns: 1fr;
  }

  .bingo-board {
    gap: 5px;
  }

  .board-cell {
    min-height: 54px;
    font-size: clamp(17px, 7vw, 28px);
  }

  .site-footer {
    flex-direction: column;
    gap: 5px;
  }
}
