/* ═══════════════════════════════════════════════════════════
   JigsawPuzzlet — style.css
   Theme: Windows XP Silver — light grey, silver, steel blue
   No black. No GPU-heavy CSS (no backdrop-filter, no transforms on hover, no box-shadow animations).
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* ── XP Silver palette ──────────────────────────────── */
  --white:      #ffffff;
  --bg:         #ece9d8;        /* XP classic desktop tan/silver */
  --surface:    #f0eff0;        /* slightly lighter silver surface */
  --silver:     #d4d0c8;        /* classic XP border silver */
  --silver-lt:  #f5f4f1;        /* light silver for inputs */
  --silver-dk:  #a8a090;        /* darker silver for accents */

  /* Primary: XP steel blue */
  --primary:    #1f5799;        /* XP title bar blue */
  --primary-dk: #164080;
  --primary-lt: #cfddf0;

  /* Accent: XP green button */
  --accent:     #2e7d32;
  --accent-dk:  #1b5e20;
  --accent-lt:  #d8f0d8;

  /* Text — no black, use dark grey */
  --ink:        #1c1c1c;        /* very dark grey, not black */
  --ink2:       #3a3a3a;        /* secondary dark grey */
  --muted:      #595950;        /* muted grey-brown */
  --bdr:        #b8b4ac;        /* silver border */
  --bdr-lt:     #d0cdc6;        /* lighter border */

  /* Canvas / game bg */
  --canvas-bg:  #4a4a52;        /* dark grey for puzzle canvas */

  /* Status */
  --red:        #cc3333;
  --green:      #2e7d32;
  --amber:      #b8860b;

  /* Layout */
  --nav-h:      56px;
  --radius:     4px;
  --radius-lg:  6px;
  --shadow:     1px 2px 4px rgba(0,0,0,0.18);
  --shadow-lg:  2px 4px 8px rgba(0,0,0,0.22);
}

/* ── BASE ─────────────────────────────────────────────── */
html { scroll-behavior: auto; }
body {
  font-family: 'DM Sans', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: underline; }
a:hover { text-decoration: underline; color: var(--primary-dk); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
ul { list-style: none; }
h1, h2, h3, h4 {
  font-family: 'DM Sans', Tahoma, sans-serif;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
}

/* ── HEADER / NAV ─────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 90;
  height: var(--nav-h);
  /* XP-style gradient header — steel blue */
  background: linear-gradient(180deg, #2d6db5 0%, #1a4d8f 55%, #15437d 100%);
  border-bottom: 2px solid #0e3060;
}
.nav-inner {
  max-width: 1300px; margin: 0 auto;
  height: 100%;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.2rem;
}
.brand {
  font-family: 'DM Sans', Tahoma, sans-serif;
  font-size: 1.25rem; font-weight: 700;
  color: #ffffff; white-space: nowrap;
  letter-spacing: -0.01em;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}
.brand em { color: #FFE82B; font-style: normal; }

.nav-links {
  display: flex; align-items: center; gap: 0.1rem;
  margin-left: auto;
}
.nav-links li a {
  display: block; padding: 0.35rem 0.75rem;
  font-size: 0.84rem; font-weight: 500;
  color: #ddeeff; border-radius: var(--radius);
  text-decoration: none;
}
.nav-links li a:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  text-decoration: underline;
}
.nav-cta {
  background: rgba(255,255,255,0.22) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.35) !important;
  border-radius: var(--radius) !important;
  padding: 0.35rem 0.9rem !important;
  font-weight: 600 !important;
}
.nav-cta:hover {
  background: rgba(255,255,255,0.32) !important;
  color: #fff !important;
  text-decoration: none !important;
}

/* Avatar dropdown */
.nav-avatar-wrap { position: relative; }
.nav-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem;
  cursor: pointer; text-decoration: none;
}
.nav-avatar:hover { background: rgba(255,255,255,0.35); text-decoration: none; }
.nav-avatar-admin {
  outline: 2px solid #ffd700;
  outline-offset: 1px;
}
.nav-drop {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px; overflow: hidden;
  flex-direction: column; z-index: 100;
}
.nav-avatar-wrap:hover .nav-drop { display: flex; }
.nav-drop a {
  padding: 0.55rem 0.9rem; font-size: 0.82rem;
  color: var(--ink2); border-bottom: 1px solid var(--bdr-lt);
  font-weight: 500;
}
.nav-drop a:last-child { border-bottom: none; }
.nav-drop a:hover { background: var(--primary-lt); color: var(--primary); text-decoration: none; }

