:root {
  color-scheme: dark;
  --bg: #121016;
  --bg-elevated: #1a1620;
  --panel: rgba(28, 23, 35, 0.94);
  --panel-soft: rgba(37, 31, 46, 0.94);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f7f1e6;
  --muted: #c4b8a8;
  --muted-soft: #9a8f82;
  --wood-a: #341f1b;
  --wood-b: #1e1413;
  --blue: #2e97d1;
  --blue-deep: #1b6eaa;
  --red: #d85a42;
  --red-deep: #a93e30;
  --cream: #ead9bc;
  --cream-deep: #d7c3a0;
  --black-card: #1b1a1f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
  --radius: 20px;
  /* Spymaster tile palette — shared by board tiles, team panels, log, overlay, pills */
  --cn-tile-red-grad: linear-gradient(180deg, #ff4d44 0%, #c4001a 100%);
  --cn-tile-red-inset: inset 0 1px 0 rgba(255, 255, 255, 0.42);
  --cn-tile-red-border: rgba(120, 12, 24, 0.35);
  --cn-tile-blue-grad: linear-gradient(180deg, #1ecbff 0%, #0066d4 100%);
  --cn-tile-blue-inset: inset 0 1px 0 rgba(255, 255, 255, 0.44);
  --cn-tile-blue-border: rgba(0, 72, 140, 0.38);
  --history-elo-win: #7dcea8;
  --history-elo-loss: #f0a0a0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 151, 92, 0.12), transparent 32%),
    linear-gradient(180deg, #201725 0%, #110f14 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.03), transparent 26%);
}

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

button {
  border: 0;
  border-radius: 16px;
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, #f4935b 0%, #dc6947 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(220, 105, 71, 0.24);
}

button:disabled {
  cursor: default;
  opacity: 0.7;
  box-shadow: none;
}

.secondary-button,
.ghost-button,
.tab-button,
.inline-room-link {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.danger-button {
  background: linear-gradient(180deg, #c74d4d 0%, #8e2f34 100%);
  box-shadow: 0 10px 24px rgba(143, 47, 52, 0.24);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  backdrop-filter: blur(16px);
  background: rgba(15, 13, 19, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.header-actions.compact {
  justify-content: flex-end;
  margin-left: auto;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.34);
}

.drawer-menu,
.settings-popover {
  position: fixed;
  z-index: 30;
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  background: rgba(24, 20, 30, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.drawer-menu {
  top: 4.2rem;
  left: 0.75rem;
  min-width: 13rem;
}

.settings-popover {
  top: 4.2rem;
  right: 0.75rem;
  min-width: min(18rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-link {
  justify-content: flex-start;
  padding: 0.82rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: none;
}

.drawer-link-logout {
  margin-top: 0.35rem;
  color: rgba(255, 180, 170, 0.95);
  border-color: rgba(200, 90, 90, 0.35);
  background: rgba(120, 40, 45, 0.22);
}

.compact-form {
  margin-top: 0.35rem;
}

.minimal-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.minimal-brand-flex {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.minimal-brand-flex .brand-mark {
  justify-content: center;
}

.brand-stack {
  display: grid;
  gap: 0.25rem;
}

.brand-button,
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  background: none;
  color: var(--text);
  box-shadow: none;
  border: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.brand-mark-wordmark {
  font-family: "Fjalla One", system-ui, sans-serif;
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  gap: 0.35rem;
}

.brand-subtitle {
  color: var(--muted-soft);
  font-size: 0.88rem;
}

.header-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.header-tabs .tab-button {
  padding: 0.8rem 0.75rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.92rem;
}

.page {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: 1rem;
}

.page-live-game {
  width: 100%;
  max-width: none;
  padding: 0.75rem;
}

.page-live-game .game-page-shell {
  width: 100%;
  margin-inline: auto;
}

.game-page-viewport {
  width: 100%;
}

.page-live-game .game-page-scale {
  width: 100%;
}

.page-game {
  width: min(100%, 1100px);
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.hero-panel {
  background:
    linear-gradient(135deg, rgba(46, 151, 209, 0.22), rgba(216, 90, 66, 0.14)),
    var(--panel);
}

.manual-teams-banner,
.lobby-game-mode-banner {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.lobby-game-mode-banner {
  border-color: rgba(40, 40, 48, 0.85);
  background: linear-gradient(135deg, rgba(55, 55, 62, 0.45), rgba(28, 28, 32, 0.55));
}

.lobby-game-mode-banner .eyebrow {
  margin-bottom: 0.35rem;
}

.lobby-game-mode-note {
  margin: 0.4rem 0 0;
}

button.player-chip {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  margin: 0;
  font: inherit;
  color: inherit;
  width: 100%;
  text-align: inherit;
  cursor: pointer;
}

.admin-game-mode-form {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-config-group {
  display: grid;
  gap: 0.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-config-group:last-of-type {
  padding-bottom: 0;
  border-bottom: none;
}

.admin-config-group > h3,
.panel > h3 {
  margin: 0;
}

.tile.tile--pick-black:not(:disabled) {
  cursor: pointer;
  outline: 2px solid rgba(255, 255, 255, 0.22);
  outline-offset: 1px;
}

.tile.tile--pick-black:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.tile-shell--black-pick-selected .tile.tile--pick-black {
  outline-color: rgba(120, 200, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(120, 200, 255, 0.25);
}

.tile.tile--pick-trap:not(:disabled),
.tile.tile--pick-rename:not(:disabled),
.tile.tile--trap-resolve-pick:not(:disabled) {
  cursor: pointer;
  outline: 2px solid rgba(255, 255, 255, 0.22);
  outline-offset: 1px;
}

.tile.tile--pick-trap:not(:disabled):hover,
.tile.tile--pick-rename:not(:disabled):hover,
.tile.tile--trap-resolve-pick:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.tile-shell--black-pick-selected .tile.tile--pick-trap,
.tile-shell--black-pick-selected .tile.tile--pick-rename,
.tile-shell--black-pick-selected .tile.tile--trap-resolve-pick {
  outline-color: rgba(120, 200, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(120, 200, 255, 0.25);
}

.tile-trap-badge {
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.92;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.tile-trap-badge--red {
  text-shadow: 0 0 6px rgba(216, 90, 66, 0.55);
}

.tile-trap-badge--blue {
  text-shadow: 0 0 6px rgba(46, 151, 209, 0.55);
}

.guess-pill--trap {
  border-style: dashed;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.35);
}

.log-pill-trap {
  font-size: 0.62rem;
  line-height: 1;
}

.action-card-pick-black {
  padding: 0.75rem 1rem;
}

.pick-black-hint {
  margin: 0 0 0.5rem;
  color: rgba(255, 244, 232, 0.88);
  font-size: 0.95rem;
  line-height: 1.35;
}

.log-round--black-picks,
.history-log-row.log-round--black-picks {
  text-align: left;
}

.black-pick-log-title {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(232, 228, 220, 0.88);
  margin-bottom: 0.35rem;
}

.black-pick-log-body .black-pick-log-line,
.history-black-picks-body {
  font-size: 0.9rem;
  line-height: 1.45;
}

.black-pick-log-team {
  font-weight: 600;
  color: rgba(200, 210, 230, 0.95);
}

.history-log-row.log-round--black-picks {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.login-shell,
.stack-layout,
.lobby-layout {
  display: grid;
  gap: 1rem;
}

.login-shell {
  min-height: 100svh;
  align-items: center;
  padding-block: 2rem;
}

.login-hero,
.login-panel {
  width: min(100%, 460px);
  margin-inline: auto;
}

.login-hero {
  display: grid;
  gap: 0.9rem;
  text-align: center;
}

.login-hero h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 0.98;
}

.login-hero-brand {
  gap: 0.35rem;
}

.login-brand-mark {
  font-size: clamp(3.5rem, 18vw, 6.5rem);
  line-height: 1;
  margin-bottom: 0.15rem;
}

.login-hero h1.login-title-wordmark {
  margin: 0;
  font-size: clamp(1.85rem, 6.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.05;
}

.login-badge,
.eyebrow,
.status-pill,
.console-room {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.stack-form,
.action-form,
.admin-user-card {
  display: grid;
  gap: 0.8rem;
}

.stack-form label,
.action-form label,
.admin-user-card label {
  display: grid;
  gap: 0.3rem;
}

.button-row,
.panel-title-row,
.room-card-top,
.room-card-bottom,
.turn-button-row,
.utility-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.panel-title-row {
  justify-content: space-between;
}

.list,
.chip-list,
.leaderboard-list,
.team-player-list,
.console-log {
  display: grid;
  gap: 0.7rem;
}

.list-row,
.leaderboard-row,
.history-card,
.room-card,
.admin-user-card,
.action-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--panel-soft);
}

.list-row,
.leaderboard-row {
  padding: 0.85rem 0.95rem;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.queue-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.queue-pills-empty {
  width: 100%;
}

.queue-pill-wrap {
  flex: 0 0 auto;
  max-width: 100%;
}

button.queue-pill,
.queue-pill.queue-pill--static {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  margin: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  color: var(--text);
  box-shadow: none;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  line-height: 1.2;
}

.queue-pill.queue-pill--static {
  cursor: default;
}

button.queue-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-elevated);
}

.queue-pill--self {
  border-color: rgba(244, 147, 91, 0.45);
  box-shadow: 0 0 0 1px rgba(244, 147, 91, 0.2) inset;
}

.queue-pill .avatar-tiny {
  flex-shrink: 0;
}

.queue-pill-body {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.queue-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 11rem;
  font-weight: 700;
}

.queue-role-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.queue-role-pill--spy {
  color: #ffb8b0;
  border-color: rgba(216, 90, 66, 0.35);
  background: rgba(216, 90, 66, 0.14);
}

.queue-gamemode-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(240, 236, 228, 0.92);
}

.queue-role-pill--op {
  color: #9fd8ff;
  border-color: rgba(46, 151, 209, 0.35);
  background: rgba(46, 151, 209, 0.14);
}

.lobby-hero-actions {
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.lobby-next-game-sentence {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.queue-pill-wants {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.12rem;
  line-height: 1.35;
}

.lobby-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.lobby-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 12rem;
  padding: 0.4rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 0.25rem;
}

.lobby-vk-panel {
  min-width: 14rem;
}

.lobby-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lobby-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.game-room-settings-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-self: center;
}

.game-room-settings-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  flex-shrink: 0;
}

.game-room-settings-cog {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: block;
  opacity: 0.88;
}

.game-room-settings-panel {
  position: absolute;
  bottom: calc(100% + 6px);
  top: auto;
  left: 0;
  right: auto;
  z-index: 40;
  min-width: 12rem;
  padding: 0.4rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: none;
  gap: 0.25rem;
}

.game-room-settings-wrap.is-open .game-room-settings-panel {
  display: grid;
}

.game-room-settings-danger {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  font: inherit;
  text-align: center;
  justify-content: center;
}

.game-room-settings-menu-btn {
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  font: inherit;
  text-align: center;
  justify-content: center;
}

.game-room-settings-sub {
  display: grid;
  gap: 0.35rem;
  padding: 0.25rem 0 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.15rem;
}

.game-room-settings-sub-btn {
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  font-size: 0.88rem;
  text-align: center;
  justify-content: center;
}

.game-room-settings-sub--form {
  gap: 0.6rem;
}

.game-room-settings-choice-block,
.game-room-settings-mode-grid {
  display: grid;
  gap: 0.35rem;
}

.game-room-settings-choice-row {
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.game-room-settings-slot-grid {
  display: grid;
  gap: 0.45rem;
}

.game-room-settings-slot {
  display: grid;
  gap: 0.2rem;
  font-size: 0.86rem;
}

.game-room-settings-slot select {
  width: 100%;
}

.game-room-settings-form-message {
  margin: 0;
  font-size: 0.82rem;
}

.game-room-settings-submit {
  width: 100%;
  justify-content: center;
}

.game-room-spectator-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: 10rem;
  overflow-y: auto;
}

.game-room-spectator-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
}

.game-room-spectator-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 1rem;
}

.game-room-spectator-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-submenu-back {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
}

.lobby-vk-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.lobby-vk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.lobby-vk-row .secondary-button {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1;
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.07));
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.avatar.avatar-tiny {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.72rem;
  vertical-align: middle;
}

.room-card,
.history-card,
.inline-room-link {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  padding: 0.95rem 1rem;
}

.history-card {
  gap: 0;
  padding: 0;
  overflow: hidden;
  text-align: center;
}

.room-card-active {
  border-color: rgba(244, 147, 91, 0.48);
  box-shadow: 0 0 0 1px rgba(244, 147, 91, 0.24) inset;
}

.room-team-line {
  font-size: 0.84rem;
}

.blue-text {
  color: #79c9ff;
}

.red-text {
  color: #ff9388;
}

.leaderboard-table {
  display: grid;
  gap: 0.5rem;
}

.leaderboard-head,
.leaderboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: center;
}

.leaderboard-head {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-sort {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  box-shadow: none;
  text-align: left;
}

.table-sort.active {
  color: #fff;
}

.leaderboard-row {
  padding: 0.75rem 0.85rem;
}

.leaderboard-row.self {
  border-color: rgba(244, 147, 91, 0.45);
  background: rgba(244, 147, 91, 0.1);
}

.leaderboard-rank {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  min-width: 0;
}

.leaderboard-rank .avatar,
.user-pill .avatar {
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.95rem;
}

.game-page-shell {
  display: grid;
  gap: 0.55rem;
  min-height: 100svh;
}

.game-page-shell.team-theme-red {
  background: linear-gradient(180deg, rgba(255, 77, 68, 0.14), rgba(0, 0, 0, 0));
}

.game-page-shell.team-theme-blue {
  background: linear-gradient(180deg, rgba(30, 203, 255, 0.12), rgba(0, 0, 0, 0));
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(0, 0.84fr) minmax(170px, 1.4fr) minmax(0, 0.84fr);
  gap: 0.4rem;
  align-items: stretch;
}

.team-panel,
.center-console,
.board-panel {
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.team-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.36rem;
  padding: 0.46rem 0.44rem 0.4rem;
  color: #fff;
  min-height: 10.65rem;
  align-self: stretch;
}

.team-panel.blue {
  background: var(--cn-tile-blue-grad);
  box-shadow: var(--cn-tile-blue-inset), var(--shadow);
}

.team-panel.red {
  background: var(--cn-tile-red-grad);
  box-shadow: var(--cn-tile-red-inset), var(--shadow);
}

.team-panel.red.active {
  box-shadow:
    0 0 0 3px rgba(66, 204, 107, 0.82),
    var(--cn-tile-red-inset),
    var(--shadow);
}

.team-panel.blue.active {
  box-shadow:
    0 0 0 3px rgba(66, 204, 107, 0.82),
    var(--cn-tile-blue-inset),
    var(--shadow);
}

.team-panel-top {
  display: flex;
  justify-content: center;
  align-items: center;
}

.team-title-center {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

.team-score-foot {
  text-align: center;
  font-size: clamp(1.65rem, 5.5vw, 2.35rem);
  font-weight: 900;
  line-height: 1;
  padding-top: 0.2rem;
  color: rgba(255, 255, 255, 0.98);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.team-player-list {
  display: grid;
  grid-template-rows: repeat(2, minmax(2.75rem, auto));
  gap: 0.4rem;
  align-content: start;
}

.team-player-list-vertical {
  align-content: center;
}

.player-chip {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.28rem 0.35rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.12);
}

.player-chip-stack {
  min-height: 4.6rem;
  padding: 0.35rem 0.28rem;
}

.player-chip-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1;
}

.player-chip-inner-stack {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.28rem;
  width: 100%;
}

.team-panel .player-avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
  border-radius: 999px;
}

.team-panel .player-chip .avatar {
  width: 1.3rem;
  height: 1.3rem;
  font-size: 0.82rem;
}

.team-panel .player-chip-stack .avatar {
  width: 2.45rem;
  height: 2.45rem;
  font-size: 1.2rem;
}

.player-meta-stack {
  align-items: center;
  text-align: center;
  width: 100%;
}

.player-meta-stack strong {
  max-width: 100%;
}

.profile-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-heading .avatar {
  width: 2.8rem;
  height: 2.8rem;
  font-size: 1.5rem;
}

.player-chip.self {
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.team-panel.red .player-chip.timer-active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 12px rgba(255, 200, 180, 0.45);
  background: rgba(0, 0, 0, 0.2);
}

.team-panel.blue .player-chip.timer-active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 12px rgba(180, 220, 255, 0.45);
  background: rgba(0, 0, 0, 0.2);
}

.player-chip.player-presence-away .player-avatar-wrap {
  isolation: isolate;
}

.player-chip.player-presence-away .avatar {
  opacity: 0.82;
  filter: saturate(0.78) brightness(0.92);
}

.team-panel .player-avatar-wrap .player-presence-overlay {
  position: absolute;
  right: -0.12rem;
  bottom: -0.12rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  width: 1.05rem;
  height: 1.05rem;
  background: rgba(43, 39, 51, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

.team-panel .player-avatar-wrap .player-presence-overlay-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #d6cabd;
  line-height: 1;
}

.team-panel .player-avatar-wrap .player-presence-overlay-icon svg {
  width: 0.68rem;
  height: 0.68rem;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-meta {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.player-meta strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-meta .player-role-line {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  opacity: 0.9;
  font-size: 0.64rem;
  line-height: 1.25;
}

button.player-role-line.test-play-seat-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

button.player-role-line.test-play-seat-btn:hover {
  text-decoration: underline;
  opacity: 1;
}

button.player-role-line.test-play-seat-btn:focus-visible {
  outline: 2px solid rgba(120, 180, 255, 0.95);
  outline-offset: 2px;
  border-radius: 2px;
}

.center-console {
  display: grid;
  gap: 0.38rem;
  padding: 0.48rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    linear-gradient(180deg, var(--wood-a) 0%, var(--wood-b) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.game-log-console {
  min-height: 7.95rem;
  align-content: start;
}

.console-log-title {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 244, 232, 0.9);
  font-size: 0.82rem;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.console-log {
  max-height: 12.15rem;
  overflow-y: auto;
  padding-right: 0.15rem;
  align-content: start;
  align-items: start;
}

.log-round {
  display: grid;
  gap: 0.32rem;
}

.log-round.live {
  filter: saturate(1.08);
}

.clue-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  border-radius: 14px;
  padding: 0.28rem 0.35rem 0.28rem 0.28rem;
}

.log-round.blue .clue-banner {
  background: var(--cn-tile-blue-grad);
  box-shadow: var(--cn-tile-blue-inset);
}

.log-round.red .clue-banner {
  background: var(--cn-tile-red-grad);
  box-shadow: var(--cn-tile-red-inset);
}

.clue-word {
  display: block;
  border-radius: 10px;
  background: #fff;
  color: #1b1510;
  padding: 0.42rem 0.55rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.clue-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #211710;
  font-weight: 900;
}

.guess-row {
  display: flex;
  gap: 0.14rem;
  flex-wrap: wrap;
}

.guess-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  padding: 0.1rem 0.26rem;
  border-radius: 8px;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
}

.guess-pill span {
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guess-pill-red {
  background: var(--cn-tile-red-grad);
  color: #1a0604;
  border-color: var(--cn-tile-red-border);
  box-shadow: var(--cn-tile-red-inset);
}

.guess-pill-blue {
  background: var(--cn-tile-blue-grad);
  color: #041520;
  border-color: var(--cn-tile-blue-border);
  box-shadow: var(--cn-tile-blue-inset);
}

.guess-pill-neutral {
  background: linear-gradient(180deg, #fffdf8 0%, #e8dfd0 100%);
  color: #2a2218;
  border: 2px solid rgba(90, 72, 50, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset, 0 1px 2px rgba(0, 0, 0, 0.08);
}

.guess-pill-black {
  background: linear-gradient(180deg, #3a3842 0%, #0c0c10 100%);
  color: #f4f2f8;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5) inset;
}

.log-pill-tick {
  width: 0.65rem;
  height: 0.65rem;
  flex-shrink: 0;
}

.guess-pill-end-pass {
  background: linear-gradient(180deg, #c8f5d8 0%, #4ecf7a 100%);
  color: #0a2e14;
  border-color: rgba(20, 120, 55, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35) inset, 0 1px 2px rgba(0, 0, 0, 0.08);
}

.guess-pill-skip-timeout {
  background: linear-gradient(180deg, #fff3c2 0%, #f0c84a 100%);
  color: #3d3208;
  border-color: rgba(180, 140, 20, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35) inset, 0 1px 2px rgba(0, 0, 0, 0.08);
}

.guess-pill-skip-timeout .log-pill-skip-by {
  font-weight: 750;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-strip {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.status-strip--game-over {
  grid-template-columns: minmax(0, 1fr) auto;
  border-width: 2px;
}

.status-strip--winner-red {
  background: linear-gradient(180deg, rgba(255, 77, 68, 0.32), rgba(120, 12, 24, 0.42));
  border-color: rgba(255, 140, 120, 0.42);
}

.status-strip--winner-blue {
  background: linear-gradient(180deg, rgba(30, 203, 255, 0.22), rgba(0, 72, 140, 0.48));
  border-color: rgba(120, 200, 255, 0.38);
}

.status-strip--turn-red {
  border-color: rgba(255, 100, 88, 0.38);
  box-shadow: 0 0 0 1px rgba(255, 77, 68, 0.14) inset;
}

.status-strip--turn-blue {
  border-color: rgba(100, 200, 255, 0.36);
  box-shadow: 0 0 0 1px rgba(30, 180, 255, 0.12) inset;
}

.status-strip-lobby {
  justify-self: end;
}

.status-strip-main {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.status-strip-main span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 750;
  font-size: 0.92rem;
}

.status-strip-timer {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-strip-timer.timer-positive {
  color: #6ef59a;
}

.status-strip-timer.timer-overrun {
  color: #ff7a7a;
}

.status-strip-timer.winner-red {
  color: #ff9388;
}

.status-strip-timer.winner-blue {
  color: #79c9ff;
}

.action-card,
.action-form {
  padding: 0.72rem;
}

.action-card {
  display: grid;
  gap: 0.65rem;
}

.action-title {
  font-weight: 800;
  font-size: 0.95rem;
}

.action-card-game-over {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
  padding: 1rem 0.75rem;
}

.action-title-game-over {
  font-weight: 900;
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.action-card-blank {
  min-height: 0;
  padding: 0.35rem 0.72rem;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.action-card-operative {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 0.72rem;
}

/** Left settings + visually centered primary action (matched edge columns). */
.room-action-bar-balanced {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 0.45rem;
}

.room-action-bar-edge--left {
  justify-self: start;
}

.room-action-bar-center {
  justify-self: center;
}

.room-action-bar-edge--right {
  justify-self: end;
  width: 2.65rem;
  min-height: 1px;
}

.room-action-settings-only {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.clue-form-inline .clue-form-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
}

.clue-form-inline .clue-inline-word {
  margin: 0;
  min-width: 0;
}

.clue-form-inline .clue-inline-word input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
}

.clue-form-inline .clue-inline-number {
  margin: 0;
}

.clue-form-inline .clue-inline-number select {
  width: auto;
  min-width: 3.2rem;
  padding: 0.65rem 0.5rem;
  border-radius: 12px;
}

.clue-form-inline .clue-inline-submit {
  padding: 0.65rem 1rem;
  border-radius: 12px;
}

.clue-form-inline .clue-inline-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.board-panel {
  position: relative;
  z-index: 1;
  padding: 0.4rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 20%),
    linear-gradient(180deg, var(--wood-a) 0%, var(--wood-b) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.board-panel-inner {
  position: relative;
}

.board-clue-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0.5rem;
}

.board-clue-overlay[hidden] {
  display: none !important;
}

.board-clue-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  max-width: min(92%, 22rem);
  border-radius: 16px;
  padding: 0.42rem 0.5rem 0.42rem 0.42rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.94);
  transition:
    opacity 0.2s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.board-clue-banner.is-visible {
  opacity: 1;
  transform: scale(1);
}

.board-clue-banner.is-leaving {
  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.board-clue-banner--red {
  background: var(--cn-tile-red-grad);
  box-shadow: var(--cn-tile-red-inset), 0 12px 40px rgba(0, 0, 0, 0.35);
}

.board-clue-banner--blue {
  background: var(--cn-tile-blue-grad);
  box-shadow: var(--cn-tile-blue-inset), 0 12px 40px rgba(0, 0, 0, 0.35);
}

.board-clue-banner .board-clue-word {
  display: block;
  border-radius: 12px;
  background: #fff;
  color: #1b1510;
  padding: 0.55rem 0.65rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(1.15rem, 4.2vw, 1.65rem);
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.board-clue-banner .board-clue-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #211710;
  font-weight: 900;
  font-size: clamp(1.1rem, 3.8vw, 1.45rem);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.32rem;
}

.game-page-shell .board-grid {
  gap: calc(0.32rem - 2px);
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  aspect-ratio: 1;
  padding: 0.18rem;
  text-align: center;
  border-radius: 12px;
  border: 2px solid rgba(33, 25, 16, 0.18);
  background: linear-gradient(180deg, #f2e2c3 0%, #d5bc94 100%);
  color: #2f2417;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
  overflow: hidden;
}

/* Board tiles are disabled when not guessable; do not dim (global button:disabled uses opacity: 0.7). */
button.tile:disabled {
  opacity: 1;
  cursor: default;
}

.tile-shell {
  position: relative;
  padding: 3px;
  border-radius: 14px;
}

.tile-shell--puff {
  z-index: 2;
}

.tile-shell--first-turn-pulse {
  z-index: 1;
}

.tile-shell--first-turn-pulse::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 12px;
  pointer-events: none;
  background: transparent;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.42),
    0 0 14px rgba(255, 255, 255, 0.32),
    0 0 28px rgba(255, 255, 255, 0.16);
  animation: tile-first-turn-edge-glow 1.45s ease-in-out infinite;
}

.tile-shell--first-turn-pulse .tile.red:not(.revealed),
.tile-shell--first-turn-pulse .tile.blue:not(.revealed) {
  animation: tile-first-turn-pulse 1.55s ease-in-out infinite;
}

.tile-shell--puff::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130%;
  height: 130%;
  margin-left: -65%;
  margin-top: -65%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    var(--puff-a, rgba(255, 255, 255, 0.95)) 0%,
    var(--puff-b, rgba(255, 200, 120, 0.45)) 38%,
    transparent 68%
  );
  opacity: 0;
  transform: scale(0.35);
  animation: tile-puff-burst 0.55s ease-out forwards;
}

@keyframes tile-puff-burst {
  0% {
    opacity: 0.95;
    transform: scale(0.35);
  }
  55% {
    opacity: 0.85;
    transform: scale(1.05);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes tile-first-turn-pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1) saturate(1);
  }
  50% {
    transform: translateY(-1px) scale(1.018);
    filter: brightness(1.16) saturate(1.1);
  }
}

@keyframes tile-first-turn-edge-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.32),
      0 0 10px rgba(255, 255, 255, 0.2),
      0 0 22px rgba(255, 255, 255, 0.09);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 0.98),
      0 0 26px rgba(255, 255, 255, 0.7),
      0 0 50px rgba(255, 255, 255, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-shell--puff::after {
    animation: none;
    opacity: 0;
    transform: scale(1);
  }

  .tile-shell--first-turn-pulse::before,
  .tile-shell--first-turn-pulse .tile.red:not(.revealed),
  .tile-shell--first-turn-pulse .tile.blue:not(.revealed) {
    animation: none;
    transform: none;
    filter: none;
  }

  .tile-shell--first-turn-pulse::before {
    animation: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.38);
  }

  .board-clue-banner {
    transition: opacity 0.12s ease;
    transform: none;
  }

  .board-clue-banner.is-visible,
  .board-clue-banner.is-leaving {
    transform: none;
  }

  .tile.revealed.guess-faded::before {
    transition: none;
  }

  .tile.revealed.guess-faded .tile-word {
    transition: opacity 0.1s ease;
  }
}

.tile-shell.selected {
  background: rgba(110, 255, 140, 0.22);
  box-shadow: 0 0 0 2px rgba(80, 240, 120, 0.55);
}

.tile-shell.selected .tile {
  box-shadow: inset 0 0 0 5px rgba(94, 255, 130, 0.95);
}

.tile-confirm {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  bottom: auto;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #8af08c 0%, #42c255 100%);
  color: #0a180c;
  box-shadow: 0 4px 14px rgba(56, 200, 90, 0.55);
  z-index: 3;
}

.tile-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 40%),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.2), transparent 26%),
    linear-gradient(180deg, #f4e3c5 0%, #dcc29b 100%);
}

/* Let key colours read through: no beige fill on the overlay */
.tile.red .tile-art,
.tile.blue .tile-art,
.tile.black .tile-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 42%),
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.26), transparent 28%);
}

.tile-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 46%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.06rem 0.1rem 0.16rem;
  background: linear-gradient(180deg, rgba(65, 48, 32, 0.06) 0%, rgba(48, 33, 18, 0.88) 100%);
  overflow: hidden;
}

.tile-word-scaler {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.tile-word {
  display: inline-block;
  white-space: nowrap;
  max-width: none;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: clamp(1.2rem, 4.1vw, 1.75rem);
  line-height: 1;
  text-transform: uppercase;
  color: #fffefd;
  font-family: "Fjalla One", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 1px rgba(0, 0, 0, 0.35);
  text-align: center;
  transform-origin: center center;
  will-change: transform;
}

.tile-word-medium {
  font-size: clamp(1.05rem, 3.55vw, 1.52rem);
}

.tile-word-long {
  font-size: clamp(0.92rem, 3.15vw, 1.32rem);
}

.tile-word-extra-long {
  font-size: clamp(0.62rem, 2.35vw, 1.02rem);
  letter-spacing: 0.01em;
}

.tile.revealed {
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.tile.revealed.guess-faded {
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.32);
}

/* Guessed: inset dark panel — tall when word hidden, top cap when expanded */
.tile.revealed.guess-faded::before {
  content: '';
  position: absolute;
  left: 9%;
  right: 9%;
  top: 6%;
  bottom: 9%;
  height: auto;
  z-index: 3;
  pointer-events: none;
  border-radius: 9px;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.32) 100%);
  transition:
    top 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    right 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    bottom 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.34s ease;
}

/* Top-cap panel (~44% height): animate `bottom` only so we avoid height: auto vs fixed */
.tile.revealed.guess-faded.expanded::before,
.tile.revealed.guess-faded.game-over-reveal::before {
  bottom: 50%;
}

.tile.revealed.guess-faded .tile-art {
  z-index: 1;
}

.tile.revealed.guess-faded-red::before {
  background: linear-gradient(180deg, rgba(100, 28, 22, 0.38) 0%, rgba(55, 18, 14, 0.46) 100%);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 160, 140, 0.22);
}

.tile.revealed.guess-faded-blue::before {
  background: linear-gradient(180deg, rgba(24, 72, 120, 0.36) 0%, rgba(12, 48, 88, 0.44) 100%);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(160, 220, 255, 0.2);
}

.tile.revealed.guess-faded-neutral::before {
  background: linear-gradient(180deg, rgba(52, 44, 34, 0.46) 0%, rgba(28, 24, 18, 0.58) 100%);
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tile.revealed.guess-faded-black::before {
  background: linear-gradient(180deg, rgba(28, 26, 32, 0.52) 0%, rgba(12, 10, 14, 0.62) 100%);
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tile.guessed-covered .tile-band {
  min-height: 100%;
  align-items: center;
  padding-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 35%),
    linear-gradient(180deg, rgba(24, 54, 96, 0.96) 0%, rgba(13, 34, 67, 0.98) 100%);
}

.tile.guessed-covered .tile-word {
  opacity: 0;
}

.tile.guessed-covered .tile-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #5aa4db 0%, #214f8d 100%);
}

.tile.revealed.game-over-reveal .tile-art {
  opacity: 0.72;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 42%);
}

.tile.revealed.game-over-reveal .tile-word {
  opacity: 1;
}

.tile.revealed.game-over-reveal .tile-band {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.52) 100%);
}

.tile.revealed.expanded:not(.game-over-reveal) .tile-art {
  opacity: 0.62;
}

.tile.hidden {
  background: linear-gradient(180deg, #ffffff 0%, #e6e9ef 100%);
  color: #14110e;
}

.tile.operative-face {
  background: linear-gradient(180deg, #ffffff 0%, #e8ecf2 100%);
  color: #14110e;
  border-color: rgba(55, 65, 82, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.tile.operative-face .tile-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 42%),
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.38), transparent 28%);
}

.tile.operative-face .tile-band {
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.06) 100%);
}

