/* ============================================================
   ATLASQUEST — "INK & PAPER" MANGA EDITION
   Retro 2D black-and-white manga style.
   Paper + ink + screentone + hard offset shadows.
   Light = Paper Edition · Dark = Night Edition.
   Spec: design/MANGA-DESIGN.md
   ============================================================ */

/* ---------- Fonts (bundled, OFL) ---------- */
@font-face {
  font-family: "Lilita One";
  src: url("../assets/fonts/LilitaOne-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Anton";
  src: url("../assets/fonts/Anton-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("../assets/fonts/SpaceMono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("../assets/fonts/SpaceMono-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("../assets/fonts/SpaceMono-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-display: "Lilita One", "Arial Rounded MT Bold", "Comic Sans MS", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 14px;
  --radius-lg: 22px;
  --topbar-h: 64px;
  --tr-fast: .15s cubic-bezier(.4, 0, .2, 1);
  --tr: .22s cubic-bezier(.4, 0, .2, 1);
  --tr-spring: .32s cubic-bezier(.34, 1.56, .64, 1);
  --bw: 2.5px;                     /* base ink border width */
  --plate: #fff;                   /* fixed white flag plate, both themes */
  --ink-on-white: #16210f;         /* text sitting on --plate */
  --ink-on-white-soft: #55654e;
  --hard-shadow: 5px 5px 0 var(--shadow-ink);
  --hard-shadow-sm: 3px 3px 0 var(--shadow-ink);
  --hard-shadow-lg: 9px 9px 0 var(--shadow-ink);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #131a12;
  --paper-2: #1b251a;
  --paper-3: #243023;
  --ink: #e5f0da;
  --ink-soft: #afc2a6;
  --ink-faint: #75856e;
  --shadow-ink: #000;
  --accent: #7cc961;
  --accent-ink: #14200f;
  --stamp: #e2794f;
  --ok: #7cc961;
  --bad: #e2794f;
  --focus-ring: 0 0 0 3px rgba(124, 201, 97, .5);
  --scrim: rgba(6, 10, 6, .78);
  --screentone: rgba(229, 240, 218, .13);
}
html[data-theme="light"] {
  color-scheme: light;
  --paper: #ecefdf;
  --paper-2: #f8faf0;
  --paper-3: #e0e8d2;
  --ink: #22301f;
  --ink-soft: #55654e;
  --ink-faint: #8b9883;
  --shadow-ink: #22301f;
  --accent: #58a93c;
  --accent-ink: #f8faf0;
  --stamp: #d95d39;
  --ok: #22301f;
  --bad: #d95d39;
  --focus-ring: 0 0 0 3px rgba(88, 169, 60, .4);
  --scrim: rgba(34, 48, 31, .5);
  --screentone: rgba(34, 48, 31, .12);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-mono);
  background: var(--shadow-ink);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--tr);
}
::selection { background: var(--accent); color: var(--accent-ink); }

/* rectangular leaf-green scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--accent) var(--paper-3); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper-3); }
::-webkit-scrollbar-thumb { background: var(--accent); border: 3px solid var(--paper-3); }
::-webkit-scrollbar-thumb:hover { background: var(--ink); }
::-webkit-scrollbar-corner { background: var(--paper-3); }

/* paper grain over the black desk */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1.1px);
  background-size: 5px 5px;
  mix-blend-mode: overlay;
}

img { max-width: 100%; }
button { font-family: inherit; }

/* the paper sheet everything sits on */
.paper-frame {
  position: relative; z-index: 1;
  margin: 8px;
  background: var(--paper);
  background-image: url("../assets/gen/background-quiz-web.jpg");
  background-size: 900px;
  background-blend-mode: soft-light;
  border: 3px solid var(--ink);
  border-radius: 26px;
  box-shadow: var(--hard-shadow-lg);
  min-height: calc(100vh - 28px);
  transition: background var(--tr), border-color var(--tr);
}

/* ---------- background blobs (ink blobs w/ stars) ---------- */
.bg-orbs { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; border-radius: 23px; }
.orb {
  position: absolute; background: var(--ink); opacity: .92;
  border-radius: 58% 42% 55% 45% / 55% 48% 52% 45%;
  animation: blobMorph 22s ease-in-out infinite alternate;
  transition: background var(--tr);
}
html[data-theme="dark"] .orb { background: var(--paper-3); opacity: .55; }
.orb-1 { width: 380px; height: 350px; top: -200px; left: -170px; }
.orb-2 { width: 380px; height: 400px; top: 24%; right: -140px; border-radius: 42% 58% 45% 55% / 48% 55% 45% 52%; animation-delay: -7s; animation-duration: 26s; }
.orb-3 { width: 420px; height: 360px; bottom: -150px; left: 26%; border-radius: 55% 45% 60% 40% / 45% 55% 42% 58%; animation-delay: -13s; animation-duration: 30s; }
@keyframes blobMorph {
  0% { border-radius: 58% 42% 55% 45% / 55% 48% 52% 45%; transform: translate(0,0) rotate(0deg) scale(1); }
  50% { border-radius: 45% 55% 48% 52% / 52% 45% 55% 48%; transform: translate(24px, -18px) rotate(2.5deg) scale(1.05); }
  100% { border-radius: 52% 48% 58% 42% / 48% 52% 45% 55%; transform: translate(-16px, 20px) rotate(-2deg) scale(.97); }
}
/* star specks painted over blobs */
.orb::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle 2px at 22% 30%, var(--paper) 98%, transparent),
    radial-gradient(circle 1.5px at 64% 22%, var(--paper) 98%, transparent),
    radial-gradient(circle 1.5px at 78% 62%, var(--paper) 98%, transparent),
    radial-gradient(circle 2px at 40% 74%, var(--paper) 98%, transparent),
    radial-gradient(circle 1.2px at 52% 46%, var(--paper) 98%, transparent),
    radial-gradient(circle 1.2px at 14% 58%, var(--paper) 98%, transparent);
  opacity: .9;
}
.grid-lines { position: absolute; inset: 0;
  background-image: radial-gradient(var(--screentone) 1px, transparent 1.3px);
  background-size: 9px 9px;
  mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 25%, transparent 72%);
}

.view { position: relative; z-index: 2; min-height: calc(100vh - var(--topbar-h) - 60px); padding: 26px clamp(16px, 4vw, 44px) 80px; max-width: 1240px; margin: 0 auto; outline: none; }