.nav-burger {
  display: none; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; margin-left: auto;
  color: #fff; padding: 0.3rem;
}

/* ── MAIN ─────────────────────────────────────────────── */
.site-main { min-height: calc(100vh - var(--nav-h) - 60px); }

/* ── FOOTER ───────────────────────────────────────────── */
.site-footer {
  background: #3c3c44;
  padding: 2.5rem 1.5rem 1.2rem;
  margin-top: 4rem;
  color: #c8c8cc;
  border-top: 2px solid #28282e;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-top {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  padding-bottom: 1.8rem;
  border-bottom: 1px solid #55555e;
  align-items: start;
}
@media (max-width: 700px) {
  .footer-top { grid-template-columns: 1fr; }
}
.footer-brand .brand { color: #e8e8ee; font-size: 1.1rem; }
.footer-brand .brand em { color: #FFE82B; }
.footer-tagline { font-size: .8rem; color: #aaaab2; margin-top: .4rem; line-height: 1.5; }

.footer-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1.2rem;
}
.footer-col { display: flex; flex-direction: column; gap: .3rem; }
.footer-col strong {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #b0b0b8;
  margin-bottom: .15rem;
  font-family: 'DM Sans', Tahoma, sans-serif;
}
.footer-col a {
  font-size: .82rem;
  color: #c0c0c8;
  text-decoration: none;
}
.footer-col a:hover { color: #e8e8f0; text-decoration: underline; }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  padding-top: 1rem;
}
.footer-copy { font-size: .73rem; color: #b0b0b8; margin: 0; }
.footer-legal-links {
  display: flex; gap: 0; list-style: none; padding: 0; flex-wrap: wrap;
}
.footer-legal-links li a {
  font-size: .73rem;
  color: #b0b0b8;
  padding: .1rem .5rem;
  border-right: 1px solid #55555e;
}
.footer-legal-links li:last-child a { border-right: none; }
.footer-legal-links li a:hover { color: #e0e0e8; text-decoration: none; }


/* ── COMPACT HERO BAR ────────────────────────────────────── */
.hero-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
  padding: 0.7rem 1.5rem 0.65rem;
  background: var(--surface);
  border-bottom: 1px solid var(--bdr);
  max-width: 100%;
}
.hero-bar-left { flex: 1; min-width: 0; }
.hero-bar h1 {
  font-size: 1rem; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3; margin: 0;
}
.hero-bar-sub { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
.hero-bar-desc { font-size: 0.78rem; color: var(--muted); margin: 0.1rem 0 0; line-height: 1.4; }
.hero-bar-right {
  display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; flex-wrap: wrap;
}
.hero-bar-stat { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.hero-bar-stat strong { color: var(--primary); font-weight: 700; }

/* ── NAV BRAND ─────────────────────────────────────────── */
.brand,
.brand:hover,
.g-brand,
.g-brand:hover { text-decoration: none; }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 600; border-radius: var(--radius);
  padding: 0.6rem 1.2rem; font-size: 0.88rem;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none !important;
}
.btn-primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary-dk);
}
.btn-primary:hover {
  background: var(--primary-dk);
  text-decoration: none; color: #fff;
}
.btn-secondary {
  background: var(--silver-lt); color: var(--ink2);
  border: 1px solid var(--bdr);
}
.btn-secondary:hover {
  background: var(--silver); border-color: var(--silver-dk);
  color: var(--ink); text-decoration: none;
}
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent-dk); }
.btn-accent:hover { background: var(--accent-dk); text-decoration: none; color: #fff; }
.btn-sm { padding: 0.32rem 0.72rem; font-size: 0.77rem; }
.btn-danger { background: var(--red); color: #fff; border-color: #aa2222; }
.btn-danger:hover { background: #aa2222; text-decoration: none; color: #fff; }
.btn-full { width: 100%; justify-content: center; padding: 0.8rem; font-size: 0.95rem; }
.btn-white {
  background: #fff; color: var(--primary);
  border: 1px solid var(--bdr); font-weight: 700;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.65rem 1.4rem; border-radius: var(--radius); font-size: 0.92rem;
  text-decoration: none;
}
.btn-white:hover { background: var(--primary-lt); text-decoration: none; }

/* ── BREADCRUMBS ──────────────────────────────────────── */
.breadcrumbs {
  max-width: 1400px; margin: 0 auto;
  padding: 0.55rem 1.5rem 0;
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.76rem; color: var(--muted);
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--primary); text-decoration: none; font-weight: 500;
}
.breadcrumbs a:hover { color: var(--primary-dk); text-decoration: underline; }
.breadcrumbs-sep { color: var(--bdr); user-select: none; }
.breadcrumbs-current { color: var(--muted); font-weight: 500; }

/* ── SECTION HEADER ───────────────────────────────────── */
.section-head {
  max-width: 1400px; margin: 0 auto;
  padding: 0.9rem 1.5rem 0.4rem;
  display: flex; align-items: baseline; justify-content: space-between;
}
.section-head h2 { font-size: 1.1rem; font-weight: 700; color: var(--ink2); }
.section-head a { font-size: 0.82rem; color: var(--primary); font-weight: 500; text-decoration: underline; }

/* ── PUZZLE GRID ──────────────────────────────────────── */
.puzzle-grid {
  max-width: 1400px; margin: 0 auto;
  padding: 0.3rem 1.5rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
}

/* ── CARD WRAP — image-only overlay cards ──────────────── */
.puzzle-card-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--bdr);
  position: relative;
  background: var(--silver);
}
.puzzle-card-wrap:hover {
  border-color: var(--primary);
}
.puzzle-card {
  display: block;
  text-decoration: none !important;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}

