/* ==========================================================================
   Katanittes pixel UI theme — Forager-like chunky pixels + Octopath gold frames.
   Palette: Sweetie-16. Loaded after style.css and overrides its look.
   ========================================================================== */
:root {
  --ink: #1a1c2c; --plum: #5d275d; --wine: #b13e53; --coral: #ef7d57; --sand: #ffcd75; --lime: #a7f070;
  --green: #38b764; --teal: #257179; --navy: #29366f; --blue: #3b5dc9; --sky: #41a6f6; --cyan: #73eff7;
  --white: #f4f4f4; --steel: #94b0c2; --slate: #566c86; --dusk: #333c57;
  --gold: var(--sand); --pink: var(--coral); --red: var(--wine); --text: var(--white); --muted: var(--steel);
  --panel: #232b47; --panel2: #333c57; --line: rgba(148,176,194,.25);
  --font: 'Pixelify Sans', 'Nunito', monospace; --display: 'Silkscreen', 'Pixelify Sans', monospace; --num: 'Silkscreen', monospace;
  --px: 3px;
}
* { border-radius: 0 !important; }
html { image-rendering: pixelated; }
body {
  font-family: var(--font); font-weight: 500; font-size: 16px; letter-spacing: .3px;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='8' height='8' fill='%231a1c2c'/%3E%3Crect width='1' height='1' fill='%23232b47'/%3E%3C/svg%3E") repeat;
  -webkit-font-smoothing: none; font-smooth: never;
}
img.px { image-rendering: pixelated; vertical-align: -0.2em; display: inline-block; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 1px; }

/* ---------- jitter (hand-drawn boil) ---------- */
.jl { display: inline-block; animation: jit .48s steps(1) infinite; }
@keyframes jit {
  0% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px) rotate(1.5deg); }
  50% { transform: translate(-1px, 0) rotate(-1deg); } 75% { transform: translate(0, 1px) rotate(.5deg); }
}
.btn:hover .jl, .jit.hot .jl { animation-duration: .24s; }