/* ---------- route transition ---------- */
@keyframes riseIn { from { opacity: 0; transform: translateY(12px) rotate(.2deg); } to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes fadeInSoft { from { opacity: 0; } to { opacity: 1; } }
.view-anim > * { animation: riseIn .4s cubic-bezier(.22, 1, .36, 1) both; }
.view-anim > .page-bg { animation: none; } /* riseIn's fill-mode would lock opacity to 1 */
.view-anim .mode-grid > *, .view-anim .stat-strip > *, .view-anim .hero-cta > * { animation: riseIn .45s cubic-bezier(.22, 1, .36, 1) both; }
.view-anim .mode-grid > *:nth-child(1) { animation-delay: .05s; }
.view-anim .mode-grid > *:nth-child(2) { animation-delay: .1s; }
.view-anim .mode-grid > *:nth-child(3) { animation-delay: .15s; }
.view-anim .mode-grid > *:nth-child(4) { animation-delay: .2s; }
.view-anim .mode-grid > *:nth-child(5) { animation-delay: .25s; }
.view-anim .mode-grid > *:nth-child(6) { animation-delay: .3s; }
.view-anim .mode-grid > *:nth-child(7) { animation-delay: .35s; }
.view-anim .mode-grid > *:nth-child(8) { animation-delay: .4s; }
.view-anim .stat-strip > *:nth-child(2) { animation-delay: .07s; }
.view-anim .stat-strip > *:nth-child(3) { animation-delay: .14s; }
.view-anim .stat-strip > *:nth-child(4) { animation-delay: .21s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 clamp(14px, 3vw, 30px);
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
  border-radius: 22px 22px 0 0;
  transition: background var(--tr);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-globe { width: 34px; height: 34px; color: var(--ink); }
.brand-name { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .04em; text-transform: uppercase; }
.brand-name b { color: var(--ink); font-weight: 400; background: var(--accent); padding: 0 4px; margin-left: 2px; box-shadow: 2px 2px 0 var(--shadow-ink); }

.topbar-right { display: flex; align-items: center; gap: 9px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; min-width: 38px; border: var(--bw) solid var(--ink); border-radius: 12px;
  background: var(--paper-2); color: var(--ink); cursor: pointer;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--shadow-ink);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast), color var(--tr-fast);
}
.iconbtn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-ink); background: var(--accent); color: var(--accent-ink); }
.iconbtn:active { transform: translate(2px, 2px); box-shadow: none; }
.iconbtn .ico { width: 17px; height: 17px; }
.iconbtn.labeled, .iconbtn.with-label { width: auto; padding: 0 13px; gap: 8px; }
.iconbtn .btn-label { font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
/* Home sits at the front of the topbar so every mode has a way back without
   opening the drawer. Always visible, including on the home page itself. */
.home-btn:focus-visible { outline: none; box-shadow: var(--focus-ring), 2px 2px 0 var(--shadow-ink); }
@media (max-width: 560px) {
  .home-btn .btn-label { display: none; }
  .home-btn { width: 38px; padding: 0; }
  .brand-name { font-size: 1.05rem; }
}
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px;
  padding: 0 11px; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--paper-2); color: var(--ink);
  font-weight: 700; font-size: .8rem; letter-spacing: .05em;
  cursor: pointer; box-shadow: 2px 2px 0 var(--shadow-ink);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast);
}
.chip:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-ink); }
.chip:active { transform: translate(2px, 2px); box-shadow: none; }
.drawer-btn { margin-right: 2px; }

/* ---------- Drawer (left slide-out) ---------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 1150; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity var(--tr);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 14px; bottom: 14px; left: 14px; width: 276px; z-index: 1200;
  display: flex; flex-direction: column;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: 12px 12px 0 rgba(0,0,0,.4);
  transform: translateX(calc(-100% - 40px));
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: flex-end; padding: 12px 14px 0; position: relative; }
.drawer::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 19px;
  background-image: radial-gradient(var(--screentone) 1px, transparent 1.3px);
  background-size: 9px 9px;
}
.profile-card {
  position: relative; display: flex; align-items: center; gap: 12px;
  margin: 16px 14px 0; padding: 12px; text-align: left;
  background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 15px;
  box-shadow: 3px 3px 0 var(--shadow-ink); cursor: pointer; color: var(--ink);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast);
}
.profile-card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-ink); }
.profile-card .profile-ava .avatar-circle { border: 2.5px solid var(--ink); }
.profile-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.profile-name { font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: .92rem; }
.profile-lvl { font-size: .68rem; color: var(--ink-soft); font-weight: 700; letter-spacing: .04em; }
.drawer-xp {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin: 10px 14px 0; padding: 9px 12px;
  background: var(--accent); border: var(--bw) solid var(--ink); border-radius: 13px;
  box-shadow: 3px 3px 0 var(--shadow-ink);
}
.drawer-xp .xp-bar { flex: 1; height: 11px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; }
.drawer-xp .xp-fill { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .5s cubic-bezier(.22,1,.36,1); }
.drawer-xp-num { font-size: .68rem; font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.account-row {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin: 10px 14px 0; padding: 10px 12px; width: calc(100% - 28px);
  background: var(--paper); border: 2px dashed var(--ink); border-radius: 13px;
  color: var(--ink); cursor: pointer; text-align: left; font-family: var(--font-mono);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast);
}
.account-row:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-ink); background: var(--accent); color: var(--accent-ink); }
.account-row[hidden] { display: none; }
.account-row .ico { width: 16px; height: 16px; flex: none; }
.account-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.account-email { display: block; font-size: .66rem; opacity: .8; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-nav {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  margin: 14px 14px 0; padding: 8px; overflow-y: auto; flex: 1;
  background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 15px;
}
.drawer-nav .navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; border: var(--bw) solid transparent;
  color: var(--ink-soft); text-decoration: none;
  font-size: .82rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; background: none;
  transition: color var(--tr-fast), background var(--tr-fast), border-color var(--tr-fast), transform var(--tr-fast), box-shadow var(--tr-fast);
}
.drawer-nav .navlink:hover { color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink); transform: translate(-1px, -1px); }
.drawer-nav .navlink.active { color: var(--accent-ink); background: var(--accent); border-color: var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink); }
.drawer-nav .navlink .ico { width: 16px; height: 16px; flex: none; }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px;
  background: var(--stamp); color: var(--paper); border: 2px solid var(--ink);
  font-size: .66rem; font-weight: 800; text-align: center; line-height: 1.3;
}
.nav-badge[hidden] { display: none; }
.seg.wrap { flex-wrap: wrap; }
.lb-panel {
  position: fixed; top: 14px; bottom: 14px; right: 14px; width: 310px; z-index: 1200;
  display: flex; flex-direction: column;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: -12px 12px 0 rgba(0,0,0,.4);
  transform: translateX(calc(100% + 40px));
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  overflow-y: auto; padding: 16px 16px 14px;
}
.lb-panel.open { transform: translateX(0); }
.lb-panel h3 { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; letter-spacing: .03em; }
.lb-tabs { display: flex; gap: 5px; margin: 10px 0 12px; }
.lb-sec { margin-bottom: 6px; }
.lb-panel .friend-row, .global-board .gb-row { padding: 8px 9px; }
body.in-geo .lb-panel, body.in-versus .lb-panel, body.in-mapgame .lb-panel { display: none; }
.lb-btn-active { background: var(--accent) !important; color: var(--accent-ink) !important; }

.lobby-invites { border-top: 2px dashed var(--ink); padding-top: 12px; margin-top: 14px; }
.lobby-invites .h3 { margin-bottom: 8px; }
.lobby-invites .btn.small:disabled { opacity: .6; }
.lobby-invites .friend-row { padding: 8px 10px; }

/* notification bell + badge */
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  background: var(--stamp); color: #fff; border: 2px solid var(--paper-2);
  border-radius: 99px; display: flex; align-items: center; justify-content: center;
  font-size: .58rem; font-weight: 800; padding: 0 3px;
}
#notifBell { position: relative; }

/* notification panel */
.notif-panel {
  position: fixed; top: 64px; right: 14px; width: 330px; max-height: 420px; z-index: 1200;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: -8px 8px 0 rgba(0,0,0,.35); transform: translateY(-8px); opacity: 0;
  pointer-events: none; transition: transform .25s cubic-bezier(.22,1,.36,1), opacity .2s;
  overflow-y: auto; padding: 14px 16px 12px;
}
.notif-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.notif-panel .np-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 6px; border-radius: 10px; }
.notif-panel .np-item:hover { background: var(--paper-3); }
.notif-panel .np-item.unread { border-left: 3px solid var(--accent); }
.notif-panel .np-item .ico { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.notif-panel .np-item.unread .ico { color: var(--accent); }
.notif-panel .np-title { font-weight: 700; font-size: .82rem; }
.notif-panel .np-body { font-size: .74rem; color: var(--ink-soft); }
.notif-panel .np-time { font-size: .62rem; color: var(--ink-faint); margin-top: 1px; }

/* friends quick-view dropdown */
.fb-drop {
  position: fixed; top: 64px; right: 14px; width: 280px; max-height: 380px; z-index: 1200;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: -8px 8px 0 rgba(0,0,0,.35); transform: translateY(-8px); opacity: 0;
  pointer-events: none; transition: transform .25s cubic-bezier(.22,1,.36,1), opacity .2s;
  overflow-y: auto; padding: 12px 14px 10px;
}
.fb-drop.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.fb-drop .fb-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; }
.fb-drop .fb-row:hover { background: var(--paper-3); }
.fb-online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; margin-left: 4px; box-shadow: 0 0 0 2px var(--paper-2); }
.fb-offline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); display: inline-block; margin-left: 4px; }
.fb-view-all { display: block; width: 100%; text-align: center; padding: 8px; margin-top: 6px; border-radius: 10px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font-weight: 700; font-size: .78rem; cursor: pointer; text-decoration: none; }
.fb-view-all:hover { background: var(--accent); }