/* Image fills the card */
.puzzle-card-img {
  aspect-ratio: 4/3;
  background: var(--silver); position: relative;
  display: block;
}
.puzzle-card-img img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}

/* ── TITLE/META OVERLAY — always visible at bottom ──── */
.puzzle-card-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1.6rem 0.6rem 0.5rem;
  background: linear-gradient(to top, rgba(28,28,28,0.78) 0%, rgba(28,28,28,0.38) 65%, transparent 100%);
  pointer-events: none;
  z-index: 2;
}
.puzzle-card-title-overlay {
  font-size: 0.78rem; font-weight: 700;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 0.1rem;
}
.puzzle-card-meta-overlay {
  font-size: 0.64rem; color: rgba(255,255,255,0.72);
}

/* ── PLAY-AS OVERLAY — slides up on hover ─────────────── */
/* Positioned relative to .puzzle-card-wrap so overflow:hidden on
   the wrap (not .puzzle-card-img) contains it cleanly — no silver bleed */
.play-as-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 0.2rem;
  padding: 0.4rem 0.4rem;
  background: rgba(28,28,36,0.94);
  transform: translateY(100%);
  transition: transform 0.18s ease;
  z-index: 4;
  flex-wrap: nowrap;
  justify-content: center;
}
.puzzle-card-wrap:hover .play-as-overlay {
  transform: translateY(0);
}
.play-as-label {
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: rgba(255,255,255,0.55);
  white-space: nowrap; flex-shrink: 0;
}
.play-as-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.15rem 0.32rem;
  border: 1px solid rgba(255,255,255,0.22); border-radius: 3px;
  background: rgba(255,255,255,0.08); color: #e0e0e0;
  font-size: 0.64rem; font-weight: 600;
  cursor: pointer; text-decoration: none !important;
  line-height: 1.4; white-space: nowrap;
  flex-shrink: 0;
}
.play-as-btn:hover, .play-as-btn.active {
  background: var(--primary); border-color: var(--primary-dk);
  color: #fff; text-decoration: none !important;
}
.play-as-btn.current-pieces {
  background: var(--accent); border-color: var(--accent-dk); color: #fff;
}

/* Legacy — hide old card body if rendered anywhere */
.puzzle-card-body { display: none; }
.puzzle-card-badge { display: none !important; }
.puzzle-card-desc { display: none; }
.play-as-bar { display: none; }

/* ── GAME PAGE ────────────────────────────────────────── */
body.game-page { overflow: hidden; background: var(--canvas-bg); }
body.game-page .site-header { display: none; }
body.game-page .site-main { padding: 0; }
body.game-page .site-footer { display: none; }

#game-topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 46px; z-index: 90;
  background: #3c3c44;
  border-bottom: 1px solid #28282e;
  display: flex; align-items: center;
  padding: 0 0.75rem; gap: 0.5rem;
}

