/* 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); }

/* ---------- 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; }

/* ---------- quadrant stage ---------- */
#screen-game { display: flex; flex-direction: column; height: 100dvh; }
#screen-game.hidden { display: none; }
#qviewport { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; touch-action: pan-y; }
#stage { position: absolute; top: 0; left: 0; display: grid; gap: 10px; transition: transform .38s cubic-bezier(.3,.7,.3,1); will-change: transform; }
.quad { overflow-y: auto; overflow-x: hidden; background:
    radial-gradient(700px 420px at 50% 0%, rgba(255,253,244,.7), rgba(255,253,244,0) 70%),
    var(--parch);
  border: 1px solid var(--gold); border-radius: 12px; padding: .7em .8em 3.2em; -webkit-overflow-scrolling: touch; }
.q-title { display: flex; justify-content: space-between; align-items: baseline; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 1.05em; letter-spacing: .18em; text-transform: uppercase; color: var(--bronze); border-bottom: 1px solid var(--gold); padding-bottom: .3em; margin-bottom: .6em; }
.q-title span:last-child { font-size: .72em; letter-spacing: .06em; color: var(--muted); font-style: italic; text-transform: none; }

/* quadrant dots */
#qnav { position: absolute; left: 50%; bottom: .55em; transform: translateX(-50%); display: flex; gap: .35em; background: rgba(42,33,24,.82); border: 1px solid var(--gold); border-radius: 999px; padding: .3em .45em; z-index: 6; }
#qnav button { background: transparent; border: none; color: #cbb98d; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; font-size: .82em; letter-spacing: .05em; padding: .35em .7em; border-radius: 999px; cursor: pointer; white-space: nowrap; }
#qnav button.on { background: var(--gold); color: #2a2118; }

/* ---------- thrones (compass) ---------- */
#thrones { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, auto); gap: .6em; 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: .7em .3em; text-align: center; min-height: 150px; box-shadow: 0 4px 14px rgba(122,92,34,.15); }
.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.6em; color: var(--muted); }
.w-skull { font-size: 2.6em; }
.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 { 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 ---------- */
#q-hand { display: flex; flex-direction: column; }
#hand { flex: 1 1 auto; display: flex; justify-content: center; align-items: center; align-content: center; flex-wrap: wrap; perspective: 1000px; padding: 1.2em .4em .6em; min-height: 220px; }
#hand .card { width: 96px; margin: 0 -16px; flex: 0 0 auto; transform-origin: 50% 130%; transform: rotate(var(--a, 0deg)) translateY(var(--y, 0px)); transition: transform .16s ease; }
#hand .card:hover { --y: -14px; }
#hand .card.sel { --y: -18px; }
#hand .card .card-text { display: none; }
#hand .card-art { height: 38px; }
.fan-hint { text-align: center; }

/* ---------- objectives ---------- */
#objectives { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: .6em; align-items: stretch; }
#objectives .card.detail { width: 100%; max-width: 340px; margin: 0 auto; }
.card.k-obiettivo .card-kind { color: var(--sage); }
#obj-choices { display: flex; flex-direction: column; gap: .4em; }

/* ---------- 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; 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 { height: 56px; 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); }

@media (max-width: 900px) {
  #hand .card { width: 78px; margin: 0 -14px; font-size: .72em; }
  #hand .card-art { height: 30px; }
  #hand .card-name { font-size: .85em; }
  .tcard { min-width: 104px; }
  #qnav button { font-size: .72em; padding: .3em .5em; }
  #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; }
