/* Uncross v2.2.0 - Modals, Dialogs & Toast Notifications */

/* Toast System */
#toast-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  overflow: hidden;
}

.toast-anchor {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  max-width: 90vw;
}

.toast-anchor.toast-anchor-fallback {
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
}

.toast-anchor.toast-anchor-centered {
  transform: translate(-50%, -50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface-elevated, #1e293b);
  border: 1px solid var(--bg-surface-border, rgba(255, 255, 255, 0.1));
  color: var(--text-primary, #f8fafc);
  padding: 12px 18px;
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.2);
  font-size: 0.9rem;
  max-width: 360px;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.toast.toast-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast:hover {
  filter: brightness(1.1);
}

.toast:active {
  transform: scale(0.97);
}

.toast-warning {
  border-color: var(--accent-gold);
  background: #272115;
}

.toast-error {
  border-color: var(--accent-red);
  background: #291415;
}

.toast-success {
  border-color: var(--accent-green);
  background: #142820;
}

.toast-star {
  border-color: #facc15;
  background: #2d2305;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.4);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Scoped entrance animation: only active modal overlays execute fade-in */
.modal-overlay.is-active {
  animation: modalFadeIn 0.2s ease-out;
}

/* Persistent or inactive overlays in the DOM must never run entrance keyframes */
.modal-overlay:not(.is-active) {
  animation: none;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-tiles-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.swap-selectable-tile {
  width: 44px;
  height: 48px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #d97706;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #1c1917;
  cursor: pointer;
  transition: all 0.15s ease;
}

.swap-selectable-tile.selected {
  outline: 3px solid var(--accent-red);
  transform: translateY(-6px);
  filter: brightness(0.9);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Game Over Leaderboard */
.game-over-dialog {
  text-align: center;
}

.winner-crown {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.leaderboard-table-container {
  width: 100%;
  max-height: 148px;
  overflow-y: auto;
  margin: 4px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold) rgba(255, 255, 255, 0.05);
}

.leaderboard-table-container::-webkit-scrollbar {
  width: 5px;
}

.leaderboard-table-container::-webkit-scrollbar-thumb {
  background: var(--accent-gold);
  border-radius: 4px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 28px;
  text-align: left;
}

.leaderboard-table th {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg-surface-border);
  position: sticky;
  top: 0;
  background: var(--bg-surface, #171b24);
  z-index: 2;
}

.leaderboard-table td {
  padding: 12px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--bg-surface-border);
}

.rank-winner td {
  font-weight: 800;
  color: var(--accent-gold);
}

/* Canonical Modal Container Lifecycle */
#modal-container:empty {
  display: none !important;
}

#modal-container:not(:empty) {
  display: flex !important;
}

/* Generic Backdrop & Card */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000 !important;
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
  animation: modalFadeIn 0.2s ease-out;
}

.game-config-modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

/* Game Arena Asynchronous Backdrop Fade-In */
.game-arena.is-config-preview-loading {
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

.game-arena.is-config-preview-ready {
  opacity: 1;
  transition: opacity 0.4s ease-out;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.modal-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header-title h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--accent-red);
}

.modal-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold) rgba(255, 255, 255, 0.05);
}

.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--accent-gold);
  border-radius: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  flex-shrink: 0;
}

/* Match Action Log Modal */
.log-modal-card {
  max-width: 700px !important;
  max-height: 85vh !important;
  display: flex;
  flex-direction: column;
}

.log-modal-body {
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
}

.modal-intro-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.log-entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-entry-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-entry-icon {
  font-size: 1.15rem;
}

.log-entry-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  flex: 1;
}