.tile.operative-face .tile-word {
  color: #0f0e0c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.92);
}

.tile.red {
  background: var(--cn-tile-red-grad);
  color: #fff7ee;
  box-shadow: var(--cn-tile-red-inset);
  border-color: var(--cn-tile-red-border);
}

.tile.blue {
  background: var(--cn-tile-blue-grad);
  color: #f4fbff;
  box-shadow: var(--cn-tile-blue-inset);
  border-color: var(--cn-tile-blue-border);
}

.tile.neutral {
  background: linear-gradient(180deg, #faf6f0 0%, #ebe1d2 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  border-color: rgba(33, 25, 16, 0.2);
}

/* Unguessed neutral (spymaster): former guessed-neutral look */
.tile.neutral:not(.revealed) {
  background: linear-gradient(165deg, rgba(250, 236, 210, 0.94), rgba(200, 172, 132, 0.48));
  border-color: rgba(88, 70, 50, 0.2);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.06);
}

.tile.neutral:not(.revealed)::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 50%;
  z-index: 2;
  pointer-events: none;
  border-radius: 11px 11px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
  background: linear-gradient(
    180deg,
    rgba(255, 244, 220, 0.4) 0%,
    rgba(248, 232, 200, 0.2) 72%,
    rgba(248, 232, 200, 0) 100%
  );
}

