@import url(/static/fonts/fonts.css);

/* Castellia: a dark oak table under candle light, parchment panels, carved
   lettering, a green land of hand-drawn tiles. */
:root {
  --oak: #2a1d14;
  --oak-2: #3a2a1d;
  --oak-3: #4b3727;
  --gold: #d9a441;
  --gold-dk: #8a5a14;
  --ink: #2b1f14;
  --ink-shadow: #120b05;
  --parch: #f6ecd4;
  --parch-2: #efe0bd;
  --red: #b4472f;
  --blue: #2c5aa8;
  --green: #4f8a2f;
  --muted: #7a6650;
  --line: #e2d2ae;
  --good: #4f8a2f;
  --bad: #b4472f;
  --radius: 14px;
  --serif: Cinzel, 'Trajan Pro', Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--oak); }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(217, 164, 65, .22), transparent 70%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.08) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #2f2117, var(--oak) 60%, #1d140d);
  background-attachment: fixed;
  color: var(--ink); font-family: Montserrat, system-ui, sans-serif; font-size: 15px; line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; font-family: var(--serif); font-weight: 800; }
h2 { color: var(--ink); }
p { margin: 0 0 .5rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center-text { text-align: center; }
.center { text-align: center; }

/* ---------------------------------------------------------------- logo */
.logo { display: inline-flex; align-items: center; gap: .25em; font-family: var(--serif); font-weight: 900; line-height: 1; white-space: nowrap; user-select: none; color: var(--gold); }
.logo-castle { height: 1em; width: auto; flex: none; filter: drop-shadow(0 .04em 0 var(--ink-shadow)); }
.logo-text { letter-spacing: .04em; background: linear-gradient(180deg, #f6dc8f, #d9a441 55%, #9c6a1c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 .05em 0 var(--ink-shadow)); }
.hero-logo { font-size: clamp(2.8rem, 12vw, 5.4rem); }
.brand-logo { font-size: 1.35rem; }
.mini-logo { font-size: 1rem; }

/* ---------------------------------------------------------------- topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(18, 11, 5, .8); color: #fff; flex-wrap: wrap; backdrop-filter: blur(6px); border-bottom: 1px solid rgba(217, 164, 65, .25); }
.topbar a, .topbar .linkbtn { color: #f3e6c8; text-decoration: none; font-weight: 600; }
.brand { display: flex; align-items: center; padding: 4px 8px; }
.topbar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; box-shadow: none; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 4px; color: var(--ink); }
input, select { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; font: inherit; background: #fffaf0; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 164, 65, .35); }
button, .btn { font: inherit; font-weight: 800; border: 0; border-radius: 10px; padding: 11px 18px; cursor: pointer; background: var(--oak-3); color: #fff4dc; text-decoration: none; display: inline-block; box-shadow: 0 3px 0 #1a110a; transition: transform .08s, filter .15s; }
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #1a110a; }
button:disabled { opacity: .45; cursor: default; }
.btn-accent { background: linear-gradient(180deg, #e6b85a, var(--gold)); color: #2a1700; box-shadow: 0 3px 0 var(--gold-dk); }
.btn-accent:active { box-shadow: 0 1px 0 var(--gold-dk); }
.btn-ghost { background: #fffaf0; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.sso-btn::before { content: '🔑 '; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 900; font-size: 1.4rem; text-align: center; }

/* ---------------------------------------------------------------- layout */
.panel { background: linear-gradient(180deg, var(--parch), var(--parch-2)); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(120, 80, 30, .25), inset 0 0 40px rgba(150, 100, 40, .12); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--parch); border-left: 5px solid var(--blue); }
.notice.err { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--good); background: #f1f6e6; }
.pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #eadbb8; color: var(--ink); margin-right: 4px; }
.pill.off { background: #eee6d6; color: #8a7d6a; }
.pill.gold { background: var(--gold); color: var(--ink); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff4dc; padding: 12px 16px; border-radius: 12px; border-left: 5px solid var(--gold); z-index: 2000; max-width: calc(100vw - 32px); font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toast-in .25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.spinner { width: 14px; height: 14px; border: 3px solid rgba(255,255,255,.35); border-top-color: var(--gold); border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 8px; animation: spin 0.9s linear infinite; }
.panel .spinner { border-color: var(--line); border-top-color: var(--gold-dk); }
@keyframes spin { to { transform: rotate(360deg); } }
.wait { color: var(--muted); font-weight: 600; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }

/* ---------------------------------------------------------------- tiles + followers */
.tile { position: relative; width: 100px; height: 100px; }
.tile-svg { display: block; width: 100%; height: 100%; }
.meeple { display: inline-block; width: 22px; height: 22px; flex: none; filter: drop-shadow(0 1.5px 1px rgba(0,0,0,.45)); }
.meeple svg { width: 100%; height: 100%; display: block; }
.meeple.lying svg { transform: rotate(-90deg); }

/* ---------------------------------------------------------------- home */
.hero { text-align: center; margin: 10px 0 26px; color: #fff; }
.hero-land { position: relative; width: min(240px, 60vw); aspect-ratio: 1; margin: 6px auto 18px; transform: rotate(-4deg); filter: drop-shadow(0 12px 20px rgba(0,0,0,.6)); }
.hero-land .tile { position: absolute; width: 33.34%; height: 33.34%; animation: lay .5s cubic-bezier(.2,.8,.3,1.2) backwards; animation-delay: calc(var(--i) * .09s); }
@keyframes lay { from { opacity: 0; transform: translateY(-40px) scale(1.2) rotate(8deg); } }
.hero-fol { position: absolute; width: 13%; height: 13%; animation: lay .5s 1s backwards; }
.hero-fol .meeple { width: 100%; height: 100%; }
.hero-fol.f1 { left: 46%; top: 7%; }
.hero-fol.f2 { left: 6%; top: 42%; }
.hero-fol.f3 { left: 73%; top: 76%; }
.subtitle { font-size: 1.1rem; font-weight: 600; color: #f0e2c2; margin: 16px auto 0; max-width: 640px; }
.rules { padding-left: 1.3rem; margin: 0 0 1rem; }
.rules li { margin-bottom: .55rem; }
.rules li::marker { color: var(--gold-dk); font-weight: 900; }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.score-table th, .score-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.score-table thead th { font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------- lobby */
.lobby { margin-top: 8px; }
.code-text { font-size: clamp(2.4rem, 10vw, 3.4rem); font-weight: 900; font-family: var(--serif); letter-spacing: .12em; color: var(--ink); }
.qr { width: 180px; height: 180px; display: block; margin: 0 auto; border-radius: 12px; }
.players .tags { margin-top: 2px; }
.lobby-wrap main { padding-bottom: 40px; }
.lobby-meeple { width: 26px; height: 26px; }
.grid-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------------------------------------------------------- table */
body.in-game { overflow: hidden; overscroll-behavior: none; }
.game {
  height: 100svh; display: flex; flex-direction: column; color: #fff;
  user-select: none; -webkit-user-select: none;
}
.slot-top { flex: none; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); background: rgba(18, 11, 5, .82); border-bottom: 1px solid rgba(217, 164, 65, .3); z-index: 5; }
.slot-dock { flex: none; z-index: 5; }
.tinfo { display: flex; align-items: center; gap: 10px; height: 36px; font-weight: 700; font-size: .88rem; white-space: nowrap; }
.tlogo { display: flex; }
.bag { color: #e9d9b4; }
.bag::before { content: '👜 '; }
.clock-num { font-family: var(--serif); font-weight: 900; font-size: 1.15rem; color: #fff4dc; flex: 1; text-align: center; }
.clock-num.hurry { color: #ff8c6b; animation: hurry .5s ease-in-out infinite alternate; }
@keyframes hurry { to { filter: brightness(1.6); } }
.zoom { display: flex; gap: 4px; margin-left: auto; }
.zbtn { padding: 4px 10px; background: rgba(255,255,255,.1); box-shadow: none; font-size: 1.05rem; line-height: 1.2; }
.menu-btn { background: rgba(255,255,255,.1); box-shadow: none; padding: 6px 12px; font-size: 1.1rem; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 0; scrollbar-width: none; }
.chip { flex: none; min-width: 110px; background: rgba(0, 0, 0, .35); border: 2px solid rgba(255,255,255,.1); border-radius: 10px; padding: 4px 9px; border-left: 5px solid var(--pc); transition: background .2s, box-shadow .2s; }
.chip.me .chip-name { text-decoration: underline; text-decoration-color: var(--pc); text-underline-offset: 3px; }
.chip.turn { background: rgba(217, 164, 65, .22); border-color: var(--gold); box-shadow: 0 0 12px rgba(217, 164, 65, .45); }
.chip.gone { opacity: .45; }
.chip.gain { animation: gain .8s ease-out; }
@keyframes gain { 30% { background: var(--pc); transform: scale(1.06); } }
.chip-top { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: .82rem; }
.chip-name { max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 1px; }
.chip-score { font-family: var(--serif); font-size: 1.25rem; font-weight: 900; color: #fff4dc; }
.chip-fol { display: inline-flex; align-items: center; gap: 1px; font-weight: 700; font-size: .85rem; color: #e9d9b4; }
.chip-fol .meeple { width: 16px; height: 16px; }

/* the land */
.land { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; cursor: grab;
  background:
    radial-gradient(ellipse at center, rgba(255, 240, 200, .08), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.12) 0 3px, transparent 3px 26px),
    linear-gradient(180deg, #4a3423, #3b291c); }
.land.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.world.glide { transition: transform .35s ease-out; }
.tiles-layer, .spots-layer, .marks-layer { position: absolute; left: 0; top: 0; }
.world .tile { position: absolute; box-shadow: 0 2px 4px rgba(0,0,0,.45); }
.world .tile.drop { animation: drop .45s cubic-bezier(.2,.8,.3,1.25); }
@keyframes drop { from { transform: translateY(-30px) scale(1.15); opacity: 0; } }
.world .tile.last::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px rgba(255, 236, 160, .9); pointer-events: none; }
.world .tile.flash::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; animation: flash 1.7s ease-out forwards; background: rgba(255, 230, 120, .55); }
.world .tile.flash.k-road::before { background: rgba(255, 255, 255, .55); }
.world .tile.flash.k-cloister::before { background: rgba(255, 180, 120, .55); }
.world .tile.flash.k-field::before { background: rgba(170, 240, 120, .55); }
@keyframes flash { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.fol { position: absolute; width: 24px; height: 24px; transform: translate(-50%, -55%); z-index: 3; pointer-events: none; }
.fol .meeple { width: 100%; height: 100%; animation: hop-in .35s cubic-bezier(.2,.8,.3,1.5); }
@keyframes hop-in { from { transform: translateY(-14px) scale(1.4); opacity: 0; } }
.spot { position: absolute; width: 100px; height: 100px; border: 2px dashed rgba(255, 240, 200, .18); border-radius: 4px; }
.spot.mine { border-color: rgba(255, 232, 150, .55); background: rgba(255, 232, 150, .08); cursor: pointer; }
.spot.mine.fits { border-style: solid; border-color: rgba(255, 232, 150, .95); background: rgba(255, 232, 150, .2); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { background: rgba(255, 232, 150, .32); } }
.spot.mine:hover { background: rgba(255, 232, 150, .38); }
.world .tile.tent { opacity: .92; cursor: pointer; box-shadow: 0 0 0 3px #ffe58a, 0 8px 18px rgba(0,0,0,.6); z-index: 4; animation: tent .25s ease-out; }
@keyframes tent { from { transform: scale(1.12); } }
.mark-box { position: absolute; width: 100px; height: 100px; z-index: 6; }
.fmark { position: absolute; width: clamp(26px, calc(30px / var(--z, 1)), 34px); height: clamp(26px, calc(30px / var(--z, 1)), 34px); padding: 0; border-radius: 50%; transform: translate(-50%, -50%); background: rgba(255, 250, 230, .85);
  box-shadow: 0 0 0 2px var(--pc), 0 0 0 5px rgba(255, 255, 255, .5), 0 3px 8px rgba(0,0,0,.5); display: grid; place-items: center; animation: pulse 1.2s ease-in-out infinite; }
.fmark .meeple { width: 66%; height: 66%; opacity: .85; }
.fmark:hover { background: #fff; }
.fmark:hover .meeple { opacity: 1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--pc), 0 0 0 8px rgba(255, 255, 255, .25), 0 3px 8px rgba(0,0,0,.5); } }

/* the dock: current tile + buttons */
.dock-wrap { position: relative; }
.dock { display: flex; align-items: center; gap: 12px; padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: rgba(18, 11, 5, .88); border-top: 1px solid rgba(217, 164, 65, .3); }
.dock.mine { background: linear-gradient(180deg, rgba(70, 48, 18, .95), rgba(30, 20, 10, .95)); border-top-color: var(--gold); }
.cur-tile { padding: 0; background: none; box-shadow: 0 0 0 3px var(--pc), 0 6px 14px rgba(0,0,0,.6); border-radius: 3px; width: 76px; height: 76px; flex: none; }
.cur-tile .tile { width: 76px; height: 76px; }
.cur-tile .tile-svg { transition: transform .2s; }
.dock-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.status { margin: 0; color: #f3e6c8; font-weight: 700; min-height: 1.3em; font-size: .92rem; }
.dock-btns { display: flex; gap: 8px; }
.ctl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 10px 8px; font-size: .92rem; }
.ctl.go { background: linear-gradient(180deg, #e6b85a, var(--gold)); color: #2a1700; box-shadow: 0 3px 0 var(--gold-dk); }
.ctl.ghosty { background: rgba(255,255,255,.1); box-shadow: none; flex: 0 1 auto; }
.over-again { position: absolute; right: 12px; bottom: calc(100% + 12px); z-index: 6; }

/* bubbles */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1500; }
.bubble { position: fixed; z-index: 1700; transform: translate(-50%, -50%); font-family: var(--serif); font-weight: 900; font-size: 2rem; color: #fff4dc; white-space: nowrap;
  -webkit-text-stroke: 3px var(--ink-shadow); paint-order: stroke fill; text-shadow: 2px 3px 0 var(--ink-shadow); animation: bubble 2s ease-out forwards; letter-spacing: .03em; }
.bubble.b-go { font-size: clamp(2rem, 8vw, 3.2rem); color: #ffe58a; }
.bubble.b-score { color: var(--pc, #ffe58a); font-size: 2.6rem; -webkit-text-stroke: 4px #fff; text-shadow: 0 3px 8px rgba(0,0,0,.6); }
@keyframes bubble { 0% { opacity: 0; scale: .3; } 15% { opacity: 1; scale: 1.15; } 25% { scale: 1; } 75% { opacity: 1; translate: 0 -12px; } 100% { opacity: 0; translate: 0 -34px; } }
@keyframes pop { 0% { scale: 1.12; } 100% { scale: 1; } }
@keyframes fade-in { from { opacity: 0; } }

/* menu + overlays */
.menu { position: fixed; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 44px); z-index: 1200; background: var(--parch); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; min-width: 220px; box-shadow: 0 12px 30px rgba(0,0,0,.5); animation: pop .2s; }
.menu button { background: none; box-shadow: none; color: var(--ink); text-align: left; padding: 10px 12px; font-weight: 700; }
.menu button:hover { background: var(--parch-2); }
.overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(15, 9, 4, .66); display: grid; place-items: center; padding: 16px; animation: fade-in .3s; backdrop-filter: blur(3px); }
.modal { width: min(500px, 100%); max-height: calc(100svh - 32px); overflow: auto; color: var(--ink); animation: pop .35s; }
.overlay.clear { background: transparent; backdrop-filter: none; }
.over { text-align: center; }
.over h2 { font-size: 1.9rem; color: var(--ink); }
.over-meeples { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin-bottom: 8px; }
.over-meeples .meeple { width: 30px; height: 30px; }
.over-meeples .meeple.big { width: 48px; height: 48px; animation: hop-in .6s cubic-bezier(.2,.8,.3,1.5); }
.scores li { text-align: left; }
.scores li.win { background: #f9e7b5; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.place { width: 2em; color: var(--gold-dk); }
.pts { font-family: var(--serif); font-size: 1.4rem; font-weight: 900; }
.log { list-style: none; padding: 0; margin: 0 0 12px; font-size: .88rem; max-height: 60svh; overflow: auto; }
.log li { padding: 5px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 520px) {
  .mini-logo .logo-text { display: none; }
  .chip { min-width: 92px; }
  .cur-tile, .cur-tile .tile { width: 64px; height: 64px; }
  .grid-opts { grid-template-columns: 1fr; }
}

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

/* moving the table to another Antwire game (hub.js) */
.move-box { border-top: 1px solid rgba(120, 80, 30, .2); padding-top: .6rem; margin-top: .4rem; text-align: left; }
.move-box summary { cursor: pointer; font-weight: 700; }
.move-box p { margin: .4rem 0; }
.move-games { display: flex; flex-wrap: wrap; gap: .4rem; }
.move-page { max-width: 480px; margin: 2rem auto; }