.log-pts-badge {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.log-pts-positive {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.log-pts-zero {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.log-entry-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.log-formula-box {
  background: #0d1017;
  border: 1px solid #1e2433;
  border-radius: 4px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-formula-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-formula-content {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #cbd5e1;
  word-break: break-word;
  line-height: 1.4;
}

.log-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.log-empty-state p {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Invite Modal Dialog */
.invite-links-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0;
}

.invite-card {
  background: #141822;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invite-role-badge {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent-gold);
}

.invite-role-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.invite-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-url-input {
  flex: 1;
  background: #0d1017;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #94a3b8;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  outline: none;
}

.btn-copy-invite {
  white-space: nowrap;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.invite-instructions-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 8px;
}

.bot-difficulty-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-add-bot {
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
  height: auto !important;
}

.btn-add-bot:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
}

/* Top-right floating Video & Chat button (when HUD is removed) */
.btn-float-top-right {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 100;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--bg-surface-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

@media (max-width: 480px) {
  .modal-backdrop,
  .modal-overlay {
    padding: 8px;
  }
  .modal-card,
  .modal-dialog {
    padding: 16px 14px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal-footer {
    margin-top: 12px;
  }
  .invite-links-list {
    gap: 10px;
    margin: 10px 0;
  }
  .invite-card {
    padding: 10px 12px;
  }
}

/* ==========================================================================
   Help & Field Manual Modal Styles
   ========================================================================== */

.help-modal-card {
  max-width: 760px !important;
  max-height: 88vh !important;
  max-height: 88dvh !important;
  display: flex;
  flex-direction: column;
}

.help-modal-body {
  overflow-y: auto;
  max-height: calc(88dvh - 140px);
  padding-right: 8px;
  color: var(--text-primary, #e2e8f0);
  font-size: 0.92rem;
  line-height: 1.6;
}

.help-guide {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md, 8px);
  padding: 16px 18px;
}

.help-section-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-gold, #f59e0b);
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  padding-bottom: 6px;
}

.help-metaphor {
  margin-top: 8px;
  color: #38bdf8;
  font-size: 0.9rem;
}

.help-intro {
  margin-bottom: 12px;
  color: var(--text-secondary, #94a3b8);
}

/* Tables */
.help-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 8px;
}

.help-rosetta-table,
.help-scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.help-rosetta-table th,
.help-scoring-table th {
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  white-space: nowrap;
}

.help-rosetta-table td,
.help-scoring-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.help-rosetta-table tr:nth-child(even),
.help-scoring-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.help-rosetta-table tr:hover,
.help-scoring-table tr:hover {
  background: rgba(245, 158, 11, 0.06);
}

/* Action Badges */
.action-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.guess-badge {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.place-badge {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.swap-badge {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.pass-badge {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.special-badge {
  background: rgba(244, 114, 182, 0.2);
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.4);
}

.threat-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Scoring Values */
.score-pos {
  font-weight: 700;
  color: #34d399;
}

.score-neg {
  font-weight: 700;
  color: #f87171;
}

/* Tile Lists */
.help-tile-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-tile-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.help-tile-preview {
  font-size: 1.3rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.help-tile-desc {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Color Chips */
.color-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.color-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chip-p1 {
  background: #0f52ba;
  color: #ffffff;
  box-shadow: 0 0 6px rgba(15, 82, 186, 0.5);
}

.chip-p2 {
  background: #097969;
  color: #ffffff;
  box-shadow: 0 0 6px rgba(9, 121, 105, 0.5);
}

.chip-p3 {
  background: #9b111e;
  color: #ffffff;
  box-shadow: 0 0 6px rgba(155, 17, 30, 0.5);
}

.chip-p4 {
  background: #d97706;
  color: #ffffff;
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.5);
}

/* Network Restricted Diagnostic Modal */
.network-restricted-card {
  max-width: 520px !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), 0 0 16px rgba(245, 158, 11, 0.2) !important;
}

.network-restricted-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-primary, #e2e8f0);
  font-size: 0.95rem;
  line-height: 1.55;
}

.network-modal-highlight {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md, 8px);
  padding: 12px 14px;
  color: #fef3c7;
  font-size: 0.9rem;
}

/* Daily Resetting Leaderboard Modal Styles */
.leaderboard-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 21000 !important;
  padding: 16px;
  box-sizing: border-box;
}

.leaderboard-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(6px);
}

.leaderboard-modal-card {
  position: relative;
  background: #0f172a;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 20px rgba(245, 158, 11, 0.15);
  overflow: hidden;
  z-index: 1;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.leaderboard-trophy-icon {
  font-size: 2rem;
  line-height: 1;
}

.leaderboard-header-title h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.leaderboard-subtitle {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
}

.btn-leaderboard-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-leaderboard-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.leaderboard-game-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: #090d16;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-game-tab {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 14px;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.lb-game-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.lb-game-tab.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.1));
  border-color: #f59e0b;
  color: #fef3c7;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.leaderboard-date-bar {
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-date-toggles {
  display: flex;
  gap: 8px;
}

.lb-date-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 7px 12px;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.lb-date-btn.active {
  background: #1e293b;
  border-color: #38bdf8;
  color: #38bdf8;
}

.lb-countdown-pill {
  font-size: 0.72rem;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
}

.leaderboard-body {
  flex: 1;
  overflow-y: hidden;
  padding: 0;
  min-height: 240px;
}

.leaderboard-loading,
.leaderboard-empty,
.leaderboard-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 12px;
  color: #94a3b8;
}

.lb-empty-icon {
  font-size: 2.5rem;
}

.leaderboard-empty h4 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.1rem;
}

.leaderboard-empty p {
  margin: 0;
  max-width: 380px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.lb-play-cta {
  margin-top: 8px;
  padding: 8px 18px;
}

.lb-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Table Container */
.leaderboard-modal-overlay .leaderboard-table-container {
  max-height: 310px;
  overflow-y: auto;
  background: #0b1120;
  margin-bottom: 0;
  border-radius: 0;
  border: none;
}

.leaderboard-modal-overlay .leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.leaderboard-modal-overlay .leaderboard-table th {
  position: sticky;
  top: 0;
  background: #1e293b;
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.leaderboard-modal-overlay .leaderboard-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.leaderboard-modal-overlay .lb-table-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.leaderboard-modal-overlay .lb-table-row.lb-row-me {
  background: rgba(59, 130, 246, 0.15) !important;
  border-left: 3px solid #3b82f6;
}

.leaderboard-modal-overlay .lb-table-row.lb-row-me td {
  color: #ffffff;
  font-weight: 600;
}

.leaderboard-modal-overlay .lb-table-row.lb-row-hypothetical {
  background: rgba(99, 102, 241, 0.15) !important;
  border-left: 3px solid #6366f1;
}

.leaderboard-modal-overlay .lb-cell-rank {
  font-weight: 700;
  width: 48px;
  color: #94a3b8;
}

.leaderboard-modal-overlay .lb-podium-1 .lb-cell-rank { color: #f59e0b; }
.leaderboard-modal-overlay .lb-podium-2 .lb-cell-rank { color: #cbd5e1; }
.leaderboard-modal-overlay .lb-podium-3 .lb-cell-rank { color: #d97706; }

.leaderboard-modal-overlay .lb-cell-player {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  min-width: 0;
}

.leaderboard-modal-overlay .lb-player-name {
  font-weight: 600;
  color: #f8fafc;
}

.leaderboard-modal-overlay .lb-cell-score,
.leaderboard-modal-overlay .lb-cell-moves {
  font-weight: 700;
  color: #38bdf8;
}

.leaderboard-modal-overlay .lb-cell-time {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.8rem;
  color: #cbd5e1;
  white-space: nowrap;
}

.leaderboard-modal-overlay .lb-cell-badge {
  font-size: 0.78rem;
  color: #94a3b8;
}

.leaderboard-modal-overlay .lb-badge-auth {
  font-size: 0.8rem;
}

.leaderboard-modal-overlay .lb-tag-you {
  font-size: 0.72rem;
  font-weight: 800;
  color: #60a5fa;
  background: rgba(37, 99, 235, 0.25);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  white-space: nowrap;
}

.leaderboard-modal-overlay .lb-tag-rest {
  font-size: 0.72rem;
  font-weight: 800;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(165, 180, 252, 0.4);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  white-space: nowrap;
}

.leaderboard-modal-overlay .lb-header-mobile {
  display: none;
}

.leaderboard-sticky-footer {
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px;
}

.lb-footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lb-footer-content.has-standing .lb-standing-label {
  font-size: 0.78rem;
  color: #94a3b8;
  display: block;
}

.lb-footer-content.has-standing .lb-standing-rank {
  font-size: 0.95rem;
  color: #f59e0b;
}

.lb-footer-content.no-auth .lb-standing-info span {
  font-weight: 600;
  font-size: 0.85rem;
  color: #f8fafc;
  display: block;
}

.lb-footer-content.no-auth .lb-standing-info small {
  color: #94a3b8;
  font-size: 0.74rem;
}

.lb-auth-actions {
  display: flex;
  gap: 8px;
}

.lb-footer-pwa {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.lb-footer-google {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.lb-footer-play {
  padding: 6px 14px;
  font-size: 0.84rem;
}

.btn-play-daily {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-play-daily:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
}

.btn-play-casual {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-play-casual:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5);
}

.lb-score-stat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid;
}

.lb-standing-invite {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f8fafc;
  margin: 2px 0;
}

.lb-standing-subtext {
  font-size: 0.74rem;
  color: #94a3b8;
  display: block;
}

.lb-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-footer-share,
.lb-footer-close,
.lb-footer-play-casual {
  padding: 6px 14px;
  font-size: 0.84rem;
}

.lb-tag-surrendered {
  font-size: 0.72rem;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  vertical-align: middle;
}

/* Responsive adjustments for Daily Leaderboard Modal */
@media (max-width: 640px) {
  .leaderboard-modal-overlay {
    padding: 8px;
  }

  /* Surrendered/Finished Early flag on mobile: show flag icon only, hide associated text */
  .lb-tag-surrendered {
    background: none;
    border: none;
    padding: 0;
    margin-left: 3px;
    font-size: 0.85rem;
  }
  .lb-tag-surrendered .lb-surrender-text {
    display: none;
  }

  .leaderboard-modal-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .leaderboard-header {
    padding: 12px 14px;
  }

  .leaderboard-header-title h2 {
    font-size: 1.1rem;
  }

  .leaderboard-game-tabs {
    padding: 8px 12px;
    gap: 4px;
  }

  .lb-game-tab {
    padding: 5px 8px;
    font-size: 0.76rem;
  }

  .leaderboard-date-bar {
    padding: 6px 12px;
  }

  .leaderboard-modal-overlay .leaderboard-table th,
  .leaderboard-modal-overlay .leaderboard-table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }

  /* Rule: on mobile, do not show rank tag column (e.g. Cruciverbalist, Grand Master) */
  .leaderboard-modal-overlay .lb-th-badge,
  .leaderboard-modal-overlay .lb-cell-badge {
    display: none !important;
  }

  .leaderboard-modal-overlay .lb-header-desktop {
    display: none;
  }
  .leaderboard-modal-overlay .lb-header-mobile {
    display: inline;
  }

  .leaderboard-modal-overlay .lb-cell-rank {
    width: 48px;
    min-width: 48px;
    font-size: 0.78rem;
  }

  .leaderboard-modal-overlay .lb-player-name {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leaderboard-modal-overlay .lb-cell-score,
  .leaderboard-modal-overlay .lb-cell-moves {
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .leaderboard-modal-overlay .lb-cell-time {
    font-size: 0.74rem;
  }

  .leaderboard-sticky-footer {
    padding: 10px 14px;
  }

  .leaderboard-sticky-footer .lb-footer-content {
    flex-direction: column;
    align-items: stretch;
  }

  .leaderboard-sticky-footer .lb-footer-actions {
    width: 100%;
    justify-content: stretch;
  }

  .leaderboard-sticky-footer .lb-footer-actions .btn {
    flex: 1;
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

/* Launch Modal / Stepper Dialog */
.launch-modal-card {
  max-width: 440px;
  width: 90%;
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-gold-glow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.launch-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--bg-surface-border);
  padding-bottom: 12px;
}

.launch-modal-icon {
  font-size: 1.6rem;
  animation: pulseIcon 1.5s infinite ease-in-out;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 8px var(--accent-gold)); }
}

.launch-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.launch-modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.launch-stepper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 6px 0;
}

.launch-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.launch-step-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

.launch-step-item.done {
  color: var(--accent-green);
}

.launch-step-item.failed {
  color: var(--accent-red);
}

.launch-step-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  border: 1px solid var(--bg-surface-border);
  background: var(--bg-primary);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.launch-step-item.active .launch-step-badge {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  animation: spinStep 1s infinite linear;
}

.launch-step-item.done .launch-step-badge {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

@keyframes spinStep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.launch-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.launch-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-gold), var(--accent-green));
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================================
   Blank Tile Letter Picker Modal (A–Z Designation)
   ========================================================================= */
.blank-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
  animation: modalFadeIn 0.18s ease-out;
}

.blank-picker-dialog {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--bg-surface-border, #334155);
  border-radius: var(--radius-lg, 12px);
  padding: 22px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  color: var(--text-primary, #f8fafc);
  text-align: center;
}

.blank-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.blank-picker-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.blank-picker-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
  border: 1px solid #94a3b8;
  border-radius: 4px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

.blank-picker-dialog .modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary, #f8fafc);
}

.blank-picker-dialog .modal-desc {
  font-size: 0.88rem;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 16px;
  text-align: left;
}

.blank-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

@media (max-width: 440px) {
  .blank-picker-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }
}

.blank-picker-tile {
  width: 100%;
  aspect-ratio: 1 / 1.08;
  max-width: 48px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #d97706;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  user-select: none;
  touch-action: manipulation;
  padding: 0;
}

.blank-picker-tile:hover {
  transform: translateY(-2px) scale(1.05);
  border-color: #38bdf8;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.45);
}

.blank-picker-tile:active {
  transform: translateY(0) scale(0.98);
}

.blank-picker-tile.selected {
  outline: 3px solid #0284c7;
  border-color: #0284c7;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.6);
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

.blank-picker-char {
  font-family: var(--font-tile, 'Lora', Georgia, serif);
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  font-weight: 800;
  color: #090d16;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-1px);
}

.blank-picker-pts {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 0.6rem;
  font-weight: 800;
  color: #78350f;
  line-height: 1;
  pointer-events: none;
}

/* Invite Participants Dialog Overlay (Floating over active game arena) */
.lobby-container.invite-modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
}

.lobby-container.invite-modal-overlay .lobby-card {
  max-width: 500px;
  width: 100%;
  margin: auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
  box-sizing: border-box;
}

@media (max-width: 540px) {
  .lobby-container.invite-modal-overlay {
    padding: 10px 8px;
    align-items: center;
  }

  .lobby-container.invite-modal-overlay .lobby-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
}

/* Keyboard & Typing Preferences Modal Overlay Stacking */
.vk-prefs-modal-overlay {
  z-index: 30000 !important;
}

/* Board Upgrade Modal Overlay Stacking (Spec Section 22.3) */
.modal-backdrop.board-upgrade-modal-backdrop,
.board-upgrade-modal-backdrop {
  z-index: 26000 !important;
}

/* Bot Count Configuration Modal Overlay Stacking (Spec Section 22.3) */
.bot-count-modal-overlay {
  z-index: 25000 !important;
}

/* Player Profile & Configuration Modal (Spec Section 24) */
.profile-modal-overlay {
  z-index: 25000 !important;
}

.profile-modal-content {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--bg-surface-border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-lg, 16px);
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  color: var(--text-primary, #f8fafc);
  overflow: hidden;
}

.profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-surface-border, rgba(255, 255, 255, 0.08));
}

.profile-modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
}