/* match invite banner */
.invite-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1300;
  width: min(420px, 92vw); display: flex; align-items: center; gap: 14px;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 0 4px var(--accent);
  padding: 14px 18px; animation: bannerIn .4s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes bannerIn { from { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(.92); } }
.invite-banner .ib-avatar { flex: none; }
.invite-banner .ib-info { flex: 1; min-width: 0; }
.invite-banner .ib-info .h3 { margin: 0 0 2px; }
.invite-banner .ib-btns { display: flex; gap: 8px; margin-top: 8px; }
.invite-banner .ib-btns .btn { flex: 1; padding: 9px 12px; }

.drawer-foot {
  position: relative; padding: 12px 16px;
  font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); text-align: center;
}
body.in-geo .drawer, body.in-geo .drawer-scrim { display: none; }
body.in-mapgame .drawer, body.in-mapgame .drawer-scrim { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 20px; border: var(--bw) solid var(--ink); border-radius: 13px;
  background: var(--paper-2); color: var(--ink);
  font-weight: 700; font-size: .9rem; letter-spacing: .04em;
  cursor: pointer; text-decoration: none; user-select: none;
  box-shadow: var(--hard-shadow-sm);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast), opacity var(--tr-fast);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shadow-ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shadow-ink); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--hard-shadow-sm); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.warm { background: var(--accent); color: var(--accent-ink); }
.btn.royal { background: var(--ink); color: var(--paper); box-shadow: var(--hard-shadow-sm); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--paper-2); color: var(--stamp); border-color: var(--stamp); box-shadow: 3px 3px 0 var(--stamp); }
.btn.danger:hover { box-shadow: 5px 5px 0 var(--stamp); }
.btn.big { padding: 14px 28px; font-size: 1rem; }
.btn.small { padding: 7px 12px; font-size: .78rem; box-shadow: 2px 2px 0 var(--shadow-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn .ico { width: 17px; height: 17px; }

/* ---------- Cards / panels ---------- */
.card {
  position: relative;
  background: var(--paper-2);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--hard-shadow);
  transition: transform var(--tr-spring), box-shadow var(--tr-spring), background var(--tr);
}
.card.pad { padding: 24px; }
.h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: .01em; text-transform: uppercase; margin: 0 0 8px; line-height: 1.04; }
.h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: .02em; text-transform: uppercase; margin: 0 0 6px; }
.h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.12rem; letter-spacing: .03em; text-transform: uppercase; margin: 0 0 6px; }
.sub { color: var(--ink-soft); margin: 0; line-height: 1.65; font-size: .92rem; }
.grad-text { color: var(--ink); background: var(--accent); padding: 0 .12em; box-shadow: 3px 3px 0 var(--shadow-ink); display: inline-block; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: .8rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 26px; } .mt-4 { margin-top: 40px; }

/* panel corner tab (manga chapter label) */
.panel-tab {
  position: absolute; top: -14px; left: 16px;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-display); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  padding: 3px 10px; transform: rotate(-1.2deg);
}

/* ---------- Forms ---------- */
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px;
  border: var(--bw) solid var(--ink); border-radius: var(--radius);
  background: var(--paper-2); color: var(--ink);
  font-size: .92rem; font-family: var(--font-mono);
  transition: box-shadow var(--tr-fast), transform var(--tr-fast);
}
.input:focus { outline: none; transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-ink); }
.input::placeholder { color: var(--ink-faint); }
select.input option { background: var(--paper-2); color: var(--ink); }

.seg { display: inline-flex; padding: 5px; gap: 5px; background: var(--paper-3); border: var(--bw) solid var(--ink); border-radius: var(--radius); flex-wrap: wrap; }
.seg button {
  padding: 8px 13px; border: 2px solid transparent; background: transparent;
  color: var(--ink-soft); font-weight: 700; font-size: .8rem; letter-spacing: .03em;
  font-family: var(--font-mono); cursor: pointer;
  transition: background var(--tr-fast), color var(--tr-fast), border-color var(--tr-fast), transform var(--tr-fast), box-shadow var(--tr-fast);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--paper-2); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink); }
.seg button:active { transform: scale(.97); }
.seg .seg-label { width: 100%; padding: 2px 8px 0; font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }

/* toggle switch — ink lever */
.switch { position: relative; display: inline-flex; align-items: center; width: 48px; height: 26px; cursor: pointer; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--paper-3); border: var(--bw) solid var(--ink); border-radius: 99px; transition: background var(--tr); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform var(--tr-spring), background var(--tr); }
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .knob { transform: translateX(21px); background: var(--ink); }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 12px;
  background: var(--paper-2); border: var(--bw) solid var(--ink); box-shadow: var(--hard-shadow);
  color: var(--ink); font-weight: 700; font-size: .85rem;
  animation: toastIn .3s cubic-bezier(.34, 1.56, .64, 1);
  max-width: min(92vw, 480px);
}
.toast.out { animation: toastOut .25s forwards; }
.toast .t-ico { display: inline-flex; color: var(--ink); }
.toast .t-ico .ico { width: 16px; height: 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.95); } }

/* ---------- Modal ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 1500; background: var(--scrim);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadeInSoft .2s;
}
.modal {
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--radius-lg);
  box-shadow: var(--hard-shadow-lg); width: 100%; max-width: 640px; max-height: 90vh;
  display: flex; flex-direction: column; animation: modalIn .3s cubic-bezier(.34, 1.4, .64, 1);
  overflow: hidden;
}
.modal.wide { max-width: 880px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 20px; border-bottom: 3px solid var(--ink);
  background: repeating-linear-gradient(-45deg, var(--paper-2) 0 10px, var(--paper-3) 10px 11px);
}
.modal-head .h3 { margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) rotate(.6deg) scale(.97); } }

/* ---------- Home ---------- */
.hero { position: relative; padding: clamp(30px, 6vw, 70px) 0 12px; text-align: center; }
.hero .h1 { font-size: clamp(2.7rem, 8vw, 5.6rem); line-height: 1; color: var(--ink);
  text-shadow: 4px 4px 0 var(--accent);
  transform: rotate(-1deg); }
.hero .h1 .grad-text { color: var(--accent); background: none; text-shadow: 4px 4px 0 var(--shadow-ink); box-shadow: none; padding: 0 .04em; }
.hero-tag { color: var(--ink-soft); font-size: clamp(.86rem, 2vw, 1rem); max-width: 620px; margin: 20px auto 0; line-height: 1.7; }
.hero-cta { display: flex; gap: 14px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }

.hero-bg {
  position: absolute; inset: -30px -30px 0; pointer-events: none;
  background-image: url("../assets/gen/banner-hero-web.jpg");
  background-size: cover; background-position: center 30%;
  opacity: .16; border-radius: 18px;
  mask-image: linear-gradient(#000 55%, transparent 96%);
  -webkit-mask-image: linear-gradient(#000 55%, transparent 96%);
}
html[data-theme="dark"] .hero-bg { opacity: .13; mix-blend-mode: luminosity; }
.hero-poster {
  position: relative; width: min(400px, 92%); margin: 34px auto 0;
  background: var(--plate); padding: 10px 10px 14px;
  color: var(--ink-on-white);
  border: var(--bw) solid var(--ink); border-radius: 10px;
  box-shadow: var(--hard-shadow); transform: rotate(-1.2deg);
  transition: transform var(--tr-spring), box-shadow var(--tr-spring);
}
.hero-poster:hover { transform: rotate(0deg) scale(1.02); box-shadow: 8px 8px 0 var(--shadow-ink); }
.hero-poster img { width: 100%; display: block; border-radius: 6px; }
.hero-poster .hp-caption { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; margin-top: 9px; color: var(--ink-on-white-soft); }
.hero-mascot {
  position: absolute; right: 3%; bottom: -6%; width: 132px;
  background: var(--plate); padding: 7px 7px 5px;
  border: var(--bw) solid var(--ink); border-radius: 10px;
  box-shadow: var(--hard-shadow);
  transform: rotate(4deg); pointer-events: none;
  animation: mascotBob 5s ease-in-out infinite alternate;
}
.hero-mascot { display: block; }
html[data-theme="dark"] .hero-mascot { opacity: .96; }
@keyframes mascotBob { from { transform: rotate(2deg) translateY(0); } to { transform: rotate(-2deg) translateY(-8px); } }
@media (max-width: 900px) { .hero-mascot { display: none; } .hero-bg { opacity: .1; } }
.hero-deco .doodle { position: absolute; color: var(--ink); opacity: .9; }
.hero-deco .doodle.d1 { left: 4%; top: 4%; width: 110px; transform: rotate(-4deg); }
.hero-deco .doodle.d2 { right: 3%; top: 5%; width: 130px; transform: rotate(6deg); }
.hero-deco .doodle.d3 { left: 5%; bottom: -6%; width: 150px; transform: rotate(2deg); }
.hero-deco .doodle.d4 { right: 9%; bottom: -10%; width: 130px; transform: rotate(-5deg); }
.hero-deco .doodle.d5 { left: 22%; top: 10%; width: 90px; transform: rotate(-3deg); opacity: .75; }
.hero-deco .doodle.d6 { right: 24%; top: 2%; width: 100px; transform: rotate(3deg); opacity: .8; }
.hero-deco .doodle svg { width: 100%; height: auto; display: block; }
@media (max-width: 900px) { .hero-deco .doodle { display: none; } .hero-deco .doodle.d2, .hero-deco .doodle.d4 { display: block; width: 90px; opacity: .55; } }

/* rotating circular expedition stamp */
.circle-stamp {
  position: absolute; right: 4%; top: 12%; width: 128px; height: 128px;
  display: grid; place-items: center; pointer-events: none;
}
.circle-stamp svg { width: 100%; height: 100%; animation: stampSpin 26s linear infinite; }
.circle-stamp .cs-core {
  position: absolute; width: 46%; height: 46%; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: .62rem; letter-spacing: .1em; text-align: center;
  color: var(--accent-ink); line-height: 1.15;
}
@keyframes stampSpin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .circle-stamp { display: none; } }

.mode-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); margin-top: 40px; }
.mode-card {
  position: relative; display: block; text-decoration: none; color: var(--ink);
  padding: 20px 20px 18px; border: var(--bw) solid var(--ink); border-radius: var(--radius);
  background: var(--paper-2); cursor: pointer; text-align: left;
  box-shadow: var(--hard-shadow);
  transition: transform var(--tr-spring), box-shadow var(--tr-spring), background var(--tr);
}
.mode-card:hover { transform: translate(-3px, -3px) rotate(-.4deg); box-shadow: 8px 8px 0 var(--shadow-ink); }
.mode-card:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--shadow-ink); }
.mode-card .mc-index {
  position: absolute; top: 8px; right: 12px;
  font-family: var(--font-display); font-size: 2.6rem; line-height: 1; color: var(--ink);
  opacity: .14;
}
.mode-card .mc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; margin-bottom: 12px; border-radius: 14px;
  border: var(--bw) solid var(--ink); background: var(--paper); color: var(--ink);
  box-shadow: 2px 2px 0 var(--shadow-ink); transform: rotate(-2deg);
  transition: transform var(--tr-spring), background var(--tr);
}
.mode-card:hover .mc-icon { transform: rotate(2deg) scale(1.06); background: var(--accent); }
.mode-card .mc-icon .ico { width: 22px; height: 22px; }
.mode-card h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; letter-spacing: .03em; text-transform: uppercase; margin: 0 0 6px; }
.mode-card p { margin: 0; color: var(--ink-soft); font-size: .82rem; line-height: 1.6; }
.mode-card .mc-arrow { position: absolute; right: 16px; bottom: 14px; opacity: 0; transform: translateX(-6px); transition: opacity var(--tr), transform var(--tr); font-weight: 700; color: var(--ink); }
.mode-card:hover .mc-arrow { opacity: 1; transform: translateX(0); }
.mode-card .mc-badge {
  position: absolute; top: -11px; left: 16px;
  font-size: .6rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink);
  transform: rotate(-2deg); z-index: 2;
}

.stat-strip { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-top: 34px; }
.stat-box { padding: 14px 16px; border: var(--bw) solid var(--ink); border-radius: 13px; background: var(--paper-2); box-shadow: var(--hard-shadow-sm); text-align: center; }
.stat-box .st-num { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; }
.stat-box .st-label { font-size: .64rem; color: var(--ink-faint); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-top: 6px; }

/* ---------- Quiz ---------- */
.quiz-shell { max-width: 760px; margin: 0 auto; }
.quiz-topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.q-progress { flex: 1; height: 18px; background: var(--paper-2); border: var(--bw) solid var(--ink); border-radius: 99px; box-shadow: 2px 2px 0 var(--shadow-ink); overflow: hidden; }
.qp-fill { height: 100%; background: repeating-linear-gradient(-45deg, var(--ink) 0 8px, var(--accent) 8px 16px); width: 0%; transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.q-score { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .95rem; }
.q-streak { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--ink); background: var(--accent); border: 2px solid var(--ink); padding: 2px 8px; box-shadow: 2px 2px 0 var(--shadow-ink); }
.q-streak .ico { width: 14px; height: 14px; }
.q-streak.pop { animation: pop .4s cubic-bezier(.34, 1.9, .64, 1); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.5) rotate(-3deg); } 100% { transform: scale(1); } }

.quiz-card { padding: clamp(20px, 4vw, 36px); }
.quiz-card::before {
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  background-image: radial-gradient(var(--screentone) 1px, transparent 1.3px);
  background-size: 8px 8px; border-radius: 4px;
}
.quiz-q { position: relative; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.2rem, 3vw, 1.6rem); letter-spacing: .02em; text-transform: uppercase; text-align: center; margin: 0 0 4px; line-height: 1.25; }
.quiz-qsub { position: relative; text-align: center; color: var(--ink-faint); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 20px; }
.quiz-flagsvg {
  position: relative; display: block; width: min(420px, 84%); margin: 6px auto 24px;
  background: #fff; padding: 9px; border-radius: 12px;
  border: var(--bw) solid var(--ink); box-shadow: var(--hard-shadow);
  transform: rotate(-.6deg);
  transition: transform var(--tr-spring);
}
.quiz-flagsvg:hover { transform: rotate(.4deg) scale(1.02); }