.tile.neutral:not(.revealed) .tile-art {
  z-index: 1;
  background:
    repeating-linear-gradient(-12deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 48%);
  opacity: 0.88;
}

.tile.black {
  background: linear-gradient(180deg, #45414e 0%, #1c1920 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Spymaster unrevealed identity tiles: bright white word, minimal shadow */
.tile.red:not(.operative-face):not(.revealed) .tile-word,
.tile.blue:not(.operative-face):not(.revealed) .tile-word,
.tile.neutral:not(.operative-face):not(.revealed) .tile-word {
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.32);
}

.tile.black:not(.operative-face):not(.revealed) .tile-word {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.tile.red:not(.operative-face):not(.revealed) .tile-band,
.tile.blue:not(.operative-face):not(.revealed) .tile-band,
.tile.neutral:not(.operative-face):not(.revealed) .tile-band,
.tile.black:not(.operative-face):not(.revealed) .tile-band {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.03) 0%, rgba(0, 0, 0, 0.52) 100%);
}

/* Guessed: faded identity, word hidden until expanded (live + history) */
.tile.revealed.guess-faded .tile-word {
  opacity: 0;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1) 0.05s;
}

/* Slightly below #fff (unguessed) so guessed copy reads as the same family but softer */
.tile.revealed.guess-faded.expanded .tile-word {
  opacity: 0.82;
  transition-delay: 0.12s;
  color: rgba(248, 248, 250, 0.66);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.82), 0 0 2px rgba(0, 0, 0, 0.5);
}

