/* Bigfoot e le Streghe del Kah — storybook art direction.
   Parchment page, bronze line-art, Cormorant Garamond display + Alegreya body.
   Swap placeholders by setting GRAPHICS.url in js/ui.js
   and adding background-image rules to .ph-* classes. */

@font-face { font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 500; src: url('../assets/fonts/CormorantGaramond-normal-500.ttf'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 600; src: url('../assets/fonts/CormorantGaramond-normal-600.ttf'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 700; src: url('../assets/fonts/CormorantGaramond-normal-700.ttf'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: italic; font-weight: 500; src: url('../assets/fonts/CormorantGaramond-italic-500.ttf'); }
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; src: url('../assets/fonts/Alegreya-normal-400.ttf'); }
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 500; src: url('../assets/fonts/Alegreya-normal-500.ttf'); }
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 700; src: url('../assets/fonts/Alegreya-normal-700.ttf'); }
@font-face { font-family: 'Alegreya'; font-style: italic; font-weight: 400; src: url('../assets/fonts/Alegreya-italic-400.ttf'); }

:root {
  --parch: #f7f0dc; --parch2: #fffdf4; --panel: #f5edd6; --panel2: #efe4c8;
  --ink: #2a2118; --ink2: #4a3d28; --muted: #8a7a5c;
  --bronze: #7a5c22; --gold: #b98a2f;
  --sage: #5f7a6a; --moss: #2f5d3a;
  --blood: #8c2f2f; --blood2: #b3563f;
  --night: #2b3550;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: 'Alegreya', Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(1100px 700px at 50% -8%, rgba(255,253,244,.85), rgba(255,253,244,0) 70%),
    radial-gradient(900px 900px at 50% 115%, rgba(122,92,34,.14), rgba(122,92,34,0) 65%),
    var(--parch);
}
.hidden { display: none !important; }
h1, h2, h3, h4 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .04em; color: var(--ink2); }
button { font-family: inherit; }

/* ---------- generic ---------- */
.btn { background: var(--bronze); color: #f7f0dc; border: 1px solid #5e4718; border-radius: 8px; padding: .55em 1.1em; font-size: 1rem; cursor: pointer; margin: .2em; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .06em; }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--bronze); border: 1px solid var(--bronze); }
.btn.pick { background: var(--panel2); color: var(--ink2); border: 1px solid var(--sage); min-width: 120px; }
.btn.pick small { color: var(--muted); }
.btn.obj { display: block; width: 100%; text-align: left; background: var(--panel2); color: var(--ink2); border: 1px solid var(--sage); }
input, select { background: var(--parch2); color: var(--ink); border: 1px solid var(--bronze); border-radius: 8px; padding: .55em .8em; font-size: 1rem; width: 100%; margin-top: .3em; font-family: inherit; }
label { display: block; margin: .7em 0; text-align: left; color: var(--ink2); }
.hint { color: var(--muted); font-size: .9em; margin: .5em 0; font-style: italic; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); border: 1px solid var(--gold); color: var(--parch); padding: .7em 1.2em; border-radius: 10px; opacity: 0; transition: all .3s; z-index: 99; max-width: 90vw; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.05em; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- lobby ---------- */
#screen-lobby { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1em; }
.lobby-box { background: var(--parch2); border: 1.5pt solid var(--bronze); outline: 1px solid var(--gold); outline-offset: 4px; border-radius: 14px; padding: 2em; max-width: 480px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(122,92,34,.25); }
.lobby-box h1 { font-size: 2.4em; margin: 0; color: var(--bronze); font-weight: 700; line-height: 1.05; }
.lobby-box h1 span { font-size: .62em; color: var(--ink2); font-weight: 500; font-style: italic; }
.sub { color: var(--muted); margin-top: .4em; font-style: italic; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8em; }
.btnrow { margin-top: 1em; }
#wait-players { margin: 1em 0; }
.wp { background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: .4em .8em; margin: .25em; display: inline-block; color: var(--ink2); }

html, body { overscroll-behavior-y: none; } /* no pull-to-refresh: a swipe must never reload the table */

/* ---------- HUD ---------- */
#hud { display: flex; gap: .8em; align-items: center; padding: .5em .9em; background: var(--panel); border-bottom: 1.5pt solid var(--bronze); flex: 0 0 auto; flex-wrap: wrap; }
#hud-turn { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; font-size: 1.15em; color: var(--bronze); margin-right: auto; }
#hud-obj { font-style: italic; color: var(--ink2); font-size: .92em; }
#hud-deck { color: var(--muted); font-size: .85em; }
#hud .btn { font-size: .85rem; padding: .4em .8em; }

/* ---------- action bar (contextual actions, all quadrants) ---------- */
#actionbar { flex: 0 0 auto; background: var(--panel2); border-bottom: 1px solid var(--gold); padding: .45em .9em; }
#actionbar .hint { margin: .25em 0; }
#actions .btn { font-size: .88rem; padding: .42em .9em; }
.bidbtns { display: flex; gap: .3em; flex-wrap: wrap; margin: .35em 0 .5em; }
#actions .bidbtn { min-width: 2.6em; padding: .42em .5em; }
#actions .bidbtn.sel { background: var(--gold); color: #1d150a; border-color: #6b4d14;
  box-shadow: 0 0 0 2px rgba(185,138,47,.55); }

