:root {
  color-scheme: dark;
  --bg: #0c0b09;
  --panel: #1a1610;
  --panel-2: #211b13;
  --text: #f4ead7;
  --muted: #b8aa94;
  --border: rgba(227, 190, 111, 0.22);
  --gold: #d6a84f;
  --gold-bright: #efc66f;
  --green: #37965b;
  --blue: #3979bd;
  --purple: #9557ba;
  --red: #b84e4e;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 0%, rgba(182, 131, 54, 0.10), transparent 32rem),
    linear-gradient(180deg, #0c0b09, #11100d 58%, #0a0908);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.page-shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 48px 0 36px;
}

.landing {
  width: 100%;
}

.hero {
  display: flex;
  align-items: center;
  gap: clamp(18px, 4vw, 34px);
  max-width: 900px;
  margin: 0 auto 28px;
}

.hero-logo {
  width: clamp(92px, 15vw, 148px);
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.36));
}

.hero-copy-wrap {
  min-width: 0;
}

.hero h1 {
  margin: 0;
  color: #f6ead2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 6.8vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero-copy {
  max-width: 720px;
  margin: 17px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: clamp(1rem, 2vw, 1.13rem);
}

.connection-card {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(34, 29, 21, 0.97), rgba(22, 19, 15, 0.97));
  box-shadow: var(--shadow);
}

.card-heading,
.session-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-kicker {
  margin: 0 0 7px;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  font-weight: 900;
}