.tile.revealed.guess-faded .tile-band {
  z-index: 2;
  min-height: 48%;
  align-items: center;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
}

.tile.revealed.guess-faded.expanded .tile-band {
  z-index: 4;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
}

.tile.revealed.guess-faded-neutral .tile-band {
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(42, 36, 28, 0.34) 42%,
    rgba(26, 22, 18, 0.66) 100%
  );
}

.tile.revealed.guess-faded-neutral.expanded .tile-band {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.04) 0%,
    rgba(42, 36, 28, 0.32) 52%,
    rgba(22, 19, 15, 0.62) 100%
  );
}

.tile.revealed.guess-faded-neutral.game-over-reveal .tile-band {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(26, 22, 18, 0.68) 100%);
}

/* Word visible above shrink panel; keep game-over band background from .game-over-reveal rule */
.tile.revealed.guess-faded.game-over-reveal .tile-band {
  z-index: 4;
}

.tile.revealed.guess-faded-red {
  background: linear-gradient(165deg, rgba(255, 198, 182, 0.97), rgba(252, 92, 72, 0.66));
  border-color: rgba(130, 36, 28, 0.3);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.05);
}

.tile.revealed.guess-faded-red .tile-art {
  background:
    repeating-linear-gradient(-22deg, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(255, 205, 192, 0.64), transparent 50%);
  opacity: 0.94;
}