.choices { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
@media (max-width: 620px) { .choices { grid-template-columns: 1fr; } }
.choice {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  border: var(--bw) solid var(--ink); background: var(--paper-2);
  color: var(--ink); font-size: .95rem; font-weight: 700; cursor: pointer; text-align: left;
  box-shadow: 3px 3px 0 var(--shadow-ink);
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast);
}
.choice:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shadow-ink); }
.choice:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.choice .ckey {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 28px; height: 28px; border-radius: 9px; background: var(--ink); color: var(--paper);
  font-family: var(--font-display); font-size: .95rem;
}
.choice .cflag { width: 46px; height: 31px; object-fit: contain; border: 2px solid var(--ink); border-radius: 6px; flex: none; background: #fff; padding: 1px; }
.choice.correct { background: var(--accent); }
.choice.correct .ckey { background: var(--ink); color: var(--accent); }
.choice.wrong { background: var(--paper-2); color: var(--stamp); border-color: var(--stamp); box-shadow: 3px 3px 0 var(--stamp); animation: shake .4s; }
.choice.wrong .ckey { background: var(--stamp); color: var(--paper-2); }
.choice.dim { opacity: .4; }
.choice:disabled { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 60% { transform: translateX(6px); } }

.quiz-type-row { position: relative; display: flex; gap: 10px; }
.quiz-type-row .input { flex: 1; font-size: 1rem; padding: 13px 15px; }

.timer-ring { position: relative; width: 44px; height: 44px; flex: none; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .t-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 700; }
.timer-ring.warn .t-num { color: var(--stamp); }

/* stamp hit (correct / wrong) */
.stamp-hit {
  position: relative; display: inline-block;
  font-family: var(--font-display); letter-spacing: .1em; text-transform: uppercase;
  padding: 6px 14px; border: 3px solid currentColor; border-radius: 12px;
  transform: rotate(-6deg); animation: stampHit .28s cubic-bezier(.34, 1.56, .64, 1) both;
}
.stamp-hit.ok { color: var(--accent-ink); background: var(--accent); border-color: var(--ink); }
.stamp-hit.no { color: var(--stamp); background: transparent; }
@keyframes stampHit { 0% { opacity: 0; transform: rotate(-6deg) scale(1.7); } 100% { opacity: 1; transform: rotate(-6deg) scale(1); } }

/* reveal */
.reveal {
  position: relative; margin-top: 20px; border: var(--bw) solid var(--ink); border-radius: var(--radius);
  background: var(--paper-2); overflow: hidden; box-shadow: var(--hard-shadow-sm);
  animation: revealIn .38s cubic-bezier(.22, 1, .36, 1);
}
@keyframes revealIn { from { opacity: 0; transform: translateY(14px) rotate(.4deg); } }
.reveal-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 2.5px solid var(--ink); background: repeating-linear-gradient(-45deg, var(--paper-2) 0 9px, var(--paper-3) 9px 10px); }
.reveal-flag { width: 76px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; flex: none; box-shadow: 3px 3px 0 var(--shadow-ink); }
.reveal-title { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; letter-spacing: .02em; text-transform: uppercase; }
.reveal-sub { color: var(--ink-soft); font-size: .78rem; letter-spacing: .04em; }
.reveal-body { padding: 14px 18px 18px; font-size: .9rem; line-height: 1.7; color: var(--ink-soft); }
/* collapsible reveal body */
/* .reveal-head already draws the solid bottom border, so the fold needs none */
.reveal-fold-sum {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  padding: 11px 18px; font-weight: 700; font-size: .8rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink); user-select: none;
  transition: background var(--tr-fast), color var(--tr-fast);
}
.reveal-fold-sum::-webkit-details-marker { display: none; }
.reveal-fold-sum::marker { content: ""; }
.reveal-fold-sum:hover { background: var(--paper-3); }
.reveal-fold-sum:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.reveal-fold-sum .ico { width: 16px; height: 16px; flex: none; transition: transform var(--tr); }
.reveal-fold[open] > .reveal-fold-sum .ico { transform: rotate(180deg); }
.reveal-fold[open] > .reveal-fold-sum { border-bottom: 2px dashed var(--ink-faint); background: var(--paper-3); }
.reveal-fold .reveal-body { padding-top: 12px; }
.reveal-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.chip-tag { padding: 4px 11px; border: 2px solid var(--ink); border-radius: 99px; background: var(--paper); font-size: .74rem; font-weight: 700; letter-spacing: .02em; box-shadow: 2px 2px 0 var(--shadow-ink); }
.chip-tag.gold { background: var(--accent); color: var(--accent-ink); }
.reveal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.linklike { background: none; border: none; color: var(--ink); font-weight: 700; cursor: pointer; font-size: .82rem; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-family: var(--font-mono); }
.linklike:hover { color: var(--stamp); }

/* results */
.result-wrap { max-width: 680px; margin: 0 auto; text-align: center; }
.score-hero { padding: clamp(26px, 5vw, 44px); position: relative; overflow: hidden; }
.score-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg at 50% 42%, var(--paper-2) 0deg 6deg, var(--paper-3) 6deg 7deg);
  opacity: .5;
}
.score-hero > * { position: relative; }
.score-hero .sh-num { font-family: var(--font-display); font-size: clamp(3rem, 9vw, 4.8rem); line-height: 1; }
.score-hero .sh-num.grad-text { color: var(--ink); background: var(--accent); padding: 0 .15em; box-shadow: 5px 5px 0 var(--shadow-ink); }
.result-squares { display: flex; gap: 6px; justify-content: center; margin: 16px 0 4px; flex-wrap: wrap; }
.result-squares .sq { width: 20px; height: 20px; border: 2px solid var(--ink); border-radius: 6px; background: var(--accent); animation: sqPop .35s cubic-bezier(.34, 1.56, .64, 1) both; }
.result-squares .sq.bad { background: var(--stamp); }
.result-squares .sq:nth-child(2) { animation-delay: .05s; } .result-squares .sq:nth-child(3) { animation-delay: .1s; }
.result-squares .sq:nth-child(4) { animation-delay: .15s; } .result-squares .sq:nth-child(5) { animation-delay: .2s; }
.result-squares .sq:nth-child(6) { animation-delay: .25s; } .result-squares .sq:nth-child(7) { animation-delay: .3s; }
.result-squares .sq:nth-child(8) { animation-delay: .35s; } .result-squares .sq:nth-child(9) { animation-delay: .4s; }
.result-squares .sq:nth-child(10) { animation-delay: .45s; }
@keyframes sqPop { from { opacity: 0; transform: scale(.3) rotate(-8deg); } }