/* ---------- frames ---------- */
.card, .modal, .pcard, .offer, .toast, .banner, .event-badge, .pill, .map-card, .mode, .stepper, .player-row .swatch {
  border: 0 !important;
}
.card, .modal {
  background: linear-gradient(180deg, #2b3563 0%, #1f2542 100%);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), 0 0 0 9px var(--ink), 0 0 0 12px var(--Y, #b8862f), 10px 14px 0 8px rgba(0,0,0,.35);
  margin: 12px 12px 26px;
}
.card h3, .modal h2 { color: var(--sand); text-shadow: 3px 3px 0 var(--ink); }
.modal { padding: 22px; }
.overlay { background: rgba(10,12,24,.72); backdrop-filter: none; }
/* each card casts a hard shadow in its player's colour, so card ↔ pieces on the board match at a glance */
.pcard { background: var(--dusk); box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 3px var(--pc), inset 5px 0 0 var(--pc), inset 0 -4px 0 rgba(0,0,0,.25); margin: 3px 10px 10px 3px; }
.pcard.current { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--pc), 6px 6px 0 6px var(--pc), 0 0 18px 6px color-mix(in srgb, var(--pc) 55%, transparent), inset 5px 0 0 var(--pc), inset 0 -4px 0 rgba(0,0,0,.25); }
.pcard .avatar { box-shadow: 0 0 0 3px var(--ink); }
.pcard .vp { font-size: 26px; color: var(--sand); text-shadow: 2px 2px 0 var(--ink); }
.pill, .tag { background: var(--dusk); box-shadow: 0 0 0 2px var(--ink); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font); font-weight: 600; font-size: 16px; letter-spacing: .5px;
  background: var(--blue); color: var(--white); border: 0;
  box-shadow: 0 0 0 3px var(--ink), inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.28);
  padding: 10px 16px; margin: 3px; text-shadow: 2px 2px 0 rgba(0,0,0,.4);
  transition: none;
}
.btn:hover:not(:disabled) { background: var(--sky); transform: translate(0, -2px); }
.btn:active:not(:disabled) { transform: translate(0, 2px); box-shadow: 0 0 0 3px var(--ink), inset 4px 4px 0 rgba(0,0,0,.35); }
.btn:disabled { background: var(--slate); opacity: .55; }
.btn.primary { background: var(--sand); color: var(--ink); text-shadow: none; box-shadow: 0 0 0 3px var(--ink), inset -4px -4px 0 #c98f3a, inset 4px 4px 0 #fff2c8, 0 6px 0 3px var(--ink); }
.btn.primary:hover:not(:disabled) { background: #ffe0a0; }
.btn.pink { background: var(--wine); box-shadow: 0 0 0 3px var(--ink), inset -4px -4px 0 #6d1f33, inset 4px 4px 0 #e5708a, 0 6px 0 3px var(--ink); }
.btn.pink:hover:not(:disabled) { background: #cc5068; }
.btn.green { background: var(--green); color: var(--ink); text-shadow: none; box-shadow: 0 0 0 3px var(--ink), inset -4px -4px 0 #237a46, inset 4px 4px 0 var(--lime), 0 6px 0 3px var(--ink); }
.btn.green:hover:not(:disabled) { background: #4fd07c; }
.btn.ghost { background: var(--dusk); }
.btn.active { outline: 0; box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), inset -4px -4px 0 rgba(0,0,0,.35); animation: activeBlink 2.4s ease-in-out infinite; }
@keyframes activeBlink { 50% { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px #fff1c4, inset -4px -4px 0 rgba(0,0,0,.35); } }
.btn.big { font-size: 22px; padding: 14px 26px; }
.chip { font-family: var(--font); background: var(--dusk); border: 0; box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 rgba(0,0,0,.3); margin: 3px; }
.chip.on { background: var(--sand); color: var(--ink); }
input[type=text], select, textarea { font-family: var(--font); font-size: 16px; background: var(--ink); border: 0; box-shadow: inset 0 0 0 3px var(--slate); color: var(--white); }
input[type=range] { accent-color: var(--sand); }
.switch { background: var(--slate); box-shadow: 0 0 0 3px var(--ink); }
.switch::after { background: var(--white); }
.on > .switch, .switch.on { background: var(--coral); }

/* ---------- menu ---------- */
.menu-bg3d { position: absolute; inset: 0; }
.menu-bg3d::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(26,28,44,.15) 0%, rgba(26,28,44,.75) 70%); pointer-events: none; }
.menu-bg3d .board-3d { width: 100%; height: 100%; }
.logo .t1 { font-family: var(--display); font-size: clamp(64px, 13vw, 140px); letter-spacing: 6px; background: none; color: var(--sand); -webkit-background-clip: initial; background-clip: initial; filter: none;
  text-shadow: 0 6px 0 var(--coral), 0 12px 0 var(--ink); }
.logo .x { font-family: var(--display); color: var(--cyan); text-shadow: 4px 4px 0 var(--ink); transform: none; }
.logo .t2 { font-family: var(--display); font-size: clamp(40px, 8vw, 86px); color: var(--white); text-shadow: 0 5px 0 var(--wine), 0 10px 0 var(--ink); letter-spacing: 6px; }
.logo .sub { color: var(--white); text-shadow: 3px 3px 0 var(--ink); font-size: 18px; }
.menu-buttons .btn { font-size: 20px; }
.menu-kingdom { position: relative; width: min(360px, 100%); display: flex; gap: 10px; align-items: center; margin: 0 0 18px; padding: 8px 10px 8px 6px;
  background: linear-gradient(180deg, #2b3563 0%, #1f2542 100%); box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), 0 0 0 9px var(--ink), 8px 10px 0 6px rgba(0,0,0,.35); }
.menu-kingdom .mk-flag { border: 0; background: none; padding: 0; cursor: pointer; width: 70px; height: 56px; }
.menu-kingdom .mk-info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.menu-kingdom .section-label { margin: 0; display: flex; gap: 6px; align-items: center; color: var(--sand); }
.menu-kingdom .section-label .swatch { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--ink); }
.menu-kingdom .hub-name { width: 100%; font-size: 18px !important; padding: 7px 10px !important; }
.menu-kingdom .btn.sm { font-size: 20px; padding: 8px 10px; }
.menu-foot { color: var(--steel); text-shadow: 2px 2px 0 var(--ink); }
/* language picker, top right of the menu */
.lang-pick { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 8px; background: var(--panel); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--panel2), 4px 4px 0 5px rgba(0,0,0,.4); cursor: pointer; }
.lang-pick img.px { width: 20px; height: 20px; }
.lang-pick select { font-family: var(--display); font-size: 14px; color: var(--white); background: var(--ink); border: 0; padding: 4px 6px; cursor: pointer; }
.lang-pick select:focus-visible { outline: 3px solid var(--sand); }
.menu-foot .credits { margin-top: 6px; font-size: 12px; }
.menu-foot a, .help-body a { color: var(--sand); }

/* ---------- game ---------- */
.topbar { background: var(--ink); border-bottom: 0; box-shadow: 0 3px 0 var(--sand), 0 6px 0 var(--ink); z-index: 6; }
.brand { font-family: var(--display); color: var(--sand); text-shadow: 3px 3px 0 var(--wine); font-size: 22px; }
.brand i { color: var(--white); }
.turn-dot { box-shadow: 0 0 0 3px var(--ink); }
.side { background: #1f2440; border-left: 0; box-shadow: inset 3px 0 0 var(--sand), inset 6px 0 0 var(--ink); padding-left: 6px; }
.log { border-top: 0; box-shadow: inset 0 3px 0 var(--ink); font-size: 14px; }
.log div { border-bottom: 1px dotted rgba(148,176,194,.18); }
.actionbar { background: var(--ink); border-top: 0; box-shadow: 0 -3px 0 var(--sand), 0 -6px 0 var(--ink); }
.banner { background: var(--ink); color: var(--white); box-shadow: 0 0 0 3px var(--sand), 0 0 0 6px var(--ink), 6px 8px 0 4px rgba(0,0,0,.4); font-size: 17px; padding: 8px 18px; }
.event-badge { background: var(--plum); box-shadow: 0 0 0 3px var(--ink); color: var(--white); }
.die { background: var(--white); box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 var(--steel); padding: 6px; }
.die.red-die { background: #ffd3d3; }
.die i { width: 5px; height: 5px; background: var(--ink); }
.dice-sum { font-size: 26px; color: var(--sand); text-shadow: 3px 3px 0 var(--ink); }
.dice-sum.seven { color: var(--coral); }
.rcard { border: 0; box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 rgba(0,0,0,.3), inset 3px 3px 0 rgba(255,255,255,.3); margin: 3px; width: 50px; height: 66px; }
.rcard img.px { width: 30px; height: 30px; }
.rcard b { background: var(--ink); font-size: 15px; }
.dcard { border: 0; background: var(--plum); box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 #9b4d9b; margin: 3px; }
.dcard.playable { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand); animation: activeBlink 2.4s ease-in-out infinite; }
.offer { background: #1f2542; box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), 0 0 0 9px var(--ink), 8px 10px 0 6px rgba(0,0,0,.4); }
.toast { background: var(--ink); box-shadow: 0 0 0 3px var(--steel), 0 0 0 6px var(--ink); }
.toast.error { background: #3a1422; box-shadow: 0 0 0 3px var(--wine), 0 0 0 6px var(--ink); }
.toast.good { background: #10301f; box-shadow: 0 0 0 3px var(--green), 0 0 0 6px var(--ink); }
.announce > div { background: var(--ink); border: 0; box-shadow: 0 0 0 4px var(--sand), 0 0 0 8px var(--ink), 0 0 0 12px var(--coral), 0 0 60px rgba(255,205,117,.35); }
.announce .at { font-family: var(--display); color: var(--sand); text-shadow: 4px 4px 0 var(--wine); font-size: 40px; }
.announce .ai img.px { width: 72px; height: 72px; }
.pass-screen { background: var(--ink); }
.pass-screen .big { text-shadow: 5px 5px 0 var(--ink), 8px 8px 0 rgba(0,0,0,.4); }
.pass-screen .eye img.px { width: 96px; height: 96px; }
.hist div { background: var(--sand); box-shadow: inset -3px 0 0 #c98f3a; }
.hist div.s { background: var(--coral); box-shadow: inset -3px 0 0 var(--wine); }
.stepper { background: var(--ink); box-shadow: inset 0 0 0 3px var(--dusk); }
.map-card { background: var(--ink); box-shadow: 0 0 0 3px var(--dusk); margin: 3px; }
.map-card.on { background: #2b2a1c; box-shadow: 0 0 0 3px var(--sand); }
.mode { background: var(--ink); box-shadow: 0 0 0 3px var(--dusk); margin: 3px; }
.mode.on { background: #2e1d2c; box-shadow: 0 0 0 3px var(--coral); }
.mode.flag { box-shadow: 0 0 0 3px var(--sand), 0 0 0 6px var(--ink); }
.mode .flagship { color: var(--sand); font-size: 12px; }
.start-bar { background: var(--ink); border-top: 0; box-shadow: 0 -3px 0 var(--sand); backdrop-filter: none; }
.room-code { font-family: var(--display); color: var(--sand); background: var(--ink); box-shadow: 0 0 0 3px var(--sand); text-shadow: 4px 4px 0 var(--wine); }
.zoom-ctrl .btn { width: 42px; height: 42px; }
.confetti { width: 8px; height: 8px; }

/* ---------- 3D pixel labels ---------- */
.labels-3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* even, fixed size + 16px Silkscreen (its native grid) + whole-pixel positions = crisp digits */
.tok3d { font-family: var(--num); background: #f7ecd0; color: var(--ink); width: 40px; height: 40px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 #d7c49b, 4px 5px 0 1px rgba(0,0,0,.35); font-weight: 400; font-size: 16px; line-height: 16px; padding-top: 2px; text-align: center; -webkit-font-smoothing: none; }
.tok3d span { display: block; height: 16px; }
/* --tk (set by the 3D view) shrinks tokens and port signs as you zoom out, so they never cover the tiles */
.tok3d, .port3d { scale: var(--tk, 1); }
/* probability bar: one segment per classic Catan pip, centred, thicker and darker (then red) the likelier the number */
.tok3d .pbar { display: flex; justify-content: center; align-items: center; gap: 2px; height: 6px; }
.tok3d .pbar b { display: block; width: 4px; box-shadow: 0 0 0 1px rgba(26,28,44,.6); }
.tok3d.red { color: var(--wine); }
/* winning number: soft green blink for ~2.6s. Only background/box-shadow/translate are animated:
   `transform` belongs to CSS2DRenderer (animating it made the tokens jump around the screen). */
.tok3d.rolled { animation: tokWin .65s ease-in-out 4; }
@keyframes tokWin { 50% { background: #7ee2a0; translate: 0 -3px; box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--green), inset -3px -3px 0 #3fae68, 4px 5px 0 1px rgba(0,0,0,.35); } }
.port3d { font-family: var(--num); background: var(--white); color: var(--ink); padding: 2px 6px; font-size: 14px; font-weight: 700; box-shadow: 0 0 0 3px var(--ink), 3px 4px 0 1px rgba(0,0,0,.35); display: flex; gap: 3px; align-items: center; }
.rune3d { font-size: 26px; color: #f3d9a4; text-shadow: 2px 2px 0 var(--ink); }
/* build hints: soft yellow with a slow breathing glow (no hard blinking). No `transform` here either. */
.hot3d { pointer-events: auto; border: 0; cursor: pointer; background: #ffe7a3; padding: 0; opacity: .85;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 4px rgba(255,231,163,.45); animation: hotBreath 2.4s ease-in-out infinite; }
.hot3d.v { width: 16px; height: 16px; }
.hot3d.e { width: 22px; height: 10px; }
.hot3d.t { width: 30px; height: 30px; display: grid; place-items: center; }
.hot3d.t::after { content: '✖'; color: var(--ink); font-size: 15px; }
.hot3d:hover { animation: none; opacity: 1; background: #fff4cf; box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px #ffe7a3; }
@keyframes hotBreath { 50% { opacity: 1; box-shadow: 0 0 0 3px var(--ink), 0 0 0 9px rgba(255,231,163,.2); } }
.board-wrap { background: var(--ink); }
.board-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--sand); font-family: var(--display); font-size: 20px; text-shadow: 3px 3px 0 var(--wine); pointer-events: none; }
.gfx-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* numbers must be unambiguous (3 vs 8): Silkscreen digits */
.vp, .dice-sum, .rcard b, .dcard b, .stepper .n, .token-num, .pcard .stats, .bank-info, .room-code, .hist em, .hist span { font-family: var(--num); }
.pcard .name, .btn, .chip, .banner { font-weight: 600; }
.logo .t1, .logo .t2, .brand, .card h3, .modal h2, .announce .at { font-family: var(--display); font-weight: 700; }
/* one word, two colours: KATAN in sand, ITTES in white */
.logo .t1 { font-size: clamp(30px, 8.6vw, 112px); letter-spacing: 4px; white-space: nowrap; }
.logo .t1b { color: var(--white); text-shadow: 0 6px 0 var(--wine), 0 12px 0 var(--ink); }
.logo .sub { margin-top: 18px; }

/* ---------- kingdom flag editor ---------- */
.flag-modal { width: min(760px, 100%); }
.flag-layout { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) { .flag-layout { grid-template-columns: 1fr; } }
.flag-grid { display: grid; grid-template-columns: repeat(12, 26px); grid-template-rows: repeat(12, 26px); box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand); width: max-content; touch-action: none; cursor: crosshair; margin: 8px 6px 14px; }
@media (max-width: 480px) { .flag-grid { grid-template-columns: repeat(12, 22px); grid-template-rows: repeat(12, 22px); } }
.flag-grid .fc { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.flag-grid .fc:hover { box-shadow: inset 0 0 0 2px #fff; }
.flag-pal { display: grid; grid-template-columns: repeat(8, 30px); gap: 6px; margin: 6px 4px 10px; }
.sw { width: 30px; height: 30px; border: 0; cursor: pointer; box-shadow: 0 0 0 2px var(--ink); padding: 0; }
.sw.on { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand); transform: translateY(-2px); }
.sw.big { width: 28px; height: 28px; margin: 3px; }
.castle-color { width: 44px !important; height: 34px; padding: 0 !important; margin: 3px; cursor: pointer; }
.flag-preview { background: var(--ink); box-shadow: inset 0 0 0 3px var(--dusk); display: grid; place-items: center; padding: 14px; }
img.flag-img { image-rendering: pixelated; box-shadow: 0 0 0 2px var(--ink); background: var(--ink); vertical-align: middle; }
.flag-btn { padding: 0 !important; width: 40px; height: 36px; display: grid; place-items: center; }
.pcard .avatar img.flag-img { width: 30px; height: 30px; box-shadow: none; }
.players.compact .pcard { padding: 5px 8px; }
.players.compact .pcard .stats { margin-top: 2px; gap: 7px; font-size: 11.5px; }
.players.compact .pcard .avatar, .players.compact .pcard .avatar img.flag-img { width: 24px; height: 24px; }
.players.compact .pcard .vp { font-size: 20px; }
.pcard.retired { opacity: .45; filter: grayscale(.8); }
.pcard .conn { font-size: 11px; font-weight: 700; margin-left: 4px; }
.pcard .conn.off { color: var(--coral); animation: blink 1s steps(2) infinite; }
.player-row { grid-template-columns: 36px 40px minmax(0, 1fr) 150px 36px; }

.kingdom-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.board-wrap .labels-3d { z-index: 1; }
.board-wrap .banner, .board-wrap .zoom-ctrl, .board-wrap .offer { z-index: 6; }

/* ---------- Gartic-like paint editor ---------- */
.flag-modal { width: min(820px, 100%); }
.paint { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; margin-top: 6px; }
.paint-tools { display: grid; gap: 6px; }
.ptool { width: 46px; height: 46px; border: 0; background: var(--dusk); font-size: 22px; cursor: pointer; box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 rgba(0,0,0,.3); }
.ptool.on { background: var(--sand); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--coral); }
.ptool:disabled { opacity: .35; cursor: default; }
.psep { height: 6px; width: 6px; }
.paint-stage { position: relative; aspect-ratio: 3 / 2; width: 100%; max-width: 480px; box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), 8px 10px 0 5px rgba(0,0,0,.35); background: #fff; justify-self: center; }
.paint-canvas, .paint-ghost { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.paint-ghost { pointer-events: none; }
.paint-pal { display: grid; gap: 8px; justify-items: center; }
.pcur { width: 46px; height: 46px; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px #fff; }
.pgrid { display: grid; grid-template-columns: repeat(2, 24px); gap: 5px; }
.pcol { width: 24px; height: 24px; border: 0; cursor: pointer; box-shadow: 0 0 0 2px var(--ink); padding: 0; }
.pcol.on { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #fff; transform: scale(1.12); }
.paint-custom { width: 46px !important; height: 30px; padding: 0 !important; cursor: pointer; }
.paint-sizes { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0 6px; flex-wrap: wrap; }
.psize { width: 44px; height: 44px; border: 0; background: var(--dusk); display: grid; place-items: center; cursor: pointer; box-shadow: 0 0 0 3px var(--ink); }
.psize.on { background: #4a5680; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--sand); }
.psize i { display: block; border-radius: 50% !important; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.flag-bottom { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; margin-top: 8px; }
@media (max-width: 700px) {
  .paint { grid-template-columns: 1fr; }
  .paint-tools { grid-auto-flow: column; justify-content: center; }
  .pgrid { grid-template-columns: repeat(10, 24px); }
  .paint-pal { grid-auto-flow: column; }
  .flag-bottom { grid-template-columns: 1fr; }
}
img.flag-img.pixel { image-rendering: pixelated; }
img.flag-img:not(.pixel) { image-rendering: auto; }
.pcard .avatar { width: auto !important; min-width: 30px; }
.pcard .avatar img.flag-img { width: 36px; height: 24px; }
.players.compact .pcard .avatar img.flag-img { width: 30px; height: 20px; }

/* ================= online hub ================= */
.online-hub { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; }
.online-hub .menu-bg3d::after { background: radial-gradient(ellipse at center, rgba(26,28,44,.55) 0%, rgba(26,28,44,.88) 75%); }
.hub-inner { position: relative; max-width: 1180px; margin: 0 auto; padding: 18px 16px 30px; }
.hub-head { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.hub-head h2 { font-size: clamp(24px, 4vw, 40px); color: var(--sand); text-shadow: 0 4px 0 var(--wine), 0 8px 0 var(--ink); }
.hub-sub { color: var(--steel); font-size: 15px; margin-top: 6px; text-shadow: 2px 2px 0 var(--ink); }
.hub-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 6px; align-items: stretch; }
@media (max-width: 1000px) { .hub-grid { grid-template-columns: 1fr 1fr; } .kingdom-card { grid-column: 1 / -1; } }
@media (max-width: 680px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-card { display: flex; flex-direction: column; gap: 10px; }
.hub-card p { color: var(--steel); margin: 0; line-height: 1.4; }
.hub-card > .btn.big { margin-top: auto; }
.kingdom-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.kingdom-info { flex: 1; min-width: 160px; display: grid; gap: 6px; }
.hub-name { font-size: 20px !important; padding: 10px 12px !important; }
.castle-line { display: flex; gap: 10px; align-items: center; color: var(--steel); }
.castle-line .swatch { width: 24px; height: 24px; box-shadow: 0 0 0 3px var(--ink); }
.hub-flag { position: relative; width: 130px; height: 120px; flex: none; }
.hub-flag .pole { position: absolute; left: 10px; top: 0; bottom: 0; width: 6px; background: #6b4a2f; box-shadow: 0 0 0 2px var(--ink); }
.hub-flag .pole::before { content: ""; position: absolute; left: -4px; top: -8px; width: 14px; height: 14px; background: var(--sand); box-shadow: 0 0 0 2px var(--ink); border-radius: 50% !important; }
.hub-flag img { position: absolute; left: 16px; top: 8px; }
.hub-flag.small { width: 76px; height: 64px; }
.hub-flag.small .pole { left: 6px; width: 4px; }
.hub-flag.small img { left: 10px; top: 4px; }
img.flag-img.wave { animation: flagWave 1.2s steps(4) infinite; transform-origin: left center; }
@keyframes flagWave { 0%,100% { transform: skewY(0deg) scaleX(1); } 25% { transform: skewY(2deg) scaleX(.97); } 50% { transform: skewY(0deg) scaleX(1); } 75% { transform: skewY(-2deg) scaleX(.98); } }
.cap-row { display: flex; gap: 6px; flex-wrap: wrap; }
.cap { width: 40px; height: 40px; border: 0; background: var(--dusk); color: var(--white); font-family: var(--num); font-size: 18px; cursor: pointer; box-shadow: 0 0 0 3px var(--ink), inset -3px -3px 0 rgba(0,0,0,.3); }
.cap:hover { background: #4a5680; }
.cap.on { background: var(--sand); color: var(--ink); box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--coral); }
.cap-people { display: flex; gap: 4px; flex-wrap: wrap; min-height: 26px; }
.cap-people span { font-size: 20px; }
.pins { display: flex; gap: 8px; justify-content: center; }
.pin { width: 52px !important; height: 62px; text-align: center; font-family: var(--num) !important; font-size: 30px !important; text-transform: uppercase; color: var(--sand) !important; box-shadow: inset 0 0 0 3px var(--slate), 0 4px 0 var(--ink) !important; padding: 0 !important; }
.pin:focus { outline: none; box-shadow: inset 0 0 0 3px var(--sand), 0 0 0 3px var(--coral) !important; }
@media (max-width: 420px) { .pin { width: 44px !important; height: 54px; font-size: 24px !important; } }
.hub-status { min-height: 28px; text-align: center; font-weight: 600; margin-top: 4px; text-shadow: 2px 2px 0 var(--ink); }
.hub-tips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.hub-tips span { background: rgba(26,28,44,.85); padding: 6px 12px; box-shadow: 0 0 0 2px var(--dusk); color: var(--steel); font-size: 14px; }
/* waiting room (guest) */
.waiting-card { max-width: 820px; margin: 10px auto 0; }
.waiting-msg { color: var(--sand) !important; font-size: 18px; }
.room-code.inline { display: inline-block; font-size: 26px; letter-spacing: 6px; padding: 2px 12px; margin: 0 8px; }
.room-state { font-family: var(--font); font-size: 13px; padding: 3px 8px; margin-left: 6px; vertical-align: middle; box-shadow: 0 0 0 2px var(--ink); }
.room-state.on { background: #10301f; color: var(--lime); }
.room-state.off { background: #3a1422; color: var(--coral); }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.seat { background: var(--ink); box-shadow: 0 0 0 3px var(--dusk); padding: 10px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.seat.host { box-shadow: 0 0 0 3px var(--sand); }
.seat.me { box-shadow: 0 0 0 3px var(--cyan); }
.seat small { color: var(--steel); }
.seat.empty { opacity: .55; }
.seat-q { width: 60px; height: 60px; display: grid; place-items: center; font-family: var(--num); font-size: 30px; color: var(--slate); }
/* host room card */
.room-card .room-code { font-size: 46px; }
.room-share { justify-content: center; }
.room-toggles { margin-top: 4px; }
.guest-list { display: grid; gap: 6px; }
.guest { display: flex; gap: 10px; align-items: center; background: var(--ink); padding: 6px 10px; box-shadow: 0 0 0 2px var(--dusk); }
.guest b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest.host { box-shadow: 0 0 0 2px var(--sand); }
.guest.empty { color: var(--steel); font-size: 14px; opacity: .8; }
.guest .kick { padding: 2px 8px !important; }
.close-room { margin-top: 12px; align-self: flex-start; }
.seat-name { background: var(--ink); box-shadow: inset 0 0 0 3px var(--dusk); padding: 9px 10px; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-name.taken { color: var(--lime); box-shadow: inset 0 0 0 3px #1d5a38; }

/* ================= design audit fixes ================= */
/* modals never overflow the screen (the gold frame is drawn outside the box) */
.modal { width: min(560px, calc(100vw - 40px)); margin: 12px; }
.flag-modal { width: min(820px, calc(100vw - 40px)); }
@media (max-width: 600px) {
  .card { margin: 10px 10px 22px; padding: 12px; }
  .modal { padding: 16px; max-height: 88vh; }
  .modal h2 { font-size: 20px; }
  /* player rows: the name keeps its space, the selector goes below */
  .player-row { grid-template-columns: 36px 40px minmax(0, 1fr) 36px; }
  .player-row > select, .player-row > .pill { grid-column: 1 / -1; }
  .lobby-head h2 { font-size: 22px; }
  /* action bar: compact buttons, no cost line */
  .actions .btn { padding: 7px 9px; font-size: 13px; margin: 2px; }
  .actions .btn .cost { display: none; }
  .actionbar { gap: 6px; }
  .hand .rcard { width: 38px; height: 50px; }
}
/* lobby modes: wider cards, flagship ones take two columns */
.modes { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (min-width: 760px) { .mode.flag { grid-column: span 2; } }
.mode small { font-size: 13px; line-height: 1.35; }
.mode b { font-size: 15px; margin-bottom: 3px; }
/* map editor polish */
.editor-side { background: linear-gradient(180deg, #232b47, #1a1c2c); box-shadow: inset -3px 0 0 var(--sand), inset -6px 0 0 var(--ink); }
.editor .board-wrap { background: radial-gradient(ellipse at center, #1f4f6e 0%, #122b40 60%, #0b1624 100%); }
.slot { fill: rgba(255,255,255,.035); stroke: rgba(148,176,194,.25); }
.brush { box-shadow: 0 0 0 2px var(--ink); background: var(--dusk); border: 0; }
.brush.on { background: #4a5680; box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--sand); }
/* help: easier reading */
.help-body li { line-height: 1.45; margin-bottom: 6px; }
.help-body h3 { margin-top: 18px; }
.jw { display: inline-block; white-space: nowrap; }
.waiting-card h3, .room-card h3 { flex-wrap: wrap; row-gap: 8px; }
.room-card .room-code { margin-bottom: 14px; }
.player-row select { text-overflow: ellipsis; }
@media (max-width: 600px) {
  .player-row > select, .player-row > .pill { order: 10; }
  .modal .btn { white-space: normal; text-align: center; line-height: 1.25; }
  .hub-head { flex-wrap: wrap; }
}

/* ---------- out of turn: what your hand already pays for ---------- */
.afford { display: flex; gap: 6px; flex-wrap: wrap; }
.afford-item { position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); color: var(--slate); box-shadow: 0 0 0 3px var(--ink); margin: 3px; font-weight: 600; font-size: 14px; opacity: .55; }
.afford-item .cost { opacity: .8; }
.afford-item.half { opacity: .8; color: var(--steel); }
.afford-item.ok { opacity: 1; color: var(--white); background: #1f4a3a; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--green); animation: affordGlow 1.6s steps(4) infinite; }
.afford-item .tick { position: absolute; top: -9px; right: -7px; background: var(--green); color: var(--ink); font-size: 11px; padding: 0 4px; box-shadow: 0 0 0 2px var(--ink); }
@keyframes affordGlow { 50% { box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--lime); } }
@media (max-width: 720px) { .afford-item { padding: 5px 7px; font-size: 12px; } .afford-item .cost { display: none; } }

/* ---------- resources flying from the tiles to the hands ---------- */
.fly-res { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; will-change: transform, opacity; filter: drop-shadow(3px 3px 0 var(--ink)); }
.fly-res img.px { width: 34px; height: 34px; display: block; }
.fly-res:not(.mine) img.px { width: 26px; height: 26px; }
/* a stolen card that you're not part of: you only see its back */
.fly-back { display: block; width: 22px; height: 30px; background: repeating-linear-gradient(45deg, var(--pc, #5d275d) 0 4px, #29366f 4px 8px); box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--ink); }
/* where the cards land: player cards and the bank counters give a little hop */
.pcard.bump { animation: bumpSm .45s; }
.bank-info span.bump { display: inline-block; animation: bump .45s; }
@keyframes bumpSm { 40% { transform: translateY(-4px) scale(1.03) } }

/* ---------- reactions ---------- */
.emote-toggle { font-size: 16px; }
.emote-pop { position: fixed; z-index: 90; width: min(340px, calc(100vw - 16px)); padding: 10px; background: var(--panel); box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sand), 6px 6px 0 6px var(--ink); animation: popIn .12s steps(3); }
.emote-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emote-btn { background: var(--dusk); border: 0; padding: 5px 0; font-size: 22px; cursor: pointer; box-shadow: 0 0 0 2px var(--ink); color: var(--white); }
.emote-btn:hover { background: var(--navy); transform: translateY(-2px); }
.emote-btn img.px { width: 24px; height: 24px; }
.emote-phrases { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 8px; }
.emote-phrases .chip { font-size: 12px; padding: 4px 8px; }
.emote-say { display: flex; gap: 6px; }
.emote-input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 6px 8px; background: var(--ink); color: var(--white); border: 0; box-shadow: 0 0 0 2px var(--slate); }
.emote-input:focus { outline: none; box-shadow: 0 0 0 2px var(--sand); }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }

/* ---------- ADHD: the little arcade for the wait (a machine appears in each empty slot as you earn it) ---------- */
.adhd-toggle { font-size: 16px; }
.adhd-toggle.on { background: var(--plum); }
.adhd { position: absolute; left: 10px; bottom: 10px; z-index: 5; width: min(400px, calc(100% - 70px)); max-height: calc(100% - 64px); overflow: auto; padding: 8px; background: var(--panel); box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--plum), 6px 6px 0 6px rgba(0,0,0,.45); animation: popIn .12s steps(3); transition: opacity .2s, filter .2s; }
.adhd.hidden { display: none; }
/* your turn or a trade offer: still there, but see-through and clicks go to the board */
.adhd.ghost { opacity: .4; filter: grayscale(.5); pointer-events: none; }
.adhd-picks .btn { padding: 4px 2px !important; }
.adhd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.adhd-title { font-family: var(--display); color: var(--sand); font-size: 13px; white-space: nowrap; }
.adhd-money { font-family: var(--num); color: var(--lime); font-size: 16px; }
.adhd-prog { flex: 1; min-width: 30px; height: 8px; background: var(--ink); box-shadow: 0 0 0 2px var(--dusk); }
.adhd-prog i { display: block; height: 100%; width: 0; background: var(--sand); transition: width .2s steps(4); }
.adhd-goal { font-family: var(--num); font-size: 11px; color: var(--muted); white-space: nowrap; }
.adhd-wins { font-family: var(--num); font-size: 12px; color: var(--sand); }
.adhd .btn.sm { padding: 4px 8px; font-size: 12px; border-radius: 0; }
.adhd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.adhd-slot { min-height: 150px; background: repeating-linear-gradient(45deg, rgba(0,0,0,.2) 0 6px, transparent 6px 12px); box-shadow: inset 0 0 0 2px var(--dusk); }
.adhd-cell { min-width: 0; display: flex; flex-direction: column; gap: 5px; padding: 6px; background: var(--ink); box-shadow: 0 0 0 2px var(--dusk); }
.adhd-cell.fresh { animation: adhdIn .6s steps(6); }
@keyframes adhdIn { 0% { transform: scale(.2); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }
.adhd-cell h4 { margin: 0; font-family: var(--display); font-size: 11px; color: var(--sand); }
.adhd-cv { display: block; width: 100%; height: auto; image-rendering: pixelated; background: #0f1020; }
.adhd-row { display: flex; gap: 4px; align-items: center; }
.adhd-row .btn { flex: 1; min-width: 0; white-space: nowrap; }
.adhd-row input + b + .btn { flex: 0 0 auto; }
.adhd-row input[type=range] { flex: 1; min-width: 0; accent-color: var(--sand); }
.adhd-row b { font-family: var(--num); font-size: 11px; color: var(--lime); min-width: 38px; text-align: right; }
.adhd-note { min-height: 13px; font-family: var(--num); font-size: 9px; color: var(--muted); }
.adhd-bins { display: grid; grid-template-columns: repeat(9, 1fr); font-family: var(--num); font-size: 8px; text-align: center; color: var(--muted); }
.adhd-fw { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 45; pointer-events: none; image-rendering: pixelated; }
.adhd-band { position: fixed; left: 0; right: 0; top: 22%; z-index: 46; pointer-events: none; display: grid; place-items: center; padding: 14px 10px; background: var(--ink); box-shadow: 0 5px 0 var(--pc), 0 -5px 0 var(--pc), 0 10px 0 var(--ink), 0 -10px 0 var(--ink); font-family: var(--display); color: var(--sand); font-size: clamp(18px, 4vw, 34px); text-shadow: 3px 3px 0 var(--wine); text-align: center; animation: adhdBand 5s steps(30) forwards; }
.adhd-band b { color: var(--pc); }
.adhd-band-n { color: #ffcd75; }
.adhd-band small { margin-top: 6px; font-size: 14px; color: var(--sand); opacity: .8; text-shadow: none; }
@keyframes adhdBand { 0% { transform: translateX(-100%); } 8%, 88% { transform: none; opacity: 1; } 100% { transform: translateX(100%); opacity: 0; } }
@media (max-width: 700px) { .adhd { width: calc(100% - 64px); } .adhd-slot { min-height: 110px; } }

/* a pixel balloon on a string, tied to one of your buildings */
.balloon { z-index: 60; display: flex; flex-direction: column; align-items: center; will-change: transform, opacity; }
.balloon-body { position: relative; display: grid; place-items: center; color: var(--ink); font-weight: 700; }
.balloon.emoji .balloon-body { width: 58px; height: 64px; background: var(--pc); font-size: 32px;
  clip-path: polygon(30% 0, 70% 0, 100% 25%, 100% 62%, 72% 100%, 28% 100%, 0 62%, 0 25%); }
.balloon.emoji .balloon-body::before { content: ''; position: absolute; left: 22%; top: 16%; width: 9px; height: 12px; background: rgba(255,255,255,.55); }
.balloon.emoji .balloon-body img.px { width: 34px; height: 34px; }
.balloon.talk .balloon-body { max-width: 200px; padding: 7px 11px; background: var(--white); font-size: 15px; line-height: 1.2; text-align: center;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--pc), 4px 4px 0 6px var(--ink); margin-bottom: 4px; }
.balloon.talk .balloon-body img.px { width: 18px; height: 18px; }
.balloon-knot { width: 10px; height: 6px; background: var(--pc); box-shadow: 0 0 0 2px var(--ink); }
.balloon.talk .balloon-knot { width: 12px; height: 8px; background: var(--white); clip-path: polygon(0 0, 100% 0, 50% 100%); box-shadow: none; }
.balloon-string { width: 2px; height: 30px; background: var(--ink); opacity: .8; }
.balloon.talk .balloon-string { display: none; }

/* the same reaction on the player's card */
.pc-emote { position: absolute; right: 46px; top: -12px; z-index: 3; max-width: 70%; padding: 2px 8px; background: var(--white); color: var(--ink); font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--pc); animation: pcEmote 3s steps(12) forwards; pointer-events: none; }
.pc-emote.big { font-size: 20px; padding: 0 6px; }
.pc-emote img.px { width: 16px; height: 16px; }
.pc-emote.big img.px { width: 22px; height: 22px; }
@keyframes pcEmote { 0% { transform: translateY(8px) scale(.6); opacity: 0; } 8% { transform: none; opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(-6px); opacity: 0; } }

/* settlement spots on a port corner carry an anchor badge */
.hot3d.v.port { position: relative; }
.hot3d.v.port::after { content: '⚓'; position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -3px); font-size: 12px; line-height: 1; padding: 1px 2px; background: var(--white); box-shadow: 0 0 0 2px var(--ink); pointer-events: none; }

/* the dice button: hold it and the bar fills with throwing power */
.roll-btn { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.roll-btn > span { position: relative; z-index: 1; }
.roll-fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--charge, 0) * 100%); background: repeating-linear-gradient(90deg, #f08a3a 0 8px, #e86a2a 8px 16px); opacity: 0; }
.roll-btn.charging .roll-fill { opacity: 1; }
.roll-btn.charging { animation: rollShake .12s steps(2) infinite; }
.roll-btn.full .roll-fill { background: repeating-linear-gradient(90deg, #e04040 0 8px, #b13e53 8px 16px); }
.roll-btn.full { animation-duration: .06s; }
@keyframes rollShake { 0% { transform: translate(-1px, 0); } 50% { transform: translate(1px, -1px); } 100% { transform: translate(-1px, 1px); } }

/* build buttons: the piece icon reads bigger than the label */
.bicon { line-height: 1; display: inline-flex; vertical-align: middle; }
.bicon img.px { width: 28px; height: 28px; vertical-align: 0; }
.afford-item .bicon img.px { width: 26px; height: 26px; }
@media (max-width: 720px) { .bicon img.px, .afford-item .bicon img.px { width: 22px; height: 22px; } }

/* dice history: a column in the top right corner of the map, newest on top, each chip in the thrower's colour */
.roll-log { position: absolute; top: 10px; right: 10px; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 5px; max-height: calc(100% - 250px); overflow: hidden; padding: 6px 5px; background: rgba(26,28,44,.82); box-shadow: 0 0 0 3px var(--ink); }
.roll-log-head { font-size: 15px; flex: none; }
.roll-chip { flex: none; width: 28px; height: 24px; display: grid; place-items: center; font-family: var(--num); font-weight: 400; font-size: 14px; color: var(--white); background: var(--panel); box-shadow: inset 4px 0 0 var(--pc), 0 0 0 2px var(--ink); padding-left: 3px; opacity: .7; }
.roll-chip.newest { opacity: 1; width: 32px; height: 28px; font-size: 16px; background: #333c57; box-shadow: inset 5px 0 0 var(--pc), 0 0 0 2px var(--ink), 0 0 0 4px var(--sand); margin-bottom: 2px; }
.roll-chip.seven { color: #ef7d57; }
@media (max-width: 720px) { .roll-log { top: 6px; right: 6px; gap: 4px; max-height: calc(100% - 230px); } .roll-chip { width: 24px; height: 20px; font-size: 12px; } }