.card-heading h2,
.dialog-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.connect-form {
  margin-top: 19px;
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(190px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(223, 194, 136, 0.28);
  border-radius: 11px;
  padding: 10px 12px;
  background: rgba(7, 7, 6, 0.66);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(214, 168, 79, 0.14);
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 15px;
  font-weight: 850;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.button.primary {
  background: linear-gradient(180deg, #e5b85c, #bd8a32);
  color: #171005;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(225, 196, 139, 0.18);
  color: var(--text);
}

.text-button {
  border: 0;
  padding: 7px 0;
  background: transparent;
  color: var(--gold-bright);
  cursor: pointer;
}

.session-actions {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.form-error {
  margin: 11px 0 0;
  color: #ffb9b9;
  font-size: 0.88rem;
  font-weight: 650;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-pill.neutral {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.status-pill.synced {
  color: #cbf2d6;
  background: rgba(55, 150, 91, 0.18);
  border-color: rgba(55, 150, 91, 0.44);
}

.status-pill.syncing {
  color: #ffe7af;
  background: rgba(214, 168, 79, 0.17);
  border-color: rgba(214, 168, 79, 0.44);
}

.status-pill.offline {
  color: #ffd0d0;
  background: rgba(184, 78, 78, 0.17);
  border-color: rgba(184, 78, 78, 0.44);
}

/* Board-only mode */
.page-shell.board-only {
  width: min(1050px, 100%);
  padding: 0;
}

.board-mode {
  width: 100%;
}

.board-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #cfc5ad;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
}

.board-image {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.board-topbar {
  position: absolute;
  z-index: 20;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.board-identity,
.board-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-identity {
  min-width: 0;
  padding: 6px 9px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(12, 11, 9, 0.82);
  backdrop-filter: blur(4px);
}

.board-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.board-identity-text {
  display: grid;
  min-width: 0;
  line-height: 1.08;
}

.board-identity-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.board-identity-text span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.71rem;
}

.board-controls {
  pointer-events: auto;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(12, 11, 9, 0.82);
  color: white;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tile-layer {
  position: absolute;
  inset: 0;
}

.bingo-tile {
  position: absolute;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  color: #fff;
  outline: none;
  overflow: hidden;
  touch-action: manipulation;
}

.bingo-tile::before {
  content: "";
  position: absolute;
  inset: 1px;
  border: 2px solid transparent;
}

.bingo-tile:hover::before,
.bingo-tile:focus-visible::before {
  border-color: rgba(255, 255, 255, 0.60);
  background: rgba(255, 255, 255, 0.06);
}

.bingo-tile.claimed::before {
  background: rgba(215, 145, 25, 0.28);
  border-color: rgba(215, 145, 25, 0.94);
}

.bingo-tile.progress::before {
  background: rgba(57, 121, 189, 0.28);
  border-color: rgba(57, 121, 189, 0.96);
}

.bingo-tile.aid::before {
  background: rgba(149, 87, 186, 0.29);
  border-color: rgba(149, 87, 186, 0.96);
}

.bingo-tile.complete::before {
  background: rgba(55, 150, 91, 0.30);
  border-color: rgba(55, 150, 91, 0.96);
}

.tile-people,
.tile-status {
  position: absolute;
  left: 5%;
  width: 90%;
  z-index: 2;
  border-radius: 7px;
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
  pointer-events: none;
}

.tile-people {
  top: 5%;
  padding: 4px 3px;
  background: rgba(10, 10, 9, 0.84);
  font-size: clamp(7px, 1vw, 11px);
}

.tile-people span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-status {
  bottom: 5%;
  padding: 5px 3px;
  font-size: clamp(8px, 1.05vw, 12px);
}

.claimed .tile-status { background: rgba(203, 129, 18, 0.96); }
.progress .tile-status { background: rgba(45, 105, 173, 0.96); }
.aid .tile-status { background: rgba(133, 66, 172, 0.96); }
.complete .tile-status { background: rgba(43, 135, 76, 0.96); }

.notice {
  width: min(96%, 720px);
  margin: 10px auto;
  padding: 11px 13px;
  border: 1px solid rgba(214, 168, 79, 0.30);
  border-radius: 10px;
  color: #f3ddb0;
  background: rgba(24, 20, 15, 0.95);
}

.notice.error {
  color: #ffd0d0;
  border-color: rgba(184, 78, 78, 0.45);
}

.mobile-hint {
  display: none;
  margin: 8px 12px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-width: min(290px, calc(100vw - 18px));
  padding: 7px;
  border: 1px solid rgba(234, 197, 126, 0.28);
  border-radius: 12px;
  background: rgba(24, 20, 15, 0.98);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.55);
}

.context-heading {
  display: grid;
  gap: 3px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.context-heading span {
  color: var(--gold-bright);
  font-size: 0.70rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.context-heading strong {
  font-size: 0.95rem;
}

.context-menu button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover:not(:disabled),
.context-menu button:focus-visible:not(:disabled) {
  background: rgba(214, 168, 79, 0.13);
}

.context-menu button:disabled {
  color: #6f675a;
  cursor: default;
}

.menu-separator {
  height: 1px;
  margin: 5px 4px;
  background: rgba(255, 255, 255, 0.08);
}

dialog {
  width: min(430px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
}

.dialog-card {
  padding: 22px;
}

.dialog-card h2 {
  margin-bottom: 10px;
}

.dialog-card label {
  margin-top: 17px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}


/*
 * Desktop board sizing:
 * Fit the complete 1024×1310 board inside the visible browser height
 * so the user normally doesn't need to scroll. Mobile keeps using
 * full-width sizing below.
 */
@media (min-width: 681px) {
  .page-shell.board-only {
    width: 100%;
    min-height: 100vh;
    display: grid;
    place-items: start center;
    padding: 8px 0;
  }

  .board-mode {
    width: auto;
    max-width: 100%;
  }

  .board-shell {
    width: min(
      calc(100vw - 24px),
      calc((100vh - 16px) * 1024 / 1310)
    );
    margin: 0 auto;
  }

  .notice {
    margin-top: 8px;
    margin-bottom: 0;
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 22px, 1080px);
    padding-top: 28px;
  }

  .hero {
    align-items: flex-start;
  }

  .hero-logo {
    width: 78px;
  }

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

  .card-heading,
  .session-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .connection-card {
    padding: 17px;
  }

  .page-shell.board-only {
    width: 100%;
    padding: 0;
  }

  .board-topbar {
    top: 6px;
    left: 6px;
    right: 6px;
  }

  .board-identity {
    max-width: 62%;
  }

  .board-logo {
    width: 28px;
    height: 28px;
  }

  .board-identity-text strong {
    font-size: 0.72rem;
  }

  .board-identity-text span {
    font-size: 0.62rem;
  }

  .icon-button {
    width: 30px;
    height: 30px;
  }

  .board-controls .status-pill {
    display: none;
  }

  .tile-people {
    padding: 2px 1px;
    border-radius: 4px;
    font-size: clamp(5px, 2vw, 9px);
  }

  .tile-status {
    padding: 3px 1px;
    border-radius: 4px;
    font-size: clamp(6px, 2.2vw, 10px);
  }

  .mobile-hint {
    display: block;
  }
}

@media (max-width: 430px) {
  .hero {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 14px;
  }

  .hero-logo {
    width: 68px;
  }

  .hero h1 {
    font-size: clamp(2.05rem, 12vw, 3.25rem);
  }

  .hero-copy {
    grid-column: 1 / -1;
  }
}