.recap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px; margin: 24px 0; }
.recap-cell { border: 2px solid var(--ink); border-radius: 9px; background: #fff; padding: 7px 7px 6px; box-shadow: 3px 3px 0 var(--shadow-ink); transform: rotate(-1deg); }
.recap-cell:nth-child(even) { transform: rotate(1deg); }
.recap-cell.bad { background: var(--paper-3); outline: 2px solid var(--stamp); outline-offset: -4px; }
.recap-cell img { width: 100%; display: block; border: 1px solid var(--ink); }
.recap-cell .rc-name { font-size: .6rem; font-weight: 700; margin-top: 5px; color: var(--ink-on-white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .04em; }
.recap-cell.bad .rc-name { color: var(--ink); }

.xp-float { position: absolute; top: 12px; right: 16px; font-family: var(--font-display); color: var(--ink); font-size: 1.1rem; background: var(--accent); border: 2px solid var(--ink); padding: 1px 8px; box-shadow: 2px 2px 0 var(--shadow-ink); pointer-events: none; animation: xpUp 1.1s forwards; }
@keyframes xpUp { 0% { opacity: 0; transform: translateY(6px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

/* ---------- GeoGuesser ---------- */
.geo-wrap { position: fixed; inset: 0; z-index: 1100; background: var(--shadow-ink); }
body.in-geo .topbar { display: none; }
body.in-geo .view { display: none; }
body.in-geo .paper-frame { margin: 0; border: none; border-radius: 0; box-shadow: none; min-height: 100vh; }
.geo-wrap #pano { position: absolute; inset: 0; }
.geo-wrap .leaflet-container { background: #0a0e1a; }

.geo-hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 900;
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  pointer-events: none;
}
.geo-hud > * { pointer-events: auto; }
.geo-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 11px;
  background: var(--paper-2); border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.55);
  color: var(--ink); font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
}
.geo-badge .ico { width: 15px; height: 15px; }
.geo-badge[hidden] { display: none; }
.geo-timer .geo-timer-num { min-width: 34px; text-align: right; }
.geo-timer.low { color: var(--stamp); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.guess-panel { position: absolute; left: 14px; bottom: 14px; z-index: 1000; display: flex; flex-direction: column; gap: 9px; }
.guess-map {
  width: 340px; height: 230px; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 6px 6px 0 rgba(0,0,0,.55);
  overflow: hidden; cursor: crosshair; background: var(--paper-3);
  transition: width var(--tr), height var(--tr); resize: both; min-width: 200px; min-height: 140px; max-width: min(90vw, 780px); max-height: 70vh;
}
.guess-map.small { width: 220px; height: 150px; }
.guess-map.big { width: min(560px, 92vw); height: 400px; }
@media (max-width: 640px) { .guess-map { width: calc(100vw - 28px); height: 200px; } .guess-map.big { width: calc(100vw - 28px); height: 60vh; } }
.geo-guess-btn { width: 100%; padding: 13px; font-size: .95rem; }
.geo-guess-btn:disabled { opacity: .85; filter: none; background: var(--paper-3); color: var(--ink-soft); box-shadow: 3px 3px 0 var(--shadow-ink); }
.geo-exit { position: absolute; top: 12px; right: 14px; z-index: 1000; }
.geo-size-btns { display: flex; gap: 6px; }
.geo-size-btns button { width: 32px; height: 32px; border: 2.5px solid var(--ink); border-radius: 9px; background: var(--paper-2); color: var(--ink); cursor: pointer; font-weight: 700; font-size: .78rem; box-shadow: 2px 2px 0 rgba(0,0,0,.55); }
.geo-size-btns button:hover { background: var(--accent); }

.geo-result {
  position: absolute; inset: 0; z-index: 1200; display: flex; flex-direction: column;
  background: rgba(8, 7, 5, .45);
  animation: fadeInSoft .3s;
}
.geo-result .gr-map { flex: 1; min-height: 0; }
.gr-bar {
  display: flex; align-items: center; justify-content: center; gap: clamp(12px, 4vw, 44px); flex-wrap: wrap;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--paper-2); border-top: 3px solid var(--ink);
  color: var(--ink);
}
.gr-stat { text-align: center; min-width: 110px; }
.gr-stat .grs-label { font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.gr-stat .grs-num { font-family: var(--font-display); font-size: 1.6rem; }
.gr-stat .grs-num.grad { background: var(--accent); padding: 0 8px; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink); }
.gr-line { width: 2px; align-self: stretch; background: var(--ink); opacity: .2; display: none; }
@media (min-width: 560px) { .gr-line { display: block; } }
.gr-locname { font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

.leaflet-control-attribution { background: rgba(20, 17, 12, .8) !important; color: #b7b2a4 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #f5d920 !important; }
.leaflet-bar, .leaflet-bar a { background: var(--paper-2) !important; color: var(--ink) !important; border-color: var(--ink) !important; }
.leaflet-bar a:hover { background: var(--accent) !important; }

.page-bg {
  position: absolute; inset: -10px -10px 0; pointer-events: none; z-index: 0;
  background-size: cover; background-position: center top;
  opacity: .07; border-radius: 18px;
  mask-image: linear-gradient(#000 30%, transparent 80%);
  -webkit-mask-image: linear-gradient(#000 30%, transparent 80%);
}
html[data-theme="dark"] .page-bg { opacity: .06; mix-blend-mode: luminosity; }
.empire-grid { position: relative; z-index: 1; }
.empire-page-head {
  position: relative; z-index: 1;
  margin: 0 auto 10px; max-width: 860px; padding: 12px 20px; border-radius: 16px;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  border: var(--bw) solid var(--ink); box-shadow: var(--hard-shadow-sm);
}
.geo-setup { max-width: 560px; margin: 0 auto; }

/* global leaderboard */
.global-board { max-width: 640px; margin: 0 auto 26px; }
.global-board .gb-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper-2); box-shadow: 2px 2px 0 var(--shadow-ink); }
.global-board .gb-row + .gb-row { margin-top: 7px; }
.global-board .gb-row.me { background: var(--accent); color: var(--accent-ink); }
.global-board .gb-row.me .fr-meta { color: var(--accent-ink); }
.gb-me-tag { font-size: .56rem; font-weight: 800; letter-spacing: .1em; background: var(--ink); color: var(--paper); padding: 2px 6px; border-radius: 99px; margin-left: 6px; }

/* ---------- Versus (live matches) ---------- */
.versus-card { max-width: 640px; margin: 0 auto; }
.lobby .code-badge {
  font-family: var(--font-display); font-size: 2rem; letter-spacing: .22em;
  background: var(--accent); color: var(--accent-ink);
  border: var(--bw) solid var(--ink); border-radius: 12px; padding: 6px 14px 4px 20px;
  box-shadow: var(--hard-shadow-sm); transform: rotate(-1.5deg);
}
.lobby-status { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .8rem; color: var(--ink-soft); margin: 0; }
.rank { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink-faint); width: 34px; flex: none; }
.friend-row.live { outline: 2.5px solid var(--accent); outline-offset: -1px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 7px; box-shadow: 0 0 0 2px var(--paper-2); animation: pulse 1.4s infinite; }
.live-tag { font-size: .58rem; font-weight: 800; letter-spacing: .12em; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--ink); padding: 2px 7px; border-radius: 99px; margin-left: 8px; }
.podium-medal { font-size: 1.3rem; width: 34px; flex: none; display: inline-flex; }
.podium-medal.gold .ico { width: 20px; height: 20px; color: var(--gold, #d9a621); }
.podium-row.gold { background: color-mix(in srgb, var(--accent) 16%, var(--paper-2)); }

/* in-match stage */
.vs-stage { display: flex; flex-direction: column; background: var(--paper); }
body.in-versus .topbar, body.in-versus .view { display: none; }
body.in-versus .paper-frame { margin: 0; border: none; border-radius: 0; box-shadow: none; min-height: 100vh; }
.vs-board { position: absolute; inset: 64px 14px 14px; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; }
.vs-qzone { width: min(640px, 94vw); }
.vs-qzone .quiz-q { font-family: var(--font-display); font-size: clamp(1.2rem, 3vw, 1.6rem); text-transform: uppercase; letter-spacing: .02em; margin: 0 0 14px; }
.vs-qzone .quiz-flagsvg { transform: none; margin-bottom: 18px; }
.vs-standings {
  position: fixed; right: 14px; top: 64px; width: 250px; max-height: calc(100vh - 90px); overflow-y: auto;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 6px 6px 0 rgba(0,0,0,.4); padding: 12px 14px;
}
.vs-standings .h3 { margin-bottom: 8px; }
.vs-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 11px; border: 2px solid transparent; }
.vs-row + .vs-row { margin-top: 5px; }
.vs-row.me { border-color: var(--ink); background: var(--paper-3); box-shadow: 2px 2px 0 var(--shadow-ink); }
.vs-row .avatar-circle { border: 2px solid var(--ink); }
.vs-row-info { flex: 1; min-width: 0; }
.vs-row-name { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-row-meta { font-size: .66rem; color: var(--ink-faint); font-weight: 700; }
.vs-row-score { font-family: var(--font-display); font-size: 1.05rem; }
.vs-timer { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
/* map stage: Map Master + GeoGuesser share one clickable map */
.vs-map {
  position: absolute; left: 0; right: 300px; top: 58px; bottom: 0;
  border-top: 3px solid var(--ink); background: var(--paper);
}
.vs-map .leaflet-container { background: var(--paper); font-family: var(--font-mono); }
.vs-stage .vs-qzone { width: min(440px, 92vw); }
@media (max-width: 980px) {
  .vs-standings { position: static; width: min(640px, 94vw); margin: 14px auto 0; max-height: none; }
  .vs-board { flex-direction: column; align-items: center; inset: 64px 14px 14px; }
  .vs-map { position: static; width: min(640px, 94vw); height: 46vh; margin: 12px auto 0; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; }
  .vs-stage .vs-qzone { width: min(640px, 94vw); }
}

/* ---------- Map Master ---------- */
body.in-mapgame .topbar { display: none; }
body.in-mapgame .view { display: none; }
body.in-mapgame .paper-frame { margin: 0; border: none; border-radius: 0; box-shadow: none; min-height: 100vh; }
.mapgame-board { position: absolute; inset: 0; }
.mapgame-map { position: absolute; inset: 0; background: var(--paper); }
.mapgame-map .leaflet-container { background: var(--paper); font-family: var(--font-mono); }
.mapgame-country { cursor: pointer; transition: fill-opacity .15s; }
.mapgame-country:hover { fill-opacity: .75; }
.mapgame-panel {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 1100;
  width: min(660px, 94vw); max-height: 52vh; overflow-y: auto;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 7px 7px 0 rgba(0,0,0,.5); padding: 16px 18px 18px;
}
.mapgame-prompt { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: .02em; text-transform: uppercase; margin: 0 0 12px; }
.mapgame-target { display: flex; align-items: center; gap: 14px; }
.mapgame-target img { width: 74px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; box-shadow: 3px 3px 0 var(--shadow-ink); }
.mapgame-target-name { font-family: var(--font-display); font-size: 1.7rem; letter-spacing: .02em; text-transform: uppercase; }
.mapgame-panel .reveal-actions { margin-top: 12px; }
@media (max-width: 640px) { .mapgame-panel { max-height: 58vh; bottom: 10px; } }

/* ---------- Lore / Atlas ---------- */
.atlas-tools { display: flex; gap: 12px; margin: 20px 0; flex-wrap: wrap; }
.atlas-tools .input { flex: 1; min-width: 200px; }
/* masonry: each flag at its true aspect ratio, no letterboxing */
.country-grid { display: block; columns: 170px 5; column-gap: 14px; }
.ccard {
  display: block; width: 100%; break-inside: avoid; margin-bottom: 14px;
  padding: 8px; border-radius: 13px;
  border: 2px solid var(--ink); background: var(--paper-2); box-shadow: 3px 3px 0 var(--shadow-ink);
  cursor: pointer; text-align: left; color: var(--ink);
  transition: transform var(--tr-spring), box-shadow var(--tr-spring);
}
.ccard:hover { transform: translate(-2px, -3px) rotate(-.5deg); box-shadow: 6px 6px 0 var(--shadow-ink); }
.ccard:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--shadow-ink); }
.ccard .cc-photo {
  width: 100%; background: var(--plate);
  border: 2px solid var(--ink); border-radius: 8px; overflow: hidden;
}
.ccard .cc-photo img { width: 100%; height: auto; display: block; }
.ccard .cc-name { color: var(--ink-on-white); font-weight: 700; font-size: .86rem; letter-spacing: .02em; text-transform: uppercase; }
.ccard .cc-meta { font-size: .68rem; color: var(--ink-faint); margin-top: -5px; }

.lore-flag-band { position: relative; padding: 26px 0 0; text-align: center; }
.lore-flag-band img.big { display: inline-block; width: min(340px, 80%); background: #fff; padding: 8px; border-radius: 12px; border: var(--bw) solid var(--ink); box-shadow: var(--hard-shadow); transform: rotate(-.8deg); }
.lore-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 20px 0; }
.lf-box { padding: 10px 12px; border: 2px solid var(--ink); border-radius: 11px; background: var(--paper-2); box-shadow: 2px 2px 0 var(--shadow-ink); }
.lf-box .lf-k { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-faint); }
.lf-box .lf-v { font-weight: 700; font-size: .88rem; margin-top: 3px; line-height: 1.4; }
.lore-section { margin-top: 18px; }
.lore-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 7px; font-family: var(--font-display); font-weight: 400; font-size: .92rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.lore-section h4 .ico { width: 16px; height: 16px; color: var(--ink); background: var(--accent); border: 2px solid var(--ink); padding: 2px; box-shadow: 1.5px 1.5px 0 var(--shadow-ink); }
.lore-section p { margin: 0; line-height: 1.75; color: var(--ink-soft); font-size: .9rem; }
.lore-section p + p { margin-top: 8px; }

.empire-card {
  display: flex; gap: 14px; padding: 15px; border: var(--bw) solid var(--ink); border-radius: 14px;
  background: var(--paper-2); box-shadow: var(--hard-shadow-sm);
  cursor: pointer; text-align: left; color: var(--ink);
  transition: transform var(--tr-spring), box-shadow var(--tr-spring);
}
.empire-card:hover { transform: translate(-2px, -3px); box-shadow: 6px 6px 0 var(--shadow-ink); }
.empire-card .ec-icon {
  width: 58px; height: 58px; display: flex; align-items: center; justify-content: center;
  border: var(--bw) solid var(--ink); border-radius: 16px; flex: none;
  font-family: var(--font-display); font-size: 1.5rem;
  background: var(--ec-color, var(--accent)); color: var(--accent-ink);
  box-shadow: 2px 2px 0 var(--shadow-ink); transform: rotate(-2deg);
}
.empire-card h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; letter-spacing: .03em; text-transform: uppercase; margin: 0; }
.empire-card .ec-years { color: var(--ink-soft); font-size: .74rem; font-weight: 700; letter-spacing: .05em; }
.empire-card p { margin: 4px 0 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empire-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }

.empire-detail .ed-icon {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  border: var(--bw) solid var(--ink); border-radius: 18px; flex: none;
  font-family: var(--font-display); font-size: 1.7rem;
  background: var(--ec-color, var(--accent)); color: var(--accent-ink);
  box-shadow: 3px 3px 0 var(--shadow-ink); transform: rotate(-2deg);
}
.empire-detail .phase { position: relative; padding: 0 0 18px 30px; border-left: 3px solid var(--ink); margin-left: 10px; }
.empire-detail .phase:last-child { border-left-color: transparent; padding-bottom: 4px; }
.empire-detail .phase::before {
  content: ""; position: absolute; left: -9px; top: 2px; width: 12px; height: 12px;
  background: var(--accent); border: 2.5px solid var(--ink); transform: rotate(45deg);
}
.empire-detail .phase h4 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 400; font-size: .92rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
.empire-detail .phase h4 .ico { width: 15px; height: 15px; background: var(--accent); border: 2px solid var(--ink); padding: 2px; }
.empire-detail .phase p { margin: 0; color: var(--ink-soft); line-height: 1.7; font-size: .9rem; }
.modern-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.modern-flags .mf { position: relative; }
.modern-flags img { width: 40px; height: 28px; object-fit: contain; border: 2px solid var(--ink); border-radius: 4px; cursor: pointer; transition: transform var(--tr-fast); background: #fff; padding: 1px; }
.modern-flags img:hover { transform: scale(1.15) rotate(-2deg); }

/* ---------- Friends ---------- */
.friend-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: var(--bw) solid var(--ink); border-radius: 13px; background: var(--paper-2); box-shadow: 3px 3px 0 var(--shadow-ink); }
.friend-row .fr-ava { flex: none; }
.friend-row .fr-ava .avatar-circle { border: 2.5px solid var(--ink); }
.friend-row .fr-name { font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: .9rem; }
.friend-row .fr-meta { font-size: .72rem; color: var(--ink-faint); }
.friend-row .spread { flex: 1; }
.code-box {
  font-family: var(--font-mono); letter-spacing: .32em; font-size: 1.4rem; font-weight: 700;
  text-align: center; padding: 16px; border-radius: 14px;
  border: 2.5px dashed var(--ink); background: var(--paper);
  transform: rotate(-.4deg);
}

/* ---------- Settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 2px dashed var(--ink-faint); }
.set-row:last-child { border-bottom: none; }
.set-row .sr-title { font-weight: 700; }
.set-row .sr-sub { font-size: .76rem; color: var(--ink-faint); margin-top: 2px; max-width: 380px; line-height: 1.55; }

/* ---------- Misc ---------- */
.avatar-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-pick button {
  width: 40px; height: 40px; border: 2.5px solid var(--ink); border-radius: 12px; cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow-ink); transition: transform var(--tr-fast), box-shadow var(--tr-fast);
}
.avatar-pick button:hover { transform: translate(-1px, -1px) rotate(-3deg); box-shadow: 3px 3px 0 var(--shadow-ink); }
.avatar-pick button.on { outline: 3px solid var(--ink); outline-offset: 2px; transform: scale(1.05); }

.empty { text-align: center; padding: 44px 20px; color: var(--ink-faint); }
.empty .e-ico { display: flex; justify-content: center; margin-bottom: 12px; color: var(--ink); }
.empty .e-ico .ico { width: 46px; height: 46px; stroke-width: 1.6; }

.badge-lvl {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink);
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--shadow-ink);
  font-weight: 700; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase;
}