.tile.revealed.guess-faded-blue {
  background: linear-gradient(165deg, rgba(200, 236, 255, 0.92), rgba(120, 186, 232, 0.52));
  border-color: rgba(28, 68, 122, 0.2);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.07);
}

.tile.revealed.guess-faded-blue .tile-art {
  background:
    repeating-linear-gradient(18deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(232, 248, 255, 0.48), transparent 52%);
  opacity: 0.9;
}

.tile.revealed.guess-faded-neutral {
  background: linear-gradient(165deg, rgba(246, 236, 220, 0.98), rgba(214, 194, 166, 0.72));
  border-color: rgba(98, 78, 56, 0.22);
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.16),
    inset 0 0 10px rgba(0, 0, 0, 0.04);
}

.tile.revealed.guess-faded-neutral .tile-art {
  background:
    repeating-linear-gradient(-12deg, rgba(96, 74, 48, 0.035) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 48%);
  opacity: 0.92;
}

.tile.revealed.guess-faded-black {
  background: linear-gradient(165deg, rgba(150, 148, 158, 0.78), rgba(88, 86, 96, 0.5));
  border-color: rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.14);
}

.tile.revealed.guess-faded-black .tile-art {
  background:
    repeating-linear-gradient(25deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 55%);
  opacity: 0.8;
}