/* Brand — left side */
.g-brand {
  font-family: 'DM Sans', Tahoma, sans-serif;
  font-size: 0.9rem; font-weight: 700;
  color: #e0e0e8; white-space: nowrap; flex-shrink: 0;
  text-decoration: none;
}
.g-brand em { color: #FFE82B; font-style: normal; }

/* Title chip */
.g-title-chip {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
  font-size: 0.73rem; font-weight: 600;
  color: #d0d0d8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}

/* Stats */
.g-stats {
  display: flex; align-items: center; gap: 0.7rem;
  flex-shrink: 0;
}
.g-stat {
  display: flex; align-items: center; gap: 0.2rem;
  font-size: 0.7rem; color: rgba(255,255,255,0.42);
  white-space: nowrap;
}
.g-stat strong { color: #d8d8e0; font-size: 0.76rem; font-variant-numeric: tabular-nums; }

/* Controls */
.g-controls {
  display: flex; gap: 0.25rem; flex-shrink: 0;
}
.g-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 3px; color: #d8d8e0; font-size: 0.68rem;
  padding: 0.28rem 0.58rem; cursor: pointer;
  font-family: inherit;
  text-decoration: none; white-space: nowrap;
}
.g-btn:hover { background: rgba(255,255,255,0.16); color: #fff; text-decoration: none; }

#canvas-container {
  position: fixed; top: 46px; left: 0; right: 0; bottom: 0;
  overflow: hidden; cursor: grab;
  background: var(--canvas-bg);
}
#canvas-container.grabbing { cursor: grabbing; }
#puzzle-canvas { position: absolute; top: 0; left: 0; touch-action: none; display: block; }

#progress-bar-wrap { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.06); z-index: 10; }
#progress-bar { height: 100%; background: var(--primary); width: 0%; }

#toolbar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0.3rem; z-index: 20; flex-wrap: wrap; justify-content: center;
}
.tb-btn {
  background: #3c3c44;
  border: 1px solid #585860; border-radius: 3px;
  color: #d8d8e0; font-size: 0.68rem; padding: 0.38rem 0.65rem;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.tb-btn:hover { background: #505058; border-color: #6868a0; }

#ghost-preview {
  position: absolute; bottom: 52px; right: 12px;
  border-radius: 3px; border: 1px solid rgba(255,255,255,0.2);
  opacity: 0.82; pointer-events: none; display: none; z-index: 30;
  max-width: 150px; max-height: 110px;
}

#loading-overlay {
  position: absolute; inset: 0; background: var(--canvas-bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 100;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #FFE82B; border-radius: 50%;
  animation: spin 0.75s linear infinite; margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay h2 { font-family: 'DM Sans', Tahoma, sans-serif; color: #d8d8e0; font-size: 1.2rem; margin-bottom: 0.3rem; }
#loading-overlay p { color: rgba(255,255,255,0.32); font-size: 0.8rem; }

/* Win screen */
#win-screen {
  display: none; position: absolute; inset: 0;
  background: rgba(28,28,36,0.82); z-index: 200;
  align-items: center; justify-content: center;
}
#win-screen.show { display: flex; }
.win-card {
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem; text-align: center; max-width: 360px;
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.win-emoji { font-size: 2.8rem; display: block; margin-bottom: 0.4rem; }
.win-card h2 { font-size: 1.7rem; font-weight: 700; margin-bottom: 0.25rem; }
.win-card p { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.1rem; }
.win-time { font-size: 2.8rem; font-weight: 700; color: var(--primary); line-height: 1; }
.win-time-lbl { font-size: 0.72rem; color: var(--muted); display: block; margin-bottom: 1.2rem; }
.win-leaderboard { text-align: left; border: 1px solid var(--bdr); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.win-leaderboard h4 { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; padding: .45rem .75rem; background: var(--bg); color: var(--muted); border-bottom: 1px solid var(--bdr); }
.win-lb-row { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; font-size: .8rem; border-bottom: 1px solid var(--bdr-lt); }
.win-lb-row:last-child { border-bottom: none; }
.win-lb-rank { font-weight: 700; color: var(--primary); width: 1.3rem; }
.win-lb-name { flex: 1; color: var(--ink2); }
.win-lb-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.win-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.win-btn { padding: .6rem 1.2rem; border: 1px solid var(--bdr); border-radius: var(--radius); font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.win-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary-dk); }
.win-btn.primary:hover { background: var(--primary-dk); }
.win-btn.secondary { background: var(--silver-lt); color: var(--ink2); }
.win-btn.secondary:hover { background: var(--silver); }

/* Private badge */
.private-badge {
  position: fixed; top: 56px; right: 10px;
  background: rgba(200,50,50,0.1); border: 1px solid rgba(200,50,50,0.3);
  border-radius: 3px; padding: .22rem .6rem; font-size: .7rem; color: #cc5555; z-index: 40;
}

/* Piece switcher panel */
#piece-switcher-panel {
  position: fixed; bottom: 58px; left: 50%; transform: translateX(-50%);
  z-index: 60; display: none;
  background: #3c3c44;
  border: 1px solid #585860; border-radius: var(--radius);
  padding: 0.8rem 1rem 0.7rem; min-width: 270px;
  box-shadow: var(--shadow-lg);
}
#piece-switcher-panel.open { display: block; }
#piece-switcher-panel h4 {
  font-size: 0.74rem;
  color: #9090a0; text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 0.6rem;
}
.ps-options { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.ps-btn {
  display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.08rem; min-width: 50px;
  padding: 0.4rem 0.55rem;
  border: 1px solid #585860; border-radius: var(--radius);
  background: rgba(255,255,255,0.05); color: #c8c8d0;
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
  font-family: inherit; line-height: 1.2;
  text-decoration: none;
}
.ps-btn .ps-label {
  font-size: 0.57rem; font-weight: 400; color: #7070808;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.ps-btn:hover {
  background: rgba(31,87,153,0.5); border-color: #4477aa;
  color: #fff;
}
.ps-btn.ps-active { background: var(--primary); border-color: var(--primary-dk); color: #fff; }
.ps-btn.ps-active .ps-label { color: rgba(255,255,255,0.6); }

/* SEO off-screen block */
#seo-content { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; overflow: hidden; pointer-events: none; }

/* ── AUTH PAGES ───────────────────────────────────────── */
.auth-wrap { max-width: 420px; margin: 3.5rem auto; padding: 0 1.5rem; }
.auth-card {
  background: var(--surface); border: 1px solid var(--bdr);
  border-radius: var(--radius-lg); padding: 2rem 1.8rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.7rem; margin-bottom: 0.25rem; }
.auth-sub { color: var(--muted); margin-bottom: 1.8rem; font-size: 0.88rem; }
.auth-card .auth-link { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }

/* ── FORMS ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.73rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 0.3rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 0.55rem 0.8rem;
  border: 1px solid var(--bdr); border-radius: var(--radius);
  font-size: 0.88rem; background: var(--silver-lt); color: var(--ink);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  background: #fff;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-hint { font-size: .72rem; color: var(--muted); margin-top: .22rem; display: block; }
.req { color: var(--red); }
.form-group .error { font-size: 0.75rem; color: var(--red); margin-top: 0.22rem; }

/* ── ALERTS ───────────────────────────────────────────── */
.alert {
  padding: 0.7rem 0.9rem; border-radius: var(--radius);
  font-size: 0.86rem; margin-bottom: 1.1rem;
  border: 1px solid transparent;
}
.alert-success { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.alert-error   { background: #fdecea; border-color: #f4a0a0; color: var(--red); }
.alert-info    { background: #e3effa; border-color: #90bde0; color: var(--primary-dk); }

/* ── UPLOAD PAGE ──────────────────────────────────────── */
.upload-wrap { max-width: 660px; margin: 2.5rem auto; padding: 0 1.5rem; }
.upload-wrap h1 { font-size: 1.8rem; margin-bottom: 0.25rem; }
.upload-wrap .page-sub { color: var(--muted); margin-bottom: 1.8rem; }
.upload-card {
  background: var(--surface); border: 1px solid var(--bdr);
  border-radius: var(--radius-lg); padding: 1.8rem; box-shadow: var(--shadow);
}
#drop-zone {
  border: 2px dashed var(--bdr); border-radius: var(--radius);
  background: var(--bg); padding: 2rem 1.5rem;
  text-align: center; cursor: pointer;
  margin-bottom: 1.3rem;
}
#drop-zone:hover, #drop-zone.dragover { border-color: var(--primary); }
#drop-zone .dz-icon { font-size: 2.4rem; margin-bottom: 0.4rem; display: block; }
#drop-zone h3 { font-size: 1.05rem; }
#drop-zone p { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.upload-path-note {
  font-size: .76rem; color: var(--muted);
  background: var(--bg); border: 1px solid var(--bdr);
  border-radius: var(--radius); padding: .5rem .8rem; margin-bottom: 1rem;
}
.upload-path-note code { font-family: monospace; color: var(--primary); font-size: .8rem; }

/* ── PROFILE / SETTINGS ───────────────────────────────── */
.profile-wrap { max-width: 880px; margin: 2.5rem auto; padding: 0 1.5rem; }
.profile-header { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 2rem; }
.profile-avatar-lg {
  width: 64px; height: 64px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; flex-shrink: 0;
}
.profile-meta h2 { font-size: 1.6rem; margin-bottom: 0.1rem; }
.profile-meta p { color: var(--muted); font-size: 0.86rem; }

/* ── BROWSE PAGE ──────────────────────────────────────── */
.browse-wrap { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }
.browse-wrap h1 { font-size: 1.9rem; margin-bottom: 0.35rem; }
.browse-wrap .page-sub { color: var(--muted); margin-bottom: 1.8rem; }
.filter-bar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-btn {
  background: var(--silver-lt); border: 1px solid var(--bdr);
  border-radius: var(--radius); padding: 0.28rem 0.8rem;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  color: var(--muted);
}
.filter-btn.active, .filter-btn:hover {
  background: var(--primary); color: #fff; border-color: var(--primary-dk);
}
.filter-bar select {
  padding: 0.28rem 0.65rem; border: 1px solid var(--bdr);
  border-radius: var(--radius); font-size: 0.78rem;
  background: var(--silver-lt); cursor: pointer; color: var(--ink);
}
.pagination { display: flex; justify-content: center; gap: 0.35rem; padding: 1.8rem 0; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 0.82rem; font-weight: 600;
  background: var(--silver-lt); border: 1px solid var(--bdr); color: var(--ink2);
  cursor: pointer;
}
.page-btn.active, .page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary-dk); }

/* ── ADMIN ────────────────────────────────────────────── */
.admin-wrap { max-width: 1000px; margin: 2.5rem auto; padding: 0 1.5rem; }
.admin-wrap h1 { font-size: 1.8rem; margin-bottom: 1.8rem; }
.admin-table-wrap {
  background: var(--surface); border: 1px solid var(--bdr);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--silver); padding: 0.65rem 0.9rem;
  font-size: 0.71rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); text-align: left;
  border-bottom: 1px solid var(--bdr);
}
td {
  padding: 0.62rem 0.9rem; font-size: 0.82rem;
  border-top: 1px solid var(--bdr-lt); vertical-align: middle;
}
tr:hover td { background: var(--silver-lt); }
.td-thumb { width: 46px; height: 35px; object-fit: cover; border-radius: 3px; }