/* ---------- board: one table, two depth planes ---------- */
#screen-game { display: flex; flex-direction: column; height: 100dvh; position: relative; }
#screen-game.hidden { display: none; }
#board { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
/* far plane: the table itself — two swipeable pieces (thrones | trees), no boxes, no blur until the hand takes focus */
#tableplane { position: absolute; inset: 0; overflow: hidden; transition: filter .35s ease, transform .55s cubic-bezier(.3,.7,.3,1); transform: perspective(1200px) rotateX(20deg) scale(1.2); transform-origin: 50% 55%; background-color: #241708; }
/* each table page carries its own wood: it moves rigidly with the page on turns
   (horizontal) and scrolls along with the content (vertical) */
.tpage { background: url('../assets/textures/wood-table-v2.jpg'); background-size: 620px; background-repeat: repeat; background-attachment: local; }
/* candlelight: two flickering side lights + vignette, fixed to the board so they stay
   consistent while pages slide beneath and while the hand is shown */
#board::before, #board::after { content: ''; position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#board::before {
  background:
    radial-gradient(ellipse 46% 72% at -2% 46%, rgba(255,200,122,.22) 0%, rgba(255,154,72,.07) 52%, rgba(255,154,72,0) 74%),
    radial-gradient(ellipse 108% 102% at 50% 46%, rgba(0,0,0,0) 56%, rgba(8,5,2,.44) 100%);
  animation: kah-flicker 4.3s ease-in-out infinite;
}
#board::after {
  background:
    radial-gradient(ellipse 46% 72% at 102% 46%, rgba(255,200,122,.22) 0%, rgba(255,154,72,.07) 52%, rgba(255,154,72,0) 74%);
  animation: kah-flicker 6.1s ease-in-out -2.4s infinite;
}
@keyframes kah-flicker {
  0%, 100% { opacity: .82; }
  11% { opacity: 1; }
  26% { opacity: .76; }
  41% { opacity: .94; }
  57% { opacity: .8; }
  73% { opacity: 1; }
  88% { opacity: .86; }
}
@media (prefers-reduced-motion: reduce) { #board::before, #board::after { animation: none; } }
/* hand focus: the table recedes — blurred, dimmed, and drifting up along its
   own slanted surface, the way a real table shifts when your eyes drop to your hand */
#board.focus-hand #tableplane { filter: blur(7px) brightness(.82); transform: perspective(1200px) rotateX(20deg) translateY(-72px) scale(1.2); cursor: pointer; }
#tabletrack { display: flex; height: 100%; transition: transform .38s cubic-bezier(.3,.7,.3,1); will-change: transform; }
.tpage { flex: 0 0 100%; height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: none; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 1em 1.1em 110px; position: relative; scrollbar-width: none; -ms-overflow-style: none; }
/* no scrollbar hairline between pages, ever — scrolling still works by touch */
.tpage::-webkit-scrollbar { display: none; width: 0; }
.tpage > .q-title { max-width: 640px; margin-left: auto; margin-right: auto; }
/* engraved page hints: etched into the table, tap to turn the page */
.page-hint { position: absolute; top: .35em; z-index: 6; background: none; border: none; padding: .4em .55em; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.05em; letter-spacing: .05em; color: rgba(122,92,34,.6); text-shadow: 0 1px 0 rgba(255,252,240,.6), 0 -1px 0 rgba(74,52,20,.28); cursor: pointer; filter: grayscale(1); }
#page-thrones .page-hint { right: .45em; }
#page-trees .page-hint { left: .45em; }
/* table page dots */
#tpagedots { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(68px + .6em); z-index: 25; display: flex; gap: .3em; background: rgba(42,33,24,.78); border: 1px solid var(--gold); border-radius: 999px; padding: .25em .4em; }
#tpagedots button { background: transparent; border: none; color: #cbb98d; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; font-size: .78em; letter-spacing: .04em; padding: .3em .6em; border-radius: 999px; cursor: pointer; white-space: nowrap; }
#tpagedots button.on { background: var(--gold); color: #2a2118; }
#board.focus-hand #tpagedots { display: none; }
/* near plane: the hand floats over the board — nothing behind the cards.
   Hand focus: the stack is big and centered, owning the stage.
   Table focus: the stack slides almost fully off-screen, card tops peeking. */
#handplane { position: absolute; inset: 0; z-index: 20; pointer-events: none; touch-action: none; }
#handstack { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); transition: top .38s cubic-bezier(.3,.7,.3,1), transform .38s cubic-bezier(.3,.7,.3,1); pointer-events: none; padding: 0 .6em calc(.6em + env(safe-area-inset-bottom, 0px)); }
#board.focus-table #handstack { top: 100%; transform: translateY(-68px); pointer-events: auto; }
#board.focus-table .fan-hint { display: none; }
#handhead { display: flex; justify-content: center; gap: .6em; align-items: baseline; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: .95em; letter-spacing: .18em; text-transform: uppercase; color: var(--bronze); margin-bottom: .3em; text-shadow: 0 1px 0 rgba(247,240,220,.85), 0 0 12px rgba(247,240,220,.6); }
#handhead #hand-count { font-size: .78em; letter-spacing: .04em; color: var(--muted); font-style: italic; text-transform: none; font-family: 'Alegreya', Georgia, serif; font-weight: 400; }
#hand { --cw: 116px; display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; perspective: 1000px; padding: .3em .2em .2em; }
#hand .card { pointer-events: auto; box-shadow: 0 10px 24px rgba(42,33,24,.35); }
/* objective card back: sits at the hand's bottom-right; tap to open objectives */
#obj-back { position: absolute; right: .9em; bottom: calc(.9em + env(safe-area-inset-bottom, 0px)); z-index: 21; width: 56px; aspect-ratio: 5/7; border-radius: 8px; background: radial-gradient(circle at 35% 28%, #b04040 0%, #8a2323 42%, #571111 100%); border: 2pt double var(--gold); color: #ffd98a; font-size: 1.4em; cursor: pointer; box-shadow: inset 0 2px 6px rgba(255,220,220,.28), inset 0 -4px 9px rgba(0,0,0,.5), 0 6px 16px rgba(42,33,24,.4); display: flex; align-items: center; justify-content: center; padding: 0; transition: transform .15s ease, opacity .3s ease; }
#obj-back::after { content: ''; position: absolute; inset: 5px; border: 1px solid rgba(212,175,55,.45); border-radius: 5px; pointer-events: none; }
#obj-back:hover { transform: translateY(-3px); }
#board.focus-table #obj-back { opacity: 0; pointer-events: none; }
/* objectives bottom sheet */

/* ---------- thrones (compass) ---------- */
#thrones { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, auto); gap: .5em; width: 78%; max-width: 560px; margin: 0 auto; align-content: start; }
#thrones [data-throne="N"] { grid-column: 2; grid-row: 1; }
#thrones [data-throne="W"] { grid-column: 1; grid-row: 2; }
#thrones [data-throne="E"] { grid-column: 3; grid-row: 2; }
#thrones [data-throne="S"] { grid-column: 2; grid-row: 3; }
.throne-center { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; text-align: center; font-family: 'Cormorant Garamond', Georgia, serif; color: var(--bronze); font-size: 1.6em; line-height: 1.1; opacity: .75; }
.throne-center small { display: block; font-size: .42em; letter-spacing: .3em; }
.throne { background: var(--parch2); border: 1.5pt solid var(--bronze); border-radius: 12px; padding: .5em .3em; text-align: center; min-height: 112px; box-shadow: 0 4px 14px rgba(122,92,34,.15); }

/* deck + discard piles below the compass */
#piles { display: flex; justify-content: center; gap: 2.4em; margin-top: 1.5em; padding-bottom: .6em; }
.pile { display: flex; flex-direction: column; align-items: center; gap: .5em; }
.pile-cards { position: relative; width: 96px; aspect-ratio: 5/7; }
.pile-cards.multi::before { content: ''; position: absolute; inset: 0; transform: translate(5px, 6px) rotate(1.5deg); border-radius: 8px; border: 1.2pt solid var(--bronze); background: var(--parch); }
.pile-card { position: absolute; inset: 0; border-radius: 8px; border: 1.2pt solid var(--bronze); box-shadow: 0 2px 8px rgba(60,40,10,.22); }
.pile-back { background: linear-gradient(160deg, #43331c 0%, #2a1f10 60%, #1d150a 100%); border-color: var(--gold); display: flex; align-items: center; justify-content: center; }
.pile-back::after { content: '✦'; color: var(--gold); font-size: 1.9em; opacity: .9; }
.pile-back.dim { opacity: .45; }
.pile-face { background: var(--parch2); color: var(--ink); display: flex; align-items: center; justify-content: center; text-align: center; padding: .35em; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: .72em; line-height: 1.15; overflow: hidden; transform: rotate(-2.5deg); }
.pile-empty { background: transparent; border: 1.2pt dashed var(--bronze); box-shadow: none; opacity: .5; }
.pile-count { position: absolute; top: -11px; right: -11px; min-width: 25px; height: 25px; border-radius: 13px; background: var(--bronze); color: #fff8ea; font-size: .74em; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 7px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.pile-label { font-family: 'Cormorant Garamond', Georgia, serif; letter-spacing: .24em; font-size: .78em; font-weight: 700; color: var(--bronze); text-transform: uppercase; }
.pile.pickable { cursor: pointer; }
.pile.pickable .pile-cards { animation: pile-glow 1.7s ease-in-out infinite; }
@keyframes pile-glow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(212,175,55,.35)); transform: translateY(0); }
  50% { filter: drop-shadow(0 0 13px rgba(212,175,55,.95)); transform: translateY(-4px); }
}
.throne.is-cenere { border-color: #6b6558; opacity: .7; }
.t-label { font-family: 'Cormorant Garamond', Georgia, serif; font-size: .75em; font-weight: 600; letter-spacing: .22em; color: var(--muted); }
.w-hood { font-size: 2.2em; color: var(--muted); }
.w-skull { font-size: 2.2em; }
.w-face { width: 52px; height: 52px; border-radius: 50%; margin: .3em auto; background: radial-gradient(circle at 35% 30%, #c9a06a, #7a5230); border: 2px solid var(--gold); }
.ph-witch { /* future: background-image per witch */ }
.w-name { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; font-size: 1.05em; color: var(--bronze); }
.w-signs { font-size: .72em; color: var(--sage); font-style: italic; }
.w-vita { margin-top: .35em; font-size: 1.05em; color: var(--blood2); font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; }
.w-vita.vd { color: var(--gold); font-weight: 700; }
.w-vita.vlow { color: var(--blood); font-weight: 700; }

/* ---------- trees ---------- */
#trees { width: 78%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: .55em; }
.tree { display: flex; align-items: stretch; gap: .3em; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: .5em; }
.tree.pickable { border-color: var(--bronze); border-width: 1.5pt; cursor: pointer; box-shadow: 0 0 0 2px var(--gold); }
.tree.full-pick { border-color: var(--muted); opacity: .55; cursor: not-allowed; }
#log div, .toast, .hint, .tcard, .card { overflow-wrap: anywhere; }
.tcard { min-width: 118px; max-width: 142px; background: var(--parch2); color: var(--ink); border: 1.2pt solid var(--bronze); border-radius: 8px; padding: .45em; font-size: .8em; }
.tcard .tt { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: .72em; letter-spacing: .12em; text-transform: uppercase; color: var(--bronze); }
.tcard .tn { font-weight: 700; margin: .15em 0; }
.tcard .tx, .tcard .tby { font-size: .76em; color: var(--muted); font-style: italic; }
.tcard.seed { border-width: 1.8pt; background: #f3e8cd; }
.tcard.facedown { background: var(--night); color: #b9c6e4; border: 1px dashed #7a8ab8; display: flex; align-items: center; justify-content: center; }
.tcard.open { background: transparent; color: var(--moss); border: 1px dashed var(--moss); display: flex; align-items: center; justify-content: center; }
.tcard.leaf { background: #e6efdc; }
.tarrow { align-self: center; color: var(--bronze); font-family: 'Cormorant Garamond', Georgia, serif; }
.fuse { color: var(--blood); font-weight: bold; margin-top: .3em; }
.empty { color: var(--muted); font-style: italic; text-align: center; padding: 1em; }

/* ---------- hand fan ---------- */
#hand .card { width: var(--cw); margin: 0 calc((var(--cw) - var(--pitch, 72px)) / -2); flex: 0 0 auto; z-index: var(--z, 1); transform-origin: 50% 130%; transform: rotate(var(--a, 0deg)) translateY(var(--y, 0px)); transition: transform .16s ease, filter .3s ease; }
#board.focus-table #hand .card { filter: blur(2px) brightness(.97); }
@media (hover: hover) {
  #hand .card:hover { --z: 100 !important; --y: -14px; transform: rotate(var(--a, 0deg)) translateY(var(--y, 0px)) scale(1.1); }
}
#hand .card.peek { --z: 100 !important; transform: rotate(var(--a, 0deg)) translateY(var(--y, 0px)) scale(1.12); }
/* card focus: the tapped card flies out of the fan and grows via scale (text never re-wraps);
   action buttons transition in from below. The layer lets other taps pass through. */
#focus-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#focus-layer.hidden { display: none; }
#focus-layer .focus-card { position: absolute; width: 116px; margin: 0; pointer-events: auto; cursor: pointer;
  transform-origin: 50% 50%; transform: translate(0, 0) scale(1);
  transition: left .3s cubic-bezier(.25,.8,.3,1), top .3s cubic-bezier(.25,.8,.3,1), transform .3s cubic-bezier(.25,.8,.3,1); }
#focus-layer .focus-card .card { width: 100%; }
#focus-layer .focus-card .card-text { display: none; }
#focus-layer .focus-card.in { left: 50% !important; top: 32% !important; transform: translate(-50%, -50%) scale(var(--fs, 2)); }
#focus-layer .focus-card.in .card-text { display: block; animation: fctext .25s ease .12s both; }
@keyframes fctext { from { opacity: 0; } to { opacity: 1; } }
#focus-layer .focus-actions { position: absolute; left: 50%; top: calc(32% + var(--fh, 170px) / 2 + 14px);
  transform: translate(-50%, 26px); opacity: 0; transition: opacity .25s ease .12s, transform .25s ease .12s;
  pointer-events: auto; display: flex; gap: .5em; flex-wrap: wrap; justify-content: center; max-width: 94vw; }
#focus-layer .focus-actions.show { opacity: 1; transform: translate(-50%, 0); }
#hand .card.focus-src { visibility: hidden; }
#focus-layer .focus-actions .btn.ghost { background: var(--bronze); color: #f7f0dc; border-color: #5e4718; }
#hand .card.sel { --y: -18px; }
#hand .card .card-text { display: none; }
#hand .card-art { height: 52px; }
.fan-hint { text-align: center; }

/* ---------- objectives ---------- */
/* objective cards: wax-seal look, clearly not playable cards */
.card.k-obiettivo { background: linear-gradient(165deg, #5a2117 0%, #33120d 72%); border: 2pt double var(--gold); color: #f2e2bd; }
.card.k-obiettivo .card-kind { color: var(--gold); }
.card.k-obiettivo .card-name { color: #f8ecd2; }
.card.k-obiettivo .card-text { color: #d8c096; }
.card.k-obiettivo .card-art { border: 1px solid rgba(212,175,55,.55); background: radial-gradient(circle at 50% 35%, #6b2a1e, #2a0f0a); display: flex; align-items: center; justify-content: center; font-size: 1.7em; color: var(--gold); }

/* ---------- side panel (players + log) ---------- */
#sidepanel { position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 88vw); background: var(--parch2); border-left: 1.5pt solid var(--bronze); z-index: 40; padding: 1em; overflow-y: auto; transform: translateX(102%); transition: transform .3s ease; box-shadow: -12px 0 40px rgba(42,33,24,.3); }
#sidepanel.open { transform: translateX(0); display: block !important; }
#sidepanel h3 { margin: .4em 0 .5em; font-size: 1.05em; letter-spacing: .14em; text-transform: uppercase; color: var(--bronze); border-bottom: 1px solid var(--gold); padding-bottom: .25em; }
#panel-close { position: absolute; top: .5em; right: .7em; background: none; border: none; color: var(--muted); font-size: 1.2em; cursor: pointer; }
#players .pl { background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: .5em .7em; margin-bottom: .5em; font-size: .9em; color: var(--ink2); }
#players .pl.is-turn { border-color: var(--bronze); border-width: 1.5pt; box-shadow: 0 0 0 2px rgba(185,138,47,.35); }
#players .pl.disc { opacity: .5; }
.phand { float: right; color: var(--muted); }
.pobj { font-size: .78em; font-style: italic; color: var(--bronze); margin-top: .2em; }
#logwrap { background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: .6em; }
#log { font-size: .84em; max-height: 46vh; overflow-y: auto; }
#log div { padding: .25em 0; border-bottom: 1px dotted #c9b98f; color: var(--ink2); }

/* ---------- hand cards (shared) ---------- */
.card { width: 132px; aspect-ratio: 5/7; display: flex; flex-direction: column; overflow: hidden; background: var(--parch2); color: var(--ink); border-radius: 10px; padding: .45em; cursor: pointer; border: 1.5pt solid var(--gold); font-size: .8em; transition: transform .12s; box-shadow: 0 3px 10px rgba(122,92,34,.18); }
.card:hover { transform: translateY(-4px); }
.card.sel { border-color: var(--bronze); box-shadow: 0 0 0 2px var(--gold), 0 6px 16px rgba(122,92,34,.3); }
.card.sel-disc { border-color: var(--blood); }
.card-kind { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: .68em; letter-spacing: .14em; text-transform: uppercase; color: var(--bronze); }
.card-art { flex: 1 1 auto; min-height: 44px; border-radius: 6px; margin: .3em 0; border: 1px solid rgba(122,92,34,.35); }
.ph-seme { background: radial-gradient(circle, #a8bf8e 20%, #4a6b41 70%); }
.ph-ramo { background: linear-gradient(135deg, #b08a5a, #6b4e2e); }
.ph-foglia { background: radial-gradient(ellipse, #c4ddab, #5d8a4a); }
.ph-azione { background: radial-gradient(circle, #d8b46a, #8a5f2a); }
.card.k-ramo .card-kind { color: #6b4a2a; }
.card.k-foglia .card-kind { color: #4a6b3a; }
.card.k-azione .card-kind { color: #8a5f2a; }
.card-name { font-weight: 700; margin: .15em 0; font-size: .95em; font-family: 'Cormorant Garamond', Georgia, serif; }
.card-text { font-size: .78em; color: var(--muted); }
#hand-count { color: var(--muted); font-size: .85em; font-style: italic; }

/* card detail in modal */
.card.detail { width: 100%; max-width: 300px; margin: 0 auto; cursor: default; }
.card.detail:hover { transform: none; }
.card.detail .card-art { height: 84px; }
.detail-actions { text-align: center; margin-top: .8em; }
.detail-name { text-align: center; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; background: rgba(42,33,24,.62); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1em; }
#modal-box { background: var(--parch2); border: 1.5pt solid var(--bronze); outline: 1px solid var(--gold); outline-offset: 4px; border-radius: 14px; padding: 1.4em; max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; color: var(--ink); box-shadow: 0 16px 60px rgba(42,33,24,.4); }
#modal-close { position: absolute; top: .5em; right: .7em; background: none; border: none; color: var(--muted); font-size: 1.2em; cursor: pointer; }
.pickrow { display: flex; flex-wrap: wrap; gap: .4em; margin: .6em 0; }
.peek { background: var(--panel); border: 1px solid var(--sage); border-radius: 8px; padding: 1em; margin: .8em 0; font-size: 1.1em; color: var(--ink2); }
.scores { width: 100%; border-collapse: collapse; margin: .8em 0; }
.scores th, .scores td { border-bottom: 1px solid #c9b98f; padding: .4em; text-align: left; }
.scores th { font-family: 'Cormorant Garamond', Georgia, serif; letter-spacing: .08em; color: var(--bronze); }
.turnsum { list-style: none; margin: .8em 0; padding: 0; text-align: left; }
.turnsum li { padding: .35em 0; border-bottom: 1px solid rgba(120,90,40,.18); font-size: .95em; }
.turnsum li:last-child { border-bottom: none; }

@media (max-width: 900px) {
  #tpagedots { display: none; }
  #hand .card, #focus-layer .card { font-size: .72em; }
  #hand .card-art, #focus-layer .card-art { height: 40px; }
  #hand .card-name, #focus-layer .card-name { font-size: .85em; }
  .tcard { min-width: 104px; }
  #hud-obj { display: none; }
}

/* build stamp, always visible */
#app-version {
  position: fixed; top: .5em; right: .7em; z-index: 50;
  font-size: .72em; letter-spacing: .04em;
  color: var(--bronze); opacity: .6; pointer-events: none;
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600;
}

/* guide modal: witch signs + aid card */
.gwitches { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; margin: .6em 0 1em; }
.gwitch { background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: .5em .7em; line-height: 1.5; color: var(--ink2); }
.gwitch small { color: var(--muted); }
#btn-guide { flex-shrink: 0; }

/* solo mode: bot lobby row + thinking indicator */
.solorow { display: flex; align-items: center; justify-content: center; gap: .8em; flex-wrap: wrap; }
.solocount { display: inline-flex; align-items: center; gap: .4em; font-size: .9em; color: var(--ink2); }
.solocount select { font: inherit; padding: .3em .5em; border-radius: 8px; border: 1px solid var(--bronze); background: var(--parch2); color: var(--ink); }
.bot-thinking { font-style: italic; color: var(--bronze); animation: botpulse 1.1s ease-in-out infinite; }
@keyframes botpulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
#players .pl.is-bot { border-style: dashed; }
/* corner back: swaps the hand fan between playing cards and objectives */
#obj-back.is-cards { background: linear-gradient(160deg, #43331c 0%, #2a1f10 60%, #1d150a 100%); color: var(--gold); }

.confirm-title { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 1.25em; color: var(--bronze); text-align: center; margin: .2em 0 .6em; }

/* ============ context hint bar (under HUD) ============ */
.hintbar { background: rgba(28,18,6,.92); border-bottom: 1px solid var(--bronze); color: var(--parch);
  padding: .45em .9em; font-size: .95em; line-height: 1.35; }
.hintbar.hidden { display: none; }
/* tutorial takes over the hint bar */
.hintbar.tut { background: #1c1206; border-bottom: 2px solid var(--gold); display: flex; gap: .6em; align-items: center; }
.hintbar .tut-step { background: var(--bronze); color: #241708; border-radius: 999px; font-size: .78em;
  padding: .15em .7em; white-space: nowrap; }
.hintbar .tut-text { flex: 1; }
.hintbar .tut-skip { color: var(--gold); text-decoration: underline; font-size: .85em; white-space: nowrap; cursor: pointer; }
.hintbar #tut-next { white-space: nowrap; padding: .4em 1em; font-size: .9em; }

/* ============ tutorial coach-mark ring ============ */
#tut-ring { position: fixed; z-index: 60; pointer-events: none; border: 3px solid var(--gold);
  border-radius: 12px; display: none; animation: tut-pulse 1.6s infinite; }
/* tutorial: when the coached target is outside the hand (deck, trees, buttons),
   take the hand layer out of the hit-test path — the fan strip / cards can
   visually overlap table targets and would eat the tap while the ring looks
   perfectly placed. The tutorial guard already blocks hand taps with a nudge. */
#board.tut-nohand #handstack { pointer-events: none !important; }
#board.tut-nohand #hand .card { pointer-events: none !important; }
#board.tut-nohand #obj-back { pointer-events: none !important; }
@keyframes tut-pulse {
  0% { box-shadow: 0 0 0 0 rgba(200,149,74,.75); }
  70% { box-shadow: 0 0 0 14px rgba(200,149,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(200,149,74,0); }
}

/* ============ phase banners ============ */
.bcard { text-align: center; max-width: 340px; }
.bcard .kicker { color: var(--bronze); letter-spacing: .12em; font-size: .95em; margin-bottom: .3em; }
.bcard h3 { margin: .2em 0 .4em; font-weight: normal; }
.bcard p { line-height: 1.5; margin: .4em 0; }
.bcard p.next { font-style: italic; opacity: .85; }
.bcard .btnrow { display: flex; gap: .6em; justify-content: center; margin: .8em 0 .4em; flex-wrap: wrap; }