.tile.guessable:not(:disabled),
.tile.tile--pick-black:not(:disabled) {
  transform: translateY(-1px);
}

.tile.tile--pick-black:not(:disabled) {
  cursor: pointer;
}

.tile-shell--black-pick-selected .tile.tile--pick-black {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.85),
    0 0 18px rgba(120, 200, 255, 0.35);
}

.manual-teams-banner,
.lobby-game-mode-banner {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
}

.lobby-game-mode-banner .lobby-game-mode-note {
  margin: 0.35rem 0 0;
}

.admin-game-mode-form {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.action-card-pick-black .pick-black-hint {
  margin: 0 0 0.5rem;
  line-height: 1.45;
}

.log-round--black-picks,
.history-log-row.log-round--black-picks {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.2);
}

.black-pick-log-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.black-pick-log-body {
  display: grid;
  gap: 0.25rem;
}

.black-pick-log-line {
  font-size: 0.9rem;
  line-height: 1.35;
}

.black-pick-log-team {
  font-weight: 600;
}

.history-black-picks-body {
  text-align: left;
  margin-top: 0.35rem;
}

.utility-actions {
  justify-content: center;
}

.below-board-layout {
  display: grid;
  gap: 0.55rem;
  position: relative;
  z-index: 2;
}

.room-bottom-form {
  background: var(--panel);
}

/* Live game: bottom bar + log echo board frame; status/timer accents */
.game-page-shell .console-log .muted {
  color: rgba(232, 218, 200, 0.72);
}