.profile-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-section-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-identity-card {
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.profile-avatar-badge {
  font-size: 2.2rem;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-avatar-thumb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-identity-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-handle-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.profile-handle-input {
  flex: 0 1 190px;
  min-width: 130px;
  max-width: 210px;
  height: var(--btn-action-height, 36px);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: var(--radius-action, 8px);
  padding: 0 12px;
  font-size: 0.90rem;
  font-weight: 600;
  box-sizing: border-box;
}

.profile-handle-input:focus {
  outline: none;
  border-color: var(--accent-gold, #f59e0b);
}

.profile-handle-input[readonly] {
  cursor: default;
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.profile-handle-input[readonly]:focus {
  border-color: rgba(255, 255, 255, 0.2);
}

.profile-bound-email {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  word-break: break-all;
}

.profile-handle-readonly-hint {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.35;
}

.tier-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-handle-input:focus {
  outline: none;
  border-color: var(--accent-gold, #f59e0b);
}

.profile-tier-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.tier-casual {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.tier-device {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.tier-social {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.profile-card-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.profile-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.profile-card-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
}

.profile-card-desc {
  margin: 0;
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.35;
}

.profile-install-card, .profile-social-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-subheading {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #cbd5e1;
}

.profile-audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-vol-label {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 600;
}

.profile-vol-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-vol-slider {
  width: 110px;
  accent-color: var(--accent-gold, #f59e0b);
  cursor: pointer;
}

.profile-dev-sandbox-card {
  background: rgba(88, 28, 135, 0.18);
  border: 1px dashed rgba(168, 85, 247, 0.4);
}

.profile-dev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(168, 85, 247, 0.2);
  padding-bottom: 6px;
}

.profile-dev-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #c084fc;
}

.profile-dev-caption {
  font-size: 0.7rem;
  color: #a855f7;
}

.profile-dev-identity-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-dev-label {
  font-size: 0.75rem;
  color: #cbd5e1;
  font-weight: 600;
}

.profile-dev-btn-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-dev-level {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dev-level.is-active {
  background: rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
  color: #fff;
}

.profile-dev-pro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(168, 85, 247, 0.15);
  gap: 10px;
}

.profile-dev-pro-info {
  display: flex;
  flex-direction: column;
}

.profile-dev-pro-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f1f5f9;
}

.profile-dev-pro-status {
  font-size: 0.7rem;
  color: #94a3b8;
}

.btn-dev-pro {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-dev-pro.pro-active {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.profile-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--bg-surface-border, rgba(255, 255, 255, 0.08));
}

/* --- Streamlined 3-Card Deck & Fun Credits Vault (Spec § 24.2) --- */
.profile-vault-card {
  border: 1px solid rgba(245, 158, 11, 0.35) !important;
  background: linear-gradient(180deg, #172338 0%, #111a2c 100%) !important;
}

.vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vault-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--accent-gold, #f59e0b);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vault-balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 3px 10px;
  border-radius: 20px;
}

.vault-balance-big {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.vault-storage-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #94a3b8;
}

.storage-bar-track {
  height: 8px;
  background: #090e1a;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #fbbf24);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.vault-hint-incentive {
  font-size: 0.78rem;
  color: #e0e7ff;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1.4;
}

/* In-Card Rate Summary Strip */
.vault-rates-strip {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.vault-rates-strip-header {
  font-size: 0.74rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vault-rates-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-rates-info {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--accent-gold, #f59e0b);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-rates-info:hover {
  background: rgba(251, 191, 36, 0.28);
  border-color: #fde047;
  color: #fff;
  transform: scale(1.15);
}

.vault-rates-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

@media (max-width: 360px) {
  .vault-rates-chips {
    grid-template-columns: 1fr;
  }
}

.vault-rate-chip {
  background: #1e293b;
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.vault-rate-chip:hover {
  background: #273549;
  border-color: var(--accent-gold, #f59e0b);
  color: #fff;
  transform: translateY(-1px);
}

.vault-rate-cost {
  font-weight: 800;
  color: #FDE047;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Sub-Dialog Styles */
.sub-dialog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-sub-back {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-sub-back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-manage-tier {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent, #38bdf8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0 12px;
  min-height: 32px;
  height: 32px;
  border-radius: var(--radius-action, 8px);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-manage-tier:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent, #38bdf8);
}

.btn-uninstall-tier {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0 12px;
  min-height: 32px;
  height: 32px;
  border-radius: var(--radius-action, 8px);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-uninstall-tier:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #f87171;
}

.btn-signout {
  min-height: var(--btn-action-height, 36px);
  height: var(--btn-action-height, 36px);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0 14px;
  border-radius: var(--radius-action, 8px);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-signout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #f87171;
  transform: translateY(-1px);
}

.tier-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Button Radiuses & Gating for Profile Controls (Spec § 24.2 / § 5.3.3.1) */
.profile-handle-edit-row .btn-reroll,
.profile-handle-edit-row .btn-save-handle,
.profile-vol-controls .btn-mute,
#profile-btn-mute,
#profile-btn-reset-dismissed-prompts,
.profile-prompts-reset-row .btn,
.profile-keyboard-link-row .btn-open-keyboard-prefs,
.btn-view-comparison,
.btn-install-app,
.btn-google-auth,
.profile-modal-footer .btn {
  border-radius: var(--radius-action, 8px);
}

.profile-handle-edit-row .btn-reroll {
  flex: 1 0 auto;
  min-width: 90px;
  height: var(--btn-action-height, 36px);
  min-height: var(--btn-action-height, 36px);
  padding: 0 14px;
  font-size: 0.80rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.profile-handle-edit-row .btn-save-handle {
  flex: 0 0 auto;
  min-width: 72px;
  height: var(--btn-action-height, 36px);
  min-height: var(--btn-action-height, 36px);
  padding: 0 16px;
  font-size: 0.80rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn-save-handle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Upgrade & Account Sub-Dialog Button Standards (CROSS_GAME_SPEC § 5.3.3.1 / § 24.2.2) */
.btn-view-comparison {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  min-height: var(--btn-action-height, 36px);
  height: var(--btn-action-height, 36px);
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-view-comparison:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: #60a5fa;
  color: #93c5fd;
  transform: translateY(-1px);
}

.btn-install-app {
  min-height: var(--btn-action-height, 36px);
  height: var(--btn-action-height, 36px);
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-google-auth {
  min-height: var(--btn-action-height, 36px);
  height: var(--btn-action-height, 36px);
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-google-auth:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.profile-install-card,
.profile-installed-status-card,
.profile-social-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.profile-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}

.profile-card-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.profile-card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-card-title {
  margin: 0;
  font-size: 0.90rem;
  font-weight: 700;
  color: #f8fafc;
}

.profile-card-desc {
  margin: 0;
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.35;
}

.btn-sub-back {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-action, 8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.15s ease;
}

.btn-sub-back:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-gold, #f59e0b);
  color: #ffffff;
}

/* Comparison Table */
.comparison-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.6);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

.comparison-table th {
  background: #111a2e;
  padding: 8px 10px;
  font-weight: 700;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comparison-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

.comparison-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Hint Rules List */
.hint-rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint-rule-card {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hint-rule-info h5 {
  margin: 0 0 3px;
  font-size: 0.85rem;
  color: #fff;
}

.hint-rule-info p {
  margin: 0;
  font-size: 0.74rem;
  color: #94a3b8;
  line-height: 1.35;
}

.hint-rule-cost {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #FDE047;
  padding: 4px 8px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Name Protection & Recovery Sub-Dialogs (CROSS_GAME_SPEC § 24.2.2 & ECONOMY_SPEC § 5.3) */
.protect-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: #0d1526;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  flex-wrap: wrap;
}

.protect-row-text {
  flex: 1 1 180px;
  min-width: 0;
}

.protect-row-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.protect-row-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 2px 0 0;
}

.protect-row-status {
  font-size: 0.78rem;
  color: #e2e8f0;
  margin-top: 4px;
  font-weight: 600;
}

.protect-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid rgba(96, 165, 250, 0.5);
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.protect-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(96, 165, 250, 0.8);
  color: #fff;
}

.protect-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.protect-btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.protect-btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.protect-callout {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.protect-callout-warn {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.protect-callout-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #bfdbfe;
}

.code-words-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.code-word {
  padding: 12px;
  background: #0d1526;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.code-word span {
  color: #64748b;
  font-size: 0.72rem;
  min-width: 14px;
}

.recover-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.recover-field input,
.recover-field textarea {
  min-height: 44px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #0d1526;
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}

.recover-message {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.recover-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.recover-ok {
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
}

.recover-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #bfdbfe;
}

/* Mobile Responsive Ergonomics for Player Profile Modal (Spec § 24.2.1) */
@media (max-width: 480px) {
  .profile-modal-content {
    max-height: calc(100dvh - 16px);
    width: calc(100vw - 16px);
    margin: 8px auto;
    border-radius: 12px;
  }

  .profile-modal-header {
    padding: 12px 14px;
  }

  .profile-modal-title {
    font-size: 1rem;
  }

  .profile-modal-body {
    padding: 12px 14px;
    gap: 10px;
  }

  .profile-section-card {
    padding: 12px;
  }

  .profile-identity-card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      "avatar edit"
      "tier   tier";
    gap: 10px;
    align-items: center;
  }

  .profile-avatar-badge {
    grid-area: avatar;
    align-self: start;
    margin-top: 2px;
  }

  .profile-identity-info {
    grid-area: edit;
    min-width: 0;
  }

  .profile-handle-edit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .profile-handle-input {
    width: 100%;
    flex: 1 1 100%;
    min-width: 0;
  }

  .profile-handle-edit-row .btn-reroll,
  .profile-handle-edit-row .btn-save-handle {
    flex: 1;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    padding: 6px 8px;
  }

  .tier-summary-row {
    grid-area: tier;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    width: 100%;
  }

  .profile-tier-row {
    width: 100%;
  }

  .profile-tier-badge {
    width: 100%;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    font-size: 0.72rem;
    padding: 4px 6px;
  }

  .tier-actions-group {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .tier-actions-group button,
  .btn-manage-tier,
  .btn-uninstall-tier,
  .btn-signout {
    flex: 1;
    width: 100%;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .vault-rates-strip-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .vault-rates-chips {
    gap: 6px;
  }

  .vault-rate-chip {
    padding: 6px 8px;
    font-size: 0.74rem;
    min-height: 38px;
  }

  .vault-rate-cost {
    font-size: 0.74rem;
  }

  .vault-help-action-row {
    justify-content: stretch;
  }

  .btn-open-fc-guide {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .profile-audio-row {
    gap: 8px;
  }

  .profile-vol-controls {
    flex-shrink: 0;
  }

  .profile-vol-slider {
    width: 80px;
  }

  .profile-prompts-reset-row > div {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .profile-prompts-reset-row button {
    width: 100%;
  }

  .profile-modal-footer {
    padding: 10px 14px;
  }

  .profile-modal-footer .btn {
    width: 100%;
  }

  .code-words-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .protect-row .protect-btn {
    width: 100%;
  }
}

/* Game Card Social Likes (❤️ / 🤍) per CROSS_GAME_SPEC.md § 26 */
.btn-card-heart {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.btn-card-heart:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  transform: translateY(-1px);
}

.btn-card-heart.is-liked {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35);
}

.btn-card-heart.is-liked .heart-symbol {
  animation: heart-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

#modal-like-eligibility.fww-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(8px);
}

#modal-like-eligibility.is-visible {
  display: flex !important;
}

/* Cookie Consent Modal & Toggle Switch Component (Governed by COMPLIANCE_SPEC.md § 3) */
.modal-dialog.cookie-consent-card {
  max-width: 540px;
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
}

.cookie-consent-card .cookie-consent-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 8px;
}

.cookie-consent-card .cookie-consent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding-right: 40px;
  flex-shrink: 0;
}

.cookie-consent-card .cookie-consent-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.cookie-consent-card .cookie-consent-title {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  line-height: 1.25;
}

.cookie-consent-card .cookie-consent-subtitle {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.cookie-consent-card .cookie-consent-intro {
  font-size: 0.86rem;
  color: var(--text-secondary, #cbd5e1);
  line-height: 1.45;
  margin: 0 0 12px 0;
  flex-shrink: 0;
}

.cookie-consent-card .cookie-categories-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold, #f59e0b) rgba(255, 255, 255, 0.06);
}

.cookie-consent-card .cookie-categories-container::-webkit-scrollbar {
  width: 5px;
}

.cookie-consent-card .cookie-categories-container::-webkit-scrollbar-thumb {
  background: var(--accent-gold, #f59e0b);
  border-radius: 4px;
}

.cookie-consent-card .cookie-category-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cookie-consent-card .cookie-category-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.cookie-consent-card .cookie-category-info {
  flex: 1;
  min-width: 0;
}

.cookie-consent-card .cookie-category-title-row {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.cookie-consent-card .cookie-always-active-badge {
  font-size: 0.68rem;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.cookie-consent-card .cookie-category-desc {
  margin: 2px 0 0 0;
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.35;
}

.cookie-consent-card .cookie-consent-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.cookie-consent-card .cookie-consent-legal-links {
  font-size: 0.76rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 12px;
  line-height: 1.4;
}

.cookie-consent-card .cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cookie-consent-card .cookie-consent-primary-group {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.cookie-consent-card .cookie-action-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}

@media (max-width: 480px), (max-height: 680px) {
  .modal-dialog.cookie-consent-card {
    padding: 12px 12px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .cookie-consent-card .cookie-consent-close-btn {
    top: 6px;
    right: 6px;
  }
  .cookie-consent-card .cookie-consent-header {
    gap: 8px;
    margin-bottom: 6px;
    padding-right: 38px;
  }
  .cookie-consent-card .cookie-consent-icon {
    font-size: 1.4rem;
  }
  .cookie-consent-card .cookie-consent-title {
    font-size: 1.02rem;
  }
  .cookie-consent-card .cookie-consent-subtitle {
    font-size: 0.72rem;
  }
  .cookie-consent-card .cookie-consent-intro {
    font-size: 0.78rem;
    line-height: 1.35;
    margin-bottom: 8px;
  }
  .cookie-consent-card .cookie-categories-container {
    gap: 7px;
    padding: 9px 10px;
    margin-bottom: 8px;
  }
  .cookie-consent-card .cookie-category-item {
    gap: 8px;
    padding-bottom: 6px;
  }
  .cookie-consent-card .cookie-category-title-row {
    font-size: 0.8rem;
  }
  .cookie-consent-card .cookie-category-desc {
    font-size: 0.72rem;
    line-height: 1.28;
  }
  .cookie-consent-card .cookie-consent-legal-links {
    font-size: 0.72rem;
    margin-bottom: 8px;
  }
}

@media (max-width: 480px) {
  .cookie-consent-card .cookie-consent-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 6px;
  }
  .cookie-consent-card .cookie-consent-primary-group {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .cookie-consent-card .cookie-action-btn {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

.cookie-consent-card .toggle-switch,
.modal-dialog .toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.cookie-consent-card .toggle-switch input,
.modal-dialog .toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.cookie-consent-card .toggle-slider,
.modal-dialog .toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cookie-consent-card .toggle-slider:before,
.modal-dialog .toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.cookie-consent-card .toggle-switch input:checked + .toggle-slider,
.modal-dialog .toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-emerald, #10b981);
  border-color: #059669;
}

.cookie-consent-card .toggle-switch input:checked + .toggle-slider:before,
.modal-dialog .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.cookie-consent-card .toggle-switch.is-locked,
.modal-dialog .toggle-switch.is-locked {
  cursor: not-allowed;
}

.cookie-consent-card .toggle-switch.is-locked input,
.modal-dialog .toggle-switch.is-locked input {
  cursor: not-allowed;
}

.cookie-consent-card .toggle-switch.is-locked .toggle-slider,
.modal-dialog .toggle-switch.is-locked .toggle-slider {
  cursor: not-allowed;
  background-color: #10b981;
  opacity: 0.9;
}

.cookie-consent-card .toggle-switch.is-locked .toggle-lock-icon,
.modal-dialog .toggle-switch.is-locked .toggle-lock-icon {
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translate(20px, -50%);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

/* Coming Soon Modal Dialog */
.coming-soon-dialog {
  border: 1px solid rgba(245, 158, 11, 0.3);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(245, 158, 11, 0.1);
}

.coming-soon-icon-box {
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.coming-soon-notify-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.coming-soon-actions .btn {
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.coming-soon-actions .btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.coming-soon-actions .btn:active:not(:disabled) {
  transform: translateY(0);
}

/* ==========================================================================
   Club Pass Subscription Modal (GAME_PACKS_SPEC § 2 & CROSS_GAME_SPEC § 20)
   ========================================================================== */
.club-pass-modal-overlay {
  z-index: 28000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 29, 0.85);
  backdrop-filter: blur(8px);
}

.club-pass-card {
  max-width: 480px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface-elevated, #161e2e);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg, 16px);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(245, 158, 11, 0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.club-pass-card .club-pass-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.club-pass-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.club-pass-crown-badge {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.4));
  margin-bottom: 2px;
}

.club-pass-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary, #ffffff);
  margin: 0;
  letter-spacing: -0.02em;
}

.club-pass-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

.club-pass-context-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md, 8px);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #fef3c7;
}

.club-pass-context-callout .callout-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.club-pass-plans-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.club-pass-plan-card {
  position: relative;
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md, 12px);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.club-pass-plan-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(30, 41, 59, 0.9);
}

.club-pass-plan-card.is-selected {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.2);
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plan-badge-save {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.plan-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.price-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary, #ffffff);
}

.price-period {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
}

.plan-sub-price {
  font-size: 0.7rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.2;
}

.club-pass-benefits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md, 10px);
  padding: 12px 14px;
}

.benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.benefit-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.benefit-details {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  line-height: 1.3;
}

.benefit-details strong {
  color: var(--text-primary, #ffffff);
  font-size: 0.85rem;
}

.benefit-details span {
  color: var(--text-secondary, #94a3b8);
}

.club-pass-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.club-pass-checkout-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  font-weight: 800;
  font-size: 1rem;
  padding: 14px 20px;
  border-radius: var(--radius-md, 10px);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.club-pass-checkout-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.club-pass-portal-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  align-self: center;
}

.club-pass-portal-btn:hover {
  color: var(--text-primary, #ffffff);
}

.club-pass-footer-terms {
  text-align: center;
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.7);
}

/* Beta Notice Modal Dialog (ARCHITECTURE_SPEC.md § 13.4) */
.modal-dialog.beta-notice-card {
  max-width: 480px;
  width: 100%;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 24px rgba(245, 158, 11, 0.12);
  border-radius: var(--radius-lg, 12px);
  background: var(--bg-surface, #1e293b);
  padding: 24px;
  position: relative;
  text-align: left;
}

.beta-notice-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 6px);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.beta-notice-close-btn:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.08);
}

.beta-notice-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-right: 36px;
}

.beta-notice-icon-box {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.15);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.beta-notice-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
}

.beta-notice-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
  display: block;
}

.beta-notice-body p {
  margin: 0 0 16px 0;
  font-size: 0.88rem;
  color: var(--text-secondary, #cbd5e1);
  line-height: 1.5;
}

.beta-notice-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.beta-notice-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary, #cbd5e1);
  cursor: pointer;
  user-select: none;
}

.beta-notice-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #f59e0b;
  cursor: pointer;
  margin: 0;
}

.beta-notice-actions {
  display: flex;
  justify-content: flex-end;
}

.beta-action-btn {
  min-height: 44px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm, 6px);
  background: #f59e0b;
  border: 1px solid #d97706;
  color: #090d16;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.beta-action-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

@media (max-width: 480px) {
  .modal-dialog.beta-notice-card {
    padding: 18px 16px;
  }
  .beta-action-btn {
    width: 100%;
  }
}

/* Legal Reader Modal (Governed by COMPLIANCE_SPEC.md § 5) */
.modal-dialog.legal-reader-card {
  max-width: 720px;
  width: 92vw;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  overflow: hidden;
  padding: 20px 24px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
}

.legal-reader-card .legal-reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.legal-reader-card .legal-reader-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  flex-shrink: 0;
}

.legal-reader-card #legal-modal-content,
.legal-reader-card .legal-reader-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 8px;
  font-size: 0.86rem;
  color: #cbd5e1;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold, #f59e0b) rgba(255, 255, 255, 0.06);
}

.legal-reader-card #legal-modal-content::-webkit-scrollbar,
.legal-reader-card .legal-reader-content::-webkit-scrollbar {
  width: 6px;
}

.legal-reader-card #legal-modal-content::-webkit-scrollbar-track,
.legal-reader-card .legal-reader-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.legal-reader-card #legal-modal-content::-webkit-scrollbar-thumb,
.legal-reader-card .legal-reader-content::-webkit-scrollbar-thumb {
  background: var(--accent-gold, #f59e0b);
  border-radius: 4px;
}

.legal-reader-card .legal-reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  margin-top: 12px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .modal-dialog.legal-reader-card {
    padding: 16px 14px;
    max-height: calc(100dvh - 16px);
    width: 96vw;
  }
}


