@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Source+Serif+4:wght@600;700&display=swap");

:root {
  --bg: #f4f6f9;
  --bg-alt: #e9eef4;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.78);
  --ink: #0b1b2b;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.1);
  --accent: #0f4c81;
  --accent-2: #2d6b9f;
  --accent-soft: rgba(15, 76, 129, 0.1);
  --gold: #a1792a;
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --shadow: 0 22px 48px rgba(15, 34, 58, 0.12);
  --shadow-soft: 0 12px 28px rgba(15, 34, 58, 0.08);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-body: "IBM Plex Sans", "Trebuchet MS", sans-serif;
  --font-display: "Source Serif 4", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background: linear-gradient(145deg, #f8fafc 0%, var(--bg) 58%, var(--bg-alt) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

label {
  display: grid;
  gap: 0.45rem;
  color: var(--ink);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 0.75rem 0.9rem;
  outline: none;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(45, 107, 159, 0.28);
  outline-offset: 2px;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(15, 76, 129, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 76, 129, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.24), transparent 72%);
}

.topbar,
.shell,
.footer {
  width: min(1240px, calc(100% - 2rem));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(15, 76, 129, 0.16);
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.1;
}

.brand small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-nav a {
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
}

.topbar-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.shell {
  padding: 1.4rem 0 2.5rem;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.hero,
.page-title {
  margin-top: 0.9rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
  align-items: stretch;
}

.simple-home {
  min-height: min(720px, calc(100vh - 150px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 3rem) 0;
}

.simple-home.compact {
  min-height: min(520px, calc(100vh - 150px));
}

.simple-hero {
  width: min(760px, 100%);
  display: grid;
  justify-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 6vw, 3rem);
  text-align: center;
}

.simple-hero h1 {
  font-size: clamp(2.8rem, 9vw, 5rem);
}

.simple-hero .subtitle {
  max-width: 40rem;
}

.big-action {
  min-width: min(360px, calc(100vw - 4rem));
  min-height: 64px;
  font-size: 1.15rem;
}

.join-card-minimal {
  width: min(520px, 100%);
  display: grid;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
}

.round-strip {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.round-strip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid rgba(15, 76, 129, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.4rem 0.7rem;
}

.round-strip span.active {
  border-color: rgba(161, 121, 42, 0.36);
  background: rgba(161, 121, 42, 0.12);
  color: var(--ink);
}

.hero-copy,
.status-card,
.panel-card,
.board-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.98), var(--surface-soft));
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 360px;
  display: grid;
  align-content: center;
  gap: 1.1rem;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.status-card {
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: 1.25rem;
}

.badge,
.eyebrow,
.pill {
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.badge {
  width: fit-content;
  display: inline-flex;
  border: 1px solid rgba(15, 76, 129, 0.18);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.42rem 0.75rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 4.3rem);
  line-height: 0.98;
}

h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  line-height: 1.08;
}

.subtitle {
  max-width: 58ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

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

.hero-actions,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  padding: 0.72rem 1rem;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 14px 28px rgba(15, 76, 129, 0.24);
}

.button.secondary {
  border-color: rgba(15, 76, 129, 0.22);
  background: #fff;
  color: var(--accent);
}

.button.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.24);
}

.status-list {
  display: grid;
  gap: 0.65rem;
}

.status-list span,
.info-tile,
.summary-grid > div {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  padding: 0.8rem;
  font-weight: 700;
}

.card-grid,
.info-grid,
.results-layout,
.join-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.info-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel-card,
.board-card {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
}

.panel-head,
.game-header,
.board-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
  color: rgba(15, 23, 42, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.35rem 0.62rem;
}

.form,
.compact-form {
  display: grid;
  gap: 0.8rem;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
}

.setup-layout {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.field-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.category-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.category-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  min-height: 86px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.85rem;
}

.category-option input {
  width: 18px;
  min-height: 18px;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.category-option small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.alert {
  border-left: 4px solid var(--danger);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
  padding: 0.85rem 1rem;
}

.join-card {
  align-content: start;
}

.game-shell,
.player-shell {
  display: grid;
  gap: 1rem;
}

.game-header {
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
}

.game-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.game-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.header-strip {
  flex-basis: 100%;
  justify-content: flex-start;
}

.timer {
  display: inline-grid;
  min-width: 72px;
  min-height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.monitor-layout,
.player-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 270px;
  gap: 1rem;
  align-items: start;
}

.player-layout {
  grid-template-columns: 280px minmax(0, 1fr) 260px;
}

.side-column,
.panel-stack {
  display: grid;
  gap: 1rem;
}

.qr-panel {
  text-align: center;
}

.qr-image {
  width: min(210px, 100%);
  aspect-ratio: 1;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 16px;
  background: #fff;
  padding: 0.6rem;
  margin-inline: auto;
}

.room-code {
  display: block;
  margin-top: 0.1rem;
  font-size: 1.8rem;
  letter-spacing: 0.12em;
}

.qr-panel small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.control-grid {
  display: grid;
  gap: 0.6rem;
}

.control-grid .button {
  width: 100%;
}

.board-column {
  display: grid;
  min-width: 0;
  gap: 1rem;
}

.board-card {
  padding: 1rem;
}

.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 11 / 7.2;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
}