.game-page-shell .console-log {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.game-page-shell .console-log::-webkit-scrollbar {
  width: 6px;
}

.game-page-shell .console-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.game-page-shell .room-bottom-form {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    linear-gradient(180deg, rgba(52, 31, 27, 0.92) 0%, rgba(30, 20, 19, 0.96) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.game-page-shell .action-title-game-over {
  color: rgba(255, 244, 232, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.game-page-shell .secondary-button {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 248, 240, 0.92);
}

.game-page-shell .status-strip-main span {
  color: rgba(255, 244, 232, 0.94);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.game-page-shell .clue-inline-word input {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

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

.stats-grid > div {
  display: grid;
  gap: 0.22rem;
  padding: 0.95rem;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-grid strong {
  font-size: 1.45rem;
}

.audit-list {
  max-height: 22rem;
  overflow: auto;
}

.history-game-panel .board-grid,
.history-board .board-grid {
  gap: 0.45rem;
}

.turn-button-row {
  margin-bottom: 0.8rem;
}

.selected-turn {
  border-color: rgba(244, 147, 91, 0.52);
  box-shadow: 0 0 0 1px rgba(244, 147, 91, 0.22) inset;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.65rem;
}

.checkbox-row input {
  width: auto;
}

.form-message,
.muted {
  color: var(--muted);
}

.small-text {
  font-size: 0.84rem;
}

.error-panel {
  margin-top: 4rem;
}

@media (min-width: 760px) {
  .site-header {
    grid-template-columns: 1.2fr auto auto;
    align-items: center;
  }

  .header-actions {
    justify-content: flex-end;
  }

  .lobby-layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }

  .lobby-layout .hero-panel {
    grid-column: 1 / -1;
  }

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

  /* Stats hub: keep tabs in a full-width row above content (avoid narrow column + stretched pills). */
  .stack-layout:has(> .stats-tab-bar) {
    grid-template-columns: 1fr;
  }

  /* Stats hub: single full-width column even if :has() is unsupported. */
  .stack-layout.stats-hub-layout {
    grid-template-columns: 1fr;
  }

  .stack-layout > .panel:first-child:last-child {
    grid-column: 1 / -1;
  }

  .admin-user-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
}

@media (max-width: 759px) {
  .site-header {
    padding-bottom: 0.85rem;
  }

  .header-actions {
    flex-direction: row;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 0.45rem;
  }

  .panel {
    padding: 0.75rem;
    border-radius: 16px;
  }

  .game-page-shell {
    min-height: 100svh;
    gap: 0.42rem;
  }

  .game-stage {
    grid-template-columns: minmax(0, 0.82fr) minmax(118px, 1.5fr) minmax(0, 0.82fr);
    gap: 0.3rem;
  }

  /* Live room: fit more on small phone viewports */
  .game-page-shell .game-log-console {
    min-height: 6.75rem;
  }

  .game-page-shell .console-log {
    max-height: 10.5rem;
  }

  .game-page-shell .center-console {
    gap: 0.28rem;
    padding: 0.36rem;
  }

  .game-page-shell .team-panel {
    min-height: 9.25rem;
    gap: 0.28rem;
  }

  .game-page-shell .team-score-foot {
    padding-top: 0.12rem;
  }

  .game-page-shell .player-chip-stack {
    min-height: 3.65rem;
  }

  .game-page-shell .log-round {
    gap: 0.22rem;
  }

  .game-page-shell .clue-banner {
    padding: 0.18rem 0.28rem 0.18rem 0.22rem;
    border-radius: 12px;
    gap: 0.32rem;
  }

  .game-page-shell .clue-word {
    padding: 0.22rem 0.32rem;
    font-size: 0.72rem;
    line-height: 1.15;
    border-radius: 8px;
  }

  .game-page-shell .clue-number {
    width: 1.48rem;
    height: 1.48rem;
    font-size: 0.72rem;
  }

  .game-page-shell .board-panel {
    margin-top: -0.15rem;
  }

  .game-page-shell .board-grid {
    gap: calc(0.18rem - 2px);
  }

  .game-page-shell .below-board-layout {
    margin-top: -0.38rem;
    gap: 0.35rem;
  }

  .game-page-shell .action-card,
  .game-page-shell .action-form {
    padding: 0.38rem 0.46rem;
  }

  .game-page-shell .action-card {
    gap: 0.32rem;
  }

  .game-page-shell .action-card-operative {
    padding: 0.34rem 0.46rem;
  }

  .game-page-shell .action-card-blank {
    padding: 0.16rem 0.46rem;
  }

  .game-page-shell .action-card-game-over {
    min-height: 2.35rem;
    padding: 0.52rem 0.48rem;
  }

  .game-page-shell .clue-form-inline .clue-form-row {
    gap: 0.26rem;
  }

  .game-page-shell .clue-form-inline .clue-inline-word input {
    padding: 0.4rem 0.5rem;
    border-radius: 9px;
  }

  .game-page-shell .clue-form-inline .clue-inline-number select {
    padding: 0.4rem 0.32rem;
    min-width: 2.65rem;
    border-radius: 9px;
  }

  .game-page-shell .clue-form-inline .clue-inline-submit {
    padding: 0.4rem 0.62rem;
    border-radius: 9px;
  }

  .game-page-shell .below-board-layout .secondary-button {
    padding: 0.4rem 0.55rem;
    border-radius: 10px;
    font-size: 0.82rem;
  }

  .game-page-shell .game-room-settings-trigger {
    width: 2.32rem;
    height: 2.32rem;
  }

  .team-panel,
  .center-console {
    padding: 0.42rem;
    border-radius: 16px;
  }

  .team-player-list,
  .console-log {
    gap: 0.28rem;
  }

  .player-chip {
    padding: 0.22rem 0.24rem;
    gap: 0.3rem;
    border-radius: 10px;
  }

  .team-panel .player-chip-stack .avatar {
    width: 2rem;
    height: 2rem;
    font-size: 0.95rem;
  }

  .player-chip:not(.player-chip-stack) .avatar {
    width: 1.12rem;
    height: 1.12rem;
    font-size: 0.5rem;
  }

  .player-meta strong {
    font-size: 0.64rem;
  }

  .player-meta .player-role-line {
    font-size: 0.56rem;
  }

  .console-log-title {
    font-size: 0.72rem;
  }

  .clue-word {
    padding: 0.3rem 0.4rem;
    font-size: 0.78rem;
  }

  .clue-number {
    width: 1.72rem;
    height: 1.72rem;
    font-size: 0.82rem;
  }

  .board-panel {
    padding: 0.3rem;
    border-radius: 16px;
  }

  .board-grid {
    gap: 0.18rem;
  }

  .tile {
    border-radius: 10px;
    padding: 0.14rem;
  }

  .tile.neutral:not(.revealed)::before {
    border-radius: 9px 9px 0 0;
  }

  .tile.revealed.guess-faded::before {
    left: 8%;
    right: 8%;
    top: 5%;
    bottom: 8%;
    height: auto;
    border-radius: 7px;
  }

  .tile.revealed.guess-faded.expanded::before,
  .tile.revealed.guess-faded.game-over-reveal::before {
    bottom: 53%;
  }

  .tile-confirm {
    width: 1.75rem;
    height: 1.75rem;
    top: 0.1rem;
    right: 0.1rem;
    bottom: auto;
  }

  .button-row,
  .utility-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .utility-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .status-strip {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .status-strip .secondary-button {
    padding-inline: 0.55rem;
    font-size: 0.76rem;
  }

  .leaderboard-head,
  .leaderboard-row {
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 0.9fr));
    font-size: 0.8rem;
  }

}

/* Stats hub */
.stats-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  align-items: flex-start;
  align-content: flex-start;
}

.stats-tab {
  flex: 0 0 auto;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.stats-tab.is-active {
  color: var(--text);
  border-color: rgba(244, 147, 91, 0.45);
  background: rgba(244, 147, 91, 0.12);
}

@media (max-width: 520px) {
  .stats-tab-bar {
    flex-wrap: nowrap;
    gap: 0.14rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-inline: -0.2rem;
    padding: 0 0.2rem 0.15rem;
    margin-bottom: 0.85rem;
  }

  .stats-tab-bar::-webkit-scrollbar {
    display: none;
  }

  .stats-tab {
    padding: 0.28rem 0.46rem;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-radius: 999px;
  }
}

@media (min-width: 641px) {
  .page-live-game {
    min-height: 100svh;
    overflow: hidden;
  }

  .page-live-game .game-page-viewport {
    position: relative;
    width: 100%;
    height: calc(100svh - 1.5rem);
    overflow: hidden;
  }

  .page-live-game .game-page-scale {
    position: absolute;
    top: 0;
    left: 50%;
    width: min(100%, 1200px);
    transform-origin: top center;
    transform: translateX(-50%) scale(var(--game-shell-scale, 1));
  }
}

.panel.flush-panel {
  padding-top: 0.25rem;
}

.word-list-stats .panel-title-row {
  margin-bottom: 0.35rem;
}

.codewords-compact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 0.3rem;
  row-gap: 0.08rem;
  font-size: 0.64rem;
  line-height: 1.22;
}

.codeword-chip {
  min-width: 0;
  word-break: break-word;
  hyphens: auto;
}

@media (min-width: 360px) {
  .codewords-compact-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    font-size: 0.66rem;
  }
}

@media (min-width: 420px) {
  .codewords-compact-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 520px) {
  .codewords-compact-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    font-size: 0.7rem;
  }
}

.stat-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-soft);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.65rem;
}

.stats-subtable {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.stats-subtable-head,
.stats-subtable-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 4.5rem));
  gap: 0.35rem;
  align-items: center;
  font-size: 0.88rem;
}

.stats-subtable-head {
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.stats-subtable-head .sortable,
.stats-subtable-head button.sortable {
  background: transparent;
  box-shadow: none;
  padding: 0.2rem 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: left;
  border-radius: 8px;
  border: 1px solid transparent;
}

.stats-subtable-head .sortable:hover {
  border-color: var(--border);
  color: var(--text);
}

.streak-current .stats-subtable-head,
.streak-current .stats-subtable-row {
  grid-template-columns: minmax(0, 2.5rem) minmax(0, 1.2fr) minmax(0, 4rem) minmax(0, 3.5rem);
}

.streak-alltime .stats-subtable-head,
.streak-alltime .stats-subtable-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 5rem) minmax(0, 5rem);
}