/* ── MISC ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3.5rem 1.5rem; color: var(--muted); }
.empty-state .es-icon { font-size: 3rem; margin-bottom: 0.8rem; display: block; }
.empty-state p { font-size: 0.88rem; }
.badge {
  display: inline-block; padding: 0.15rem 0.5rem;
  border-radius: var(--radius); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
}
.badge-amber { background: #fef3c7; color: #92620a; }
.badge-green { background: #d8f0d8; color: var(--green); }
.badge-red   { background: #fdecea; color: var(--red); }
.divider { height: 1px; background: var(--bdr-lt); margin: 1.4rem 0; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.page-sub { color: var(--muted); margin-bottom: 1.8rem; }

/* ── HOMEPAGE CONTENT ─────────────────────────────────── */
.home-content { margin: 2rem 2.5rem 3rem; }
.home-section-title {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .4rem;
}
.home-section-sub {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1.6rem;
  max-width: 580px;
}
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}
.why-card {
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
}
.why-card-icon { font-size: 1.7rem; margin-bottom: .6rem; display: block; }
.why-card h3 { font-size: 0.95rem; margin-bottom: .35rem; color: var(--ink2); }
.why-card p  { font-size: .84rem; color: var(--muted); line-height: 1.55; margin: 0; }

.how-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
  counter-reset: steps;
}
.how-step {
  background: var(--primary-lt);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  position: relative;
  counter-increment: steps;
}
.how-step::before {
  content: counter(steps);
  position: absolute;
  top: -11px; left: 1rem;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.how-step h3 { font-size: .88rem; margin-bottom: .3rem; color: var(--ink2); }
.how-step p  { font-size: .82rem; color: var(--muted); line-height: 1.55; margin: 0; }

.diff-table-wrap {
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 3rem;
}
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.diff-table th {
  background: var(--silver);
  color: var(--ink2);
  padding: .65rem .9rem;
  text-align: left;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.diff-table td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--bdr-lt);
  color: var(--ink2);
  vertical-align: middle;
}
.diff-table tr:last-child td { border-bottom: none; }
.diff-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.tips-list { list-style: none; padding: 0; margin-bottom: 3rem; }
.tip-item {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: .9rem 0;
  border-bottom: 1px solid var(--bdr-lt);
}
.tip-item:last-child { border-bottom: none; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: .1rem; }
.tip-item h4 { font-size: .9rem; margin-bottom: .25rem; color: var(--ink2); }
.tip-item p  { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.55; }