.canvas-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.monitor-canvas {
  min-height: 420px;
}

.player-canvas {
  min-height: 360px;
}

.empty-board {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-board strong {
  color: rgba(15, 23, 42, 0.66);
  font-size: 1.15rem;
}

.empty-board.is-hidden {
  display: none;
}

.draw-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  border: 1px solid rgba(15, 76, 129, 0.14);
  border-radius: 14px;
  background: var(--accent-soft);
  padding: 0.75rem;
}

.draw-tools label {
  min-width: 120px;
  font-size: 0.82rem;
}

.draw-tools input[type="color"] {
  width: 54px;
  min-height: 38px;
  padding: 0.25rem;
}

.draw-tools input[type="range"] {
  min-height: 38px;
  padding: 0;
}

.icon-button {
  min-height: 40px;
  border: 1px solid rgba(15, 76, 129, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  padding: 0.6rem 0.8rem;
}

.icon-button.is-active {
  background: var(--accent);
  color: #fff;
}

.player-list,
.score-list,
.own-guesses {
  display: grid;
  gap: 0.65rem;
}

.player-list.compact {
  display: flex;
  flex-wrap: wrap;
}

.player-row,
.score-row,
.player-chip,
.own-guess {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.65rem 0.75rem;
}

.player-row.active {
  border-color: rgba(15, 76, 129, 0.32);
  background: rgba(15, 76, 129, 0.09);
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: rgba(15, 76, 129, 0.16);
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
}

.score-list.large .score-row {
  font-size: 1.2rem;
  padding: 1rem;
}

.score-row strong,
.player-row strong {
  font-variant-numeric: tabular-nums;
}

.reveal-panel {
  border-color: rgba(161, 121, 42, 0.28);
  background: linear-gradient(160deg, #fff, rgba(161, 121, 42, 0.08));
}

.secret-card {
  border-color: rgba(15, 76, 129, 0.28);
  background: linear-gradient(160deg, #fff, rgba(15, 76, 129, 0.09));
}

.secret-card h2,
.reveal-panel h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  text-transform: uppercase;
}

.form-status {
  min-height: 1.4rem;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.form-status.is-correct {
  color: var(--accent);
}

.form-status.is-error {
  color: var(--danger);
}

.own-guess {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.9rem;
}

.own-guess.correct {
  color: var(--accent);
  font-weight: 800;
}

.info-tile {
  display: grid;
  gap: 0.3rem;
}

.info-tile span {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

.results-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.summary-grid {
  display: grid;
  gap: 0.7rem;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-grid strong {
  display: block;
  margin-top: 0.2rem;
}

.catalog-shell,
.catalog-grid,
.catalog-list {
  display: grid;
  gap: 1rem;
}

.catalog-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.catalog-header {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
  padding: 1.2rem;
}

.catalog-item {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.8rem;
}

.catalog-item small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

@media (max-width: 1080px) {
  .monitor-layout,
  .player-layout {
    grid-template-columns: 1fr;
  }

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

  .board-column {
    order: -1;
  }

  .monitor-canvas,
  .player-canvas {
    min-height: 330px;
  }
}

@media (max-width: 820px) {
  .hero,
  .card-grid,
  .info-grid,
  .join-shell,
  .results-layout,
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: 280px;
  }

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

  .topbar-nav {
    justify-content: flex-start;
  }

  .game-header,
  .panel-head,
  .board-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-meta {
    justify-content: flex-start;
  }

  .side-column,
  .panel-stack,
  .field-grid {
    grid-template-columns: 1fr;
  }

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

  .simple-home {
    min-height: auto;
    place-items: stretch;
  }

  .simple-hero {
    justify-items: stretch;
    text-align: left;
  }

  .simple-hero .badge,
  .simple-hero .round-strip {
    justify-self: start;
  }

  .full-mobile,
  .inline-form .button,
  .form .button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar,
  .shell,
  .footer {
    width: min(100% - 1rem, 1240px);
  }

  .topbar {
    border-radius: 14px;
  }

  .topbar-nav a {
    padding: 0.5rem 0.55rem;
  }

  .hero-copy,
  .status-card,
  .panel-card,
  .board-card,
  .game-header {
    border-radius: 14px;
  }

  h1 {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  .footer {
    flex-direction: column;
  }

  .canvas-frame {
    aspect-ratio: 1 / 0.82;
  }

  .monitor-canvas,
  .player-canvas {
    min-height: 280px;
  }

  .draw-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .draw-tools label,
  .draw-tools .button,
  .draw-tools .icon-button {
    width: 100%;
  }
}