.profile-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.profile-search-input {
  flex: 1;
  min-width: 12rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.profile-search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-search-hit {
  background: transparent;
  box-shadow: none;
  padding: 0.25rem 0;
  color: var(--blue);
  font-weight: 600;
  text-align: left;
}

.btn.secondary {
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
  font-weight: 600;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

/* Profile / stats name links: override global orange primary button styling */
button.linklike,
button.leaderboard-name-btn {
  background: transparent !important;
  box-shadow: none !important;
  font-weight: 600;
  letter-spacing: normal;
  border-radius: 6px;
  padding: 0.1rem 0.15rem;
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--blue);
  justify-content: flex-start;
  line-height: 1.3;
  vertical-align: baseline;
}

button.linklike:hover,
button.leaderboard-name-btn:hover {
  text-decoration: underline;
}

.stack-gap {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Duos: two leaderboard cards stacked; avoid nested flex wrappers overlapping. */
.panel.flush-panel.stack-gap.duos-stats-main {
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.panel.flush-panel.stack-gap.duos-stats-main > .duo-leaderboard-panel {
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
}

.duo-table .duo-table-empty {
  margin-top: 0.35rem;
}

.teammate-table .stats-subtable-head,
.teammate-table .stats-subtable-row,
.opponent-table .stats-subtable-head,
.opponent-table .stats-subtable-row,
.duo-table .stats-subtable-head,
.duo-table .stats-subtable-row {
  grid-template-columns: minmax(0, 1.45fr) repeat(4, minmax(0, 4rem));
}

@media (max-width: 720px) {
  .teammate-table,
  .opponent-table,
  .duo-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: -0.35rem;
    padding-inline: 0.35rem;
  }

  .teammate-table .stats-subtable-head,
  .teammate-table .stats-subtable-row,
  .opponent-table .stats-subtable-head,
  .opponent-table .stats-subtable-row,
  .duo-table .stats-subtable-head,
  .duo-table .stats-subtable-row {
    min-width: 19.5rem;
  }
}

.stack-gap > .profile-stats-highlight {
  margin-bottom: 1rem;
}

.duo-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: center;
}

/* Modern header */
.app-header-modern {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem 0.65rem;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.header-nav-cluster {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-self: start;
}

.header-inline-nav {
  display: flex;
  gap: 0.25rem;
}

.header-nav-link {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  border: 1px solid transparent;
}

.header-nav-link:hover {
  color: var(--text);
  border-color: var(--border);
}

.app-header-modern .header-actions {
  justify-self: end;
}

.header-brand-center {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  justify-self: center;
  min-width: 0;
}

.header-brand-emoji {
  font-size: 1.28rem;
  line-height: 1;
  flex-shrink: 0;
}

.header-brand-text {
  font-family: "Fjalla One", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.94);
}

/* History game + log */
.history-game-head {
  margin-bottom: 0.75rem;
}

.history-game-id {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-roster {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.history-roster-team.red .tag {
  color: var(--red);
  font-weight: 700;
  margin-right: 0.35rem;
}

.history-roster-team.blue .tag {
  color: var(--blue);
  font-weight: 700;
  margin-right: 0.35rem;
}

.history-elo-block {
  margin-top: 0.5rem;
  line-height: 1.45;
}

.history-admin-actions {
  margin-top: 0.5rem;
}

.game-log-title {
  text-align: center;
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-log-row {
  width: 100%;
  text-align: left;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  box-shadow: none;
  color: inherit;
}

.history-log-row.is-active {
  border-color: rgba(244, 147, 91, 0.45);
  box-shadow: 0 0 0 1px rgba(244, 147, 91, 0.2);
}

.history-log-row.log-round.red {
  border-left: 3px solid var(--red);
}

.history-log-row.log-round.blue {
  border-left: 3px solid var(--blue);
}

.history-log-clue {
  display: block;
}

/* Admin user table */
.admin-user-table {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-user-table-head,
.admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 0.6fr) minmax(0, 0.6fr);
  gap: 0.5rem;
  align-items: center;
  font-size: 0.88rem;
}

.admin-user-table-head {
  font-weight: 700;
  color: var(--muted);
  padding: 0 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.admin-user-row {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: none;
  color: inherit;
}

.admin-user-row:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.admin-user-detail {
  padding: 0.75rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: rgba(0, 0, 0, 0.12);
}

.admin-user-block.is-open .admin-user-row {
  border-radius: 12px 12px 0 0;
}

.list-row.admin-abandon-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-abandon-row-body {
  flex: 1;
  min-width: 12rem;
}

.code-area {
  width: 100%;
  min-height: 6rem;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  border-radius: 10px;
  padding: 0.5rem;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.streaks-split-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .streaks-split-layout {
    grid-template-columns: 1fr;
  }
}

.streak-half h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.muted.padded {
  padding: 0.5rem 0;
}

.streak-alltime .stats-subtable-head,
.streak-alltime .stats-subtable-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 4rem);
}

.history-card-gameid {
  font-weight: 800;
}

.history-card-sep {
  color: var(--muted-soft);
  font-weight: 600;
}

.history-card-roster-wrap {
  width: 100%;
  min-width: 0;
}

.history-card-split {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.history-card-half {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.38rem;
  padding: 0.48rem 0.4rem 0.52rem;
  box-sizing: border-box;
}

.history-card-half--red {
  background: linear-gradient(
    180deg,
    rgba(120, 36, 32, 0.55) 0%,
    rgba(55, 22, 22, 0.72) 100%
  );
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.35);
}

.history-card-half--blue {
  background: linear-gradient(
    180deg,
    rgba(28, 58, 92, 0.65) 0%,
    rgba(18, 32, 52, 0.78) 100%
  );
}

.history-card-team-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--text);
}

.history-card-team-outcome {
  font-size: 0.95rem;
  line-height: 1;
}

.history-card-team-name {
  color: var(--text);
}

.history-card-players-panel {
  width: 100%;
  max-width: 100%;
  padding: 0.38rem 0.32rem 0.42rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-sizing: border-box;
}

.history-card-players-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
}

.history-card-players-empty {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 0.78rem;
}

.history-card-player-slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.12rem;
}

.history-card-player-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  min-width: 0;
  width: 100%;
}

.history-card-player-slot .history-card-player-role {
  flex-shrink: 0;
  font-size: 0.88rem;
  line-height: 1;
}

.history-card-player-slot .history-card-player-name {
  min-width: 0;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.history-card-player-elo {
  font-size: 0.74rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.history-card-player-elo--win {
  color: var(--history-elo-win);
}

.history-card-player-elo--loss {
  color: var(--history-elo-loss);
}

@media (max-width: 380px) {
  .history-card-split {
    flex-direction: column;
  }

  .history-card-half--red {
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35);
  }

  .history-card-player-slot {
    max-width: none;
  }
}

.history-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.65rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.lobby-streak-list {
  display: grid;
  gap: 0.42rem;
}

.lobby-streak-list .lobby-streak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
  padding: 0.52rem 0.58rem;
  font-size: 0.88rem;
  line-height: 1.25;
  border-radius: 12px;
}

.lobby-streak-list .lobby-streak-row .linklike {
  font-size: inherit;
  line-height: inherit;
}

/* Site hub — fixed, low-contrast; rare navigation to kong.ooo root */
.site-root-home {
  position: fixed;
  bottom: 0.55rem;
  right: 0.65rem;
  z-index: 120;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: rgba(196, 184, 168, 0.32);
  text-decoration: none;
  pointer-events: auto;
}

.site-root-home:hover {
  color: rgba(196, 184, 168, 0.55);
}

/* Admin — structured game edit */
.game-edit-board-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  font-size: 0.72rem;
  margin-top: 8px;
}
.game-edit-board-cell {
  padding: 6px 4px;
  border-radius: 8px;
  text-align: center;
  word-break: break-word;
  border: 1px solid var(--border);
}
.game-edit-board-red {
  background: rgba(216, 90, 66, 0.22);
}
.game-edit-board-blue {
  background: rgba(46, 151, 209, 0.22);
}
.game-edit-board-neutral {
  background: rgba(196, 184, 168, 0.12);
}
.game-edit-board-black {
  background: var(--black-card);
  color: var(--text);
}
.game-edit-slot-row {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.game-edit-turn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  background: var(--panel-soft);
}
.game-edit-guess-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.game-edit-player-hits {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.game-edit-log-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
