/* ============================================================
   Global CSS — Board Games Hub
   Dark theme design system
   ============================================================ */

/* Google Fonts import is done in HTML <head> for performance */

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* ── CSS Variables ── */
:root {
  --bg:            #f4f2ff;
  --surface:       #ffffff;
  --surface-2:     #edeaff;
  --surface-3:     #e2deff;
  --border:        #cdc8f5;
  --border-strong: #b5aeed;
  --accent:        #4338ca;
  --accent-dark:   #3730a3;
  --accent-glow:   rgba(67, 56, 202, 0.12);
  --text:          #1e1b4b;
  --text-muted:    #5b57a0;
  --text-dim:      #9b96cc;
  --error:         #dc2626;
  --success:       #16a34a;
  --warning:       #d97706;
  --easy:          #16a34a;
  --medium:        #d97706;
  --hard:          #dc2626;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 4px rgba(67,56,202,0.08);
  --shadow-md:  0 4px 16px rgba(67,56,202,0.12);
  --shadow-lg:  0 8px 32px rgba(67,56,202,0.16);

  --transition: 150ms ease;
}

/* ── Base ── */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #a5b4fc;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: all var(--transition);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ── Utility classes ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-error  { color: var(--error); }
.text-success{ color: var(--success); }

.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.justify-center { justify-content: center; }
.gap-4       { gap: 1rem; }
.gap-2       { gap: 0.5rem; }

/* ── Button base ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.55em 1.2em;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

/* ── Modal base ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92) translateY(16px);
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-card h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.modal-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── PWA Install UI ── */
.install-btn {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 1rem auto 0;
  padding: 0.75rem 1.75rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.2s;
}
.install-btn:hover { opacity: 0.9; transform: scale(1.03); }

.ios-hint {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1rem auto 0;
  max-width: 380px; padding: 0.875rem 1rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; font-size: 0.875rem; color: var(--text-muted);
  position: relative;
}
.ios-hint strong { color: var(--text); }
.hint-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 0 0.25rem;
}

/* ── Game Number Bar ── */
/* ── Game Number Bar ─────────────────────────── */
.game-number-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  margin: 0.65rem auto 0.65rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.game-number-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.game-number-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  min-width: 4ch;
}

/* Thin vertical divider */
.game-number-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
}

/* "Enter #" button — triggers modal */
.btn-enter-game {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.65rem;
  background: var(--surface-3, #26263a);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-enter-game:hover { border-color: var(--accent); color: var(--accent); }

/* Share button */
.btn-share {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-share:hover  { border-color: var(--accent); color: var(--accent); }
.btn-share.copied { border-color: var(--success, #4ade80); color: var(--success, #4ade80); }

/* ── Mobile adjustments ───────────────────────── */
@media (max-width: 400px) {
  .game-number-bar {
    padding: 0.45rem 0.65rem;
    gap: 0.35rem;
    border-radius: 12px;            /* card style on very small screens */
  }
  .game-number-label { font-size: 0.65rem; }
  .game-number-value { font-size: 0.95rem; }
  .btn-enter-game,
  .btn-share         { font-size: 0.7rem; padding: 0.22rem 0.5rem; }
}

.modal-game-num {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 0.75rem;
}
.modal-game-num strong { color: var(--accent); }

/* ── Player Name Modal ───────────────────────── */
.name-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 20, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.name-modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.name-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong, #3d3d58);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
}
.name-modal-overlay.show .name-modal {
  transform: translateY(0) scale(1);
}

.name-modal-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}

.name-modal h2 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  color: var(--text);
}

.name-modal p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.name-input-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.name-text-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  letter-spacing: 0.02em;
}
.name-text-input:focus {
  border-color: var(--accent);
}
.name-text-input::placeholder {
  color: var(--text-dim, #555570);
  font-weight: 400;
}

.name-char-count {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: var(--text-dim, #555570);
}

.name-submit-btn {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  letter-spacing: 0.02em;
}
.name-submit-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.02);
}
.name-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.name-skip-link {
  display: block;
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-dim, #555570);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.name-skip-link:hover { color: var(--text-muted); }

/* ── Hub welcome ─────────────────────────────── */
.lobby-welcome {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.lobby-welcome strong { color: var(--accent); }
.lobby-change-name {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim, #555570);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-left: 0.4rem;
  font-family: inherit;
  transition: color 0.2s;
}
.lobby-change-name:hover { color: var(--accent); }

/* ── Help button (? circle in game headers) ─── */
.btn-game-help {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
}
.btn-game-help:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Help / About Modal ───────────────────────── */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 20, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.help-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.help-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.75rem 1.5rem 2rem;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(129,140,248,0.08);
  transform: scale(0.95) translateY(12px);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.help-overlay.show .help-modal {
  transform: scale(1) translateY(0);
}
.help-modal::-webkit-scrollbar        { width: 4px; }
.help-modal::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 2px; }

.help-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.help-close:hover { background: var(--surface-3); color: var(--text); }

/* Header */
.help-game-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.help-game-icon {
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.help-game-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0 0 0.2rem;
}
.help-game-objective {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

/* Sections */
.help-section {
  margin-bottom: 1.25rem;
}
.help-section:last-child { margin-bottom: 0; }

.help-section-heading {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

/* Controls grid */
.help-keys {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.help-key-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.help-key-row span { color: var(--text-muted); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15em 0.55em;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 2ch;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.4;
}

/* Tips list */
.help-tips {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.help-tips li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.help-tips li::before {
  content: '›';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05em;
}

/* Text paragraphs */
.help-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Power-up / badge rows */
.help-badges {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.help-badge-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.help-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15em 0.6em;
  border-radius: 6px;
  border: 1px solid;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
  justify-content: center;
  font-family: inherit;
}

/* Scrollbar ── */
::-webkit-scrollbar        { width: 8px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Resume Modal ─────────────────────────────────────────────────────── */
.resume-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(30, 27, 75, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.resume-modal {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  max-width: 340px; width: 100%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(67,56,202,0.18);
}
.resume-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.resume-title { margin: 0 0 0.4rem; font-size: 1.3rem; font-weight: 700; color: var(--text); }
.resume-sub { margin: 0 0 1.25rem; font-size: 0.9rem; color: var(--text-muted); }
.resume-btns { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1.25rem; }
.resume-btn-primary {
  padding: 0.75rem 1rem; border-radius: 10px; border: none; cursor: pointer;
  font-size: 1rem; font-weight: 700;
  background: var(--accent); color: #fff;
  transition: background 0.15s;
}
.resume-btn-primary:hover { background: var(--accent-dark); }
.resume-btn-secondary {
  padding: 0.65rem 1rem; border-radius: 10px; cursor: pointer;
  font-size: 0.95rem; font-weight: 600;
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border);
  transition: border-color 0.15s, color 0.15s;
}
.resume-btn-secondary:hover { border-color: var(--accent); color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   UNIFIED GAME HEADER — used by every game page
   3-col grid: [back] [title] [controls]
   Title is always pixel-perfect centered regardless of control width.
   ══════════════════════════════════════════════════════════════════ */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  height: 52px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  box-sizing: border-box;
}

.game-header .back-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3em 0.65em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.game-header .back-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.game-title {
  justify-self: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  margin: 0;
}

.header-controls {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