.benefits-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 3rem;
}
.benefit-item { display: flex; gap: .8rem; align-items: flex-start; }
.bi-icon { font-size: 1.4rem; flex-shrink: 0; }
.benefit-item h4 { font-size: .88rem; margin-bottom: .18rem; color: var(--ink2); }
.benefit-item p  { font-size: .8rem; color: var(--muted); margin: 0; line-height: 1.5; }

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
}
.faq-item h4 { font-size: .88rem; margin-bottom: .35rem; color: var(--ink2); }
.faq-item p  { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.55; }

.home-cta {
  background: var(--primary);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: #fff;
}
.home-cta h2 { color: #fff; font-size: 1.5rem; margin-bottom: .4rem; }
.home-cta p  { color: rgba(255,255,255,.78); font-size: .9rem; margin-bottom: 1.2rem; }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column;
    position: fixed; inset: var(--nav-h) 0 0 0;
    background: #3c3c44; z-index: 88;
    padding: 1.2rem 1.2rem;
    gap: 0.2rem; overflow-y: auto;
    border-top: 1px solid #28282e;
  }
  .nav-links.open li a {
    font-size: 0.95rem; padding: 0.65rem 0.9rem;
    border-radius: var(--radius); color: #d8d8e0;
    font-weight: 500;
  }
  .nav-links.open li a:hover { background: rgba(255,255,255,0.1); color: #fff; }
  .nav-burger { display: block; }

  #game-topbar {
    height: auto; min-height: 46px;
    flex-wrap: wrap;
    padding: 0.35rem 0.55rem;
    gap: 0.3rem;
  }
  .g-brand { font-size: 0.78rem; }
  .g-title-chip { font-size: 0.66rem; padding: 0.16rem 0.45rem; max-width: 36vw; }
  .g-stats {
    order: 10; width: 100%;
    justify-content: center;
    gap: 0.8rem;
    padding: 0.12rem 0 0.22rem;
    border-top: 1px solid rgba(255,255,255,0.06);
  }
  .g-stat { font-size: 0.65rem; }
  .g-stat strong { font-size: 0.7rem; }
  .g-controls { gap: 0.22rem; }
  .g-btn { font-size: 0.64rem; padding: 0.26rem 0.48rem; }
  #canvas-container { top: 84px; }

  .hero-bar { flex-direction: column; align-items: flex-start; gap: 0.4rem; padding: 0.6rem 1rem; }
  .hero-bar h1 { font-size: 0.88rem; white-space: normal; }
  .hero-bar-desc { display: none; }
  .puzzle-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.4rem; }
  .form-row { grid-template-columns: 1fr; }
  .win-card { margin: 1rem; padding: 1.6rem 1.3rem; max-width: calc(100vw - 2rem); }
  .auth-wrap { margin: 1.8rem auto; }
  .browse-wrap, .upload-wrap, .profile-wrap { padding: 1.3rem 0.9rem; }
  .admin-wrap { padding: 1.3rem 0.9rem; }
  table { font-size: 0.76rem; }
  td, th { padding: 0.5rem 0.6rem; }
  .td-thumb { width: 36px; height: 26px; }
  .home-content { margin: 1.5rem 1rem 2rem; }
}

@media (max-width: 420px) {
  .g-title-chip { max-width: 26vw; font-size: 0.62rem; }
  .g-btn { padding: 0.22rem 0.38rem; font-size: 0.6rem; }
  .g-controls .g-btn:nth-child(2) { display: none; }
  #canvas-container { top: 88px; }
}