.confetti-canvas { position: fixed; inset: 0; z-index: 3000; pointer-events: none; }

.divider { height: 3px; background: var(--ink); margin: 18px 0; border: none; position: relative; }

.hist-card {
  position: relative; border: var(--bw) solid var(--ink); border-radius: 13px; background: var(--paper-2);
  cursor: pointer; text-align: left; color: var(--ink); padding: 0; width: 100%;
  box-shadow: var(--hard-shadow-sm); overflow: hidden;
  transition: transform var(--tr-spring), box-shadow var(--tr-spring);
}
.hist-card:hover { transform: translate(-2px, -3px) rotate(-.5deg); box-shadow: 6px 6px 0 var(--shadow-ink); }
.hist-card img { width: 100%; aspect-ratio: 3/2; object-fit: contain; background: #fff; display: block; padding: 12px; border-bottom: 2px solid var(--ink); }
.hist-card .hc-body { padding: 12px 14px 14px; }
.hist-card .hc-name { font-weight: 700; font-size: .9rem; text-transform: uppercase; letter-spacing: .02em; }
.hist-card .hc-era { color: var(--ink-faint); font-size: .72rem; font-weight: 700; letter-spacing: .05em; }
.hist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 15px; }

.skel { border: 2px solid var(--ink); border-radius: 10px; background: repeating-linear-gradient(-45deg, var(--paper-3) 0 10px, var(--paper-2) 10px 20px); animation: none; }

.daily-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 13px;
  background: var(--paper-2); color: var(--ink);
  border: var(--bw) solid var(--ink); box-shadow: var(--hard-shadow-sm);
  font-weight: 700; font-size: .85rem; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer; transition: transform var(--tr-fast), box-shadow var(--tr-fast);
}
.daily-chip:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shadow-ink); }
.daily-chip:disabled { filter: grayscale(1); cursor: default; transform: none; }
.daily-chip .ico { width: 16px; height: 16px; }

/* rotating stamp on setup screens */
.game-head { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 8px; }
.game-head .gh-icon {
  display: flex; align-items: center; justify-content: center;
  width: 66px; height: 66px; border-radius: 19px;
  border: var(--bw) solid var(--ink); background: var(--paper); color: var(--ink);
  box-shadow: var(--hard-shadow-sm); transform: rotate(-2deg);
  animation: ghPop .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.game-head .gh-icon .ico { width: 30px; height: 30px; }
@keyframes ghPop { from { opacity: 0; transform: scale(.6) rotate(-14deg); } }

/* postmark (lore) */
.postmark {
  position: absolute; top: 8px; right: 14px;
  width: 92px; height: 92px; border: 2.5px dashed var(--ink); border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  color: var(--ink); opacity: .75; transform: rotate(8deg);
  font-size: .58rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; line-height: 1.5;
}

/* monogram avatars */
.avatar-circle {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--accent-ink); font-weight: 700;
  background: var(--av-color, var(--accent)); flex: none; user-select: none;
  letter-spacing: 0;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .paper-frame { margin: 6px; border-radius: 20px; min-height: calc(100vh - 12px); }
  .bg-orbs { border-radius: 17px; }
  .orb-1 { width: 280px; height: 260px; top: -120px; left: -100px; }
  .orb-2 { width: 240px; height: 250px; top: 20%; right: -100px; }
  .orb-3 { width: 260px; height: 230px; bottom: -100px; left: 15%; }

  .topbar { padding: 0 10px; gap: 8px; height: 54px; }
  .brand-globe { width: 24px; height: 24px; }
  .brand-name { font-size: 1.05rem; }
  .iconbtn { height: 34px; min-width: 34px; border-radius: 10px; }
  .iconbtn .ico { width: 15px; height: 15px; }
  .iconbtn.labeled { padding: 0 8px; gap: 5px; }
  .iconbtn .btn-label { font-size: .62rem; }
  .chip { height: 34px; padding: 0 9px; font-size: .74rem; }

  .view { padding: 16px 12px 50px; }
  .h1 { font-size: clamp(1.6rem, 7vw, 2.4rem); }
  .h2 { font-size: clamp(1.2rem, 5vw, 1.6rem); }
  .sub { font-size: .84rem; }

  .card { border-radius: 12px; }
  .card.pad { padding: 16px; }
  .quiz-card { padding: 14px; }
  .modal { max-width: 96vw; }
  .modal-body { padding: 14px; }
  .modal-head { padding: 12px 14px; }

  .hero { padding: 20px 0 8px; }
  .hero-cta { flex-direction: column; align-items: stretch; gap: 8px; }
  .hero-cta .btn { width: 100%; }
  .hero-poster { width: min(280px, 85%); }
  .mode-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 20px; }
  .mode-card { padding: 14px 14px 12px; }
  .mode-card .mc-index { font-size: 1.8rem; top: 6px; right: 10px; }
  .mode-card .mc-icon { width: 38px; height: 38px; margin-bottom: 8px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 20px; }
  .stat-box { padding: 10px; }

  .choices { grid-template-columns: 1fr; gap: 8px; }
  .choice { padding: 10px 12px; font-size: .88rem; }
  .quiz-flagsvg { width: min(300px, 90%); }
  .quiz-q { font-size: 1.05rem; }

  .geo-setup { padding: 0 4px; }
  .seg { flex-wrap: wrap; }
  .seg button { padding: 7px 10px; font-size: .76rem; }

  .atlas-tools { flex-direction: column; }
  .country-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .ccard { padding: 8px; }
  .ccard .cc-name { font-size: .78rem; }

  .empire-grid { grid-template-columns: 1fr; }
  .empire-card { padding: 12px; }
  .empire-detail .ed-icon { width: 48px; height: 48px; font-size: 1.3rem; }

  .friend-row { padding: 10px 10px; }
  .code-box { font-size: 1.1rem; letter-spacing: .2em; padding: 12px; }

  .notif-panel { width: min(300px, calc(100vw - 20px)); top: 60px; right: 8px; }
  .fb-drop { width: min(260px, calc(100vw - 20px)); top: 60px; right: 8px; }
  .lb-panel { width: min(290px, calc(100vw - 20px)); top: 8px; bottom: 8px; right: 8px; }

  .input { padding: 10px 12px; font-size: .88rem; }
  .btn { padding: 10px 16px; font-size: .85rem; }
  .btn.big { padding: 12px 20px; font-size: .92rem; }
  .btn.small { padding: 7px 10px; font-size: .74rem; }

  .stamp-hit { font-size: .82rem; padding: 5px 10px; }
  .result-squares .sq { width: 16px; height: 16px; }
  .recap-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }

  .invite-banner { width: min(360px, calc(100vw - 16px)); top: 8px; flex-wrap: wrap; padding: 12px 14px; }
  .invite-banner .ib-btns { width: 100%; }
}

@media (max-width: 420px) {
  .iconbtn.labeled { padding: 0 6px; }
  .iconbtn .btn-label { display: none; }
  .iconbtn.labeled { width: 34px; min-width: 34px; padding: 0; justify-content: center; }
  .brand-name { font-size: .95rem; }
  .topbar { gap: 6px; padding: 0 8px; }
  .drawer { width: min(260px, calc(100vw - 40px)); }
  .lb-panel { width: min(260px, calc(100vw - 24px)); }
  .notif-panel { width: min(280px, calc(100vw - 16px)); }
  .fb-drop { width: min(240px, calc(100vw - 16px)); }
  .mode-card h3 { font-size: 1.05rem; }
  .hero .h1 { font-size: clamp(2rem, 10vw, 3rem); }
  .hero-mascot { width: 90px !important; }
  .circle-stamp { width: 90px !important; height: 90px !important; }
}

@media print { .topbar, .bg-orbs { display: none; } }
