/* Cog & Fortune: a printed board game on a walnut table. Parchment, engraved brass, ink. */
:root {
  --wood-0: #1d110a; --wood-1: #2b1a10; --wood-2: #4a2c1a; --wood-3: #6b4127;
  --paper: #efe2c3; --paper-2: #e4d2a8; --paper-3: #d6bf8b;
  --ink: #2a2018; --ink-2: #5b4a3a; --ink-3: #8a7560;
  --brass: #c4923f; --brass-hi: #f0d18a; --brass-lo: #7a5a25;
  --copper: #a5552f; --verdigris: #2f6d66; --oxblood: #7c2622; --cobalt: #355a8c;
  --display: 'IM Fell English SC', 'Iowan Old Style', Georgia, serif;
  --fell: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --body: 'Libre Caslon Text', 'Iowan Old Style', Georgia, serif;
  --shadow: 0 2px 0 rgba(0,0,0,.25), 0 18px 40px -12px rgba(0,0,0,.65);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--body); color: var(--ink); font-size: 15px; line-height: 1.45;
  background-color: var(--wood-1);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(255,190,120,.10), transparent 60%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.0) 0 7px, rgba(0,0,0,.10) 7px 9px, rgba(255,255,255,.025) 9px 15px),
    repeating-linear-gradient(88deg, rgba(0,0,0,.08) 0 2px, transparent 2px 41px),
    linear-gradient(180deg, var(--wood-2), var(--wood-1) 60%, var(--wood-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }
a { color: inherit; }
kbd { font-family: var(--body); font-size: 12px; border: 1px solid var(--ink-3); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: var(--paper); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--display); font-size: 17px; letter-spacing: .02em;
  padding: 9px 18px; border-radius: 6px; border: 2px solid #3a240f;
  color: #2a1a08; background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, var(--brass-lo));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -2px 0 rgba(0,0,0,.25), 0 3px 0 #3a240f, 0 6px 12px rgba(0,0,0,.35);
  text-shadow: 0 1px 0 rgba(255,240,200,.6);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 #3a240f, 0 3px 6px rgba(0,0,0,.35); }
.btn:disabled { filter: grayscale(.7) brightness(.85); opacity: .7; }
.btn.big { font-size: 20px; padding: 12px 22px; }
.btn.small { font-size: 14px; padding: 5px 12px; }
.btn.alt { background: linear-gradient(180deg, #5fa59a, var(--verdigris) 55%, #1c4540); color: #f3ead2; text-shadow: 0 1px 0 rgba(0,0,0,.4); border-color: #10302b; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), inset 0 -2px 0 rgba(0,0,0,.25), 0 3px 0 #10302b, 0 6px 12px rgba(0,0,0,.35); }
.btn.ghost { background: transparent; border-color: var(--ink-2); box-shadow: none; color: var(--ink); text-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: rgba(42,32,24,.06); }
.link { background: none; border: 0; padding: 4px 2px; font-family: var(--fell); font-style: italic; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link.center { display: block; margin: 10px auto 0; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; color: var(--brass-hi);
  border-bottom: 1px solid rgba(240,209,138,.18);
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.1));
}
.wordmark { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--display); font-size: 22px; letter-spacing: .02em; text-shadow: 0 1px 0 #000; }
.wordmark svg { color: var(--brass); filter: drop-shadow(0 1px 0 #000); }
.wordmark i { font-family: var(--fell); color: var(--brass); }
.room-plate { font-family: var(--display); padding: 3px 12px; border-radius: 4px; color: #2a1a08; background: linear-gradient(180deg, var(--brass-hi), var(--brass)); border: 1px solid #3a240f; font-size: 15px; }
.room-plate b { letter-spacing: .18em; }
.top-actions { margin-left: auto; display: flex; gap: 14px; }
.top-actions .link { color: var(--paper-2); font-size: 14px; }

.screen { padding: 22px 20px 40px; }

/* ---------- home ---------- */
#home { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
.lid {
  position: relative; padding: 26px 30px 30px; border-radius: 6px; text-align: center;
  background: radial-gradient(ellipse at 50% 35%, #f6ebcf, var(--paper) 55%, var(--paper-3));
  border: 10px solid var(--oxblood); outline: 2px solid #2a1410; outline-offset: -4px;
  box-shadow: inset 0 0 0 2px #e7c27b, inset 0 0 0 6px var(--oxblood), inset 0 0 0 7px #e7c27b, 0 4px 0 #1a0c08, 0 30px 60px -10px rgba(0,0,0,.75);
  transform: rotate(-1.2deg);
}
.lid-art svg { width: 100%; height: auto; display: block; }
.lid .title { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 7vw, 76px); line-height: .95; margin: 6px 0 4px; color: var(--ink); letter-spacing: .01em; text-shadow: 2px 2px 0 rgba(196,146,63,.55); }
.lid .title span { font-family: var(--fell); font-style: italic; color: var(--oxblood); }
.subtitle { font-family: var(--fell); font-style: italic; font-size: 21px; margin: 0; color: var(--ink-2); }
.meta { font-size: 13px; color: var(--ink-2); margin: 12px 0 0; border-top: 1px solid var(--ink-3); border-bottom: 1px solid var(--ink-3); padding: 6px 0; letter-spacing: .02em; }
.register {
  background: var(--paper); border-radius: 4px; padding: 22px 22px 18px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, rgba(53,90,140,.13) 27px 28px);
  border-left: 3px double rgba(124,38,34,.35);
  transform: rotate(.6deg);
}
.field { display: block; margin-bottom: 16px; }
.field > span, .lbl { display: block; font-family: var(--display); font-size: 16px; margin-bottom: 6px; color: var(--ink); }
input#homeName, #joinCode {
  width: 100%; font-family: var(--fell); font-size: 22px; padding: 6px 4px; border: 0; border-bottom: 2px solid var(--ink);
  background: transparent; color: var(--ink); outline: none;
}
input#homeName:focus, #joinCode:focus { border-bottom-color: var(--oxblood); }
input.nudge { animation: nudge .5s; }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.picks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 4px; border: 1.5px solid transparent; border-radius: 6px; background: transparent; font-size: 11px; color: var(--ink-2); }
.pick:hover:not(:disabled) { background: rgba(42,32,24,.06); }
.pick.on { border-color: var(--ink); background: rgba(196,146,63,.18); color: var(--ink); }
.pick:disabled { opacity: .3; }
.picks.small { grid-template-columns: repeat(6, auto); justify-content: start; }
.picks.small .pick { padding: 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); background: var(--c); box-shadow: inset -3px -4px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.25); position: relative; }
.swatch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.swatch.on { outline: 3px solid var(--oxblood); outline-offset: 2px; }
.swatch:disabled { opacity: .25; }
.swatches.small .swatch { width: 26px; height: 26px; }
.home-btns { display: grid; gap: 10px; margin: 18px 0 14px; }
.join-row { display: flex; gap: 10px; align-items: end; }
#joinCode { width: 110px; text-transform: uppercase; letter-spacing: .3em; font-family: var(--display); text-align: center; }
.invite { background: var(--oxblood); color: var(--paper); padding: 12px 14px; border-radius: 4px; margin-bottom: 16px; text-align: center; }
.invite p { margin: 0 0 8px; font-family: var(--fell); font-size: 18px; }
.invite b { font-family: var(--display); letter-spacing: .2em; }
.foot { grid-column: 1 / -1; text-align: center; color: var(--paper-3); font-size: 13px; font-family: var(--fell); font-style: italic; margin-top: 10px; }

/* ---------- lobby ---------- */
#lobby { display: flex; justify-content: center; }
.invitation {
  width: min(760px, 100%); text-align: center; padding: 28px 30px 26px; border-radius: 4px;
  background: radial-gradient(ellipse at 50% 20%, #f7eed6, var(--paper) 60%, var(--paper-2));
  box-shadow: inset 0 0 0 8px var(--paper), inset 0 0 0 9px var(--ink-2), inset 0 0 0 12px var(--paper), inset 0 0 0 13px var(--ink-3), var(--shadow);
}
.kicker { font-family: var(--fell); font-style: italic; margin: 0; font-size: 18px; color: var(--ink-2); }
.invitation h2 { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 5vw, 44px); margin: 0 0 10px; }
.code-plate { display: inline-flex; align-items: baseline; gap: 12px; padding: 8px 22px; margin-bottom: 10px; border-radius: 6px; background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, var(--brass-lo)); border: 2px solid #3a240f; box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 3px 0 #3a240f; }
.code-plate span { font-family: var(--fell); font-style: italic; }
.code-plate b { font-family: var(--display); font-size: 40px; letter-spacing: .25em; line-height: 1; text-shadow: 0 1px 0 rgba(255,240,200,.6); }
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 16px; }
.seat { position: relative; min-height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; border-radius: 6px; border: 1.5px solid var(--ink-2); background: rgba(255,255,255,.25); }
.seat.me { border: 2px solid var(--oxblood); background: rgba(196,146,63,.16); }
.seat.empty { border-style: dashed; border-color: var(--ink-3); color: var(--ink-3); font-family: var(--fell); font-style: italic; }
.seat-nm { font-family: var(--display); font-size: 17px; line-height: 1.1; }
.seat-sub { font-size: 12px; color: var(--ink-2); font-style: italic; }
.seat .x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 20px; color: var(--ink-2); }
.lobby-me { display: flex; gap: 24px; justify-content: center; align-items: center; flex-wrap: wrap; padding: 10px 0 14px; border-top: 1px solid var(--ink-3); border-bottom: 1px solid var(--ink-3); margin-bottom: 14px; }
.lobby-me .lbl, .cfg .lbl { font-size: 14px; margin-bottom: 4px; }
.cfg { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { font-family: var(--display); font-size: 14px; padding: 4px 12px; border-radius: 4px; border: 1.5px solid var(--ink-2); background: transparent; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:disabled:not(.on) { opacity: .5; }
.eta { font-family: var(--fell); font-style: italic; color: var(--ink-2); margin: 14px 0 6px; }
.lobby-btns { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wait { font-family: var(--fell); font-style: italic; font-size: 18px; margin: 4px 0; }

/* ---------- the table ---------- */
#game { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; max-width: 1480px; margin: 0 auto; padding-top: 14px; align-items: start; }
.table { display: flex; justify-content: center; }
.board { position: relative; width: min(100%, calc(100vh - 100px)); aspect-ratio: 1; filter: drop-shadow(0 4px 0 #1a0c08) drop-shadow(0 26px 30px rgba(0,0,0,.6)); }
.board-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board-svg text { font-family: var(--display); fill: #2a2018; }
.plate-n { font-size: 17px; fill: #3d2a10 !important; }
.plate-start { font-size: 13px; letter-spacing: .06em; }
.plate-q { font-family: var(--fell) !important; font-size: 17px; fill: #5e2a14 !important; font-weight: 700; }
.district { font-family: var(--fell) !important; font-style: italic; font-size: 19px; fill: #4a3826 !important; letter-spacing: .02em; }
.banner { font-size: 26px; fill: #f3e3bd !important; letter-spacing: .04em; }
.arch-text { font-size: 17px; fill: #f3e3bd !important; letter-spacing: .05em; }
.numeral { font-size: 15px; }
.clock-label { font-size: 12px; letter-spacing: .25em; fill: #5b4a3a !important; }
.clock-round { font-size: 30px; fill: #7c2622 !important; }
.tiny-caps { font-size: 15px; letter-spacing: .08em; }
.tiny-italic { font-family: var(--fell) !important; font-style: italic; font-size: 13px; }
#hourHand, #minHand { transition: transform .6s cubic-bezier(.3,1.4,.5,1); }
.spin { transform-box: fill-box; transform-origin: center; animation: spin var(--spd, 30s) linear infinite; }
.spin.rev { animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.board-svg.busy .spin { animation-duration: calc(var(--spd) / 6); }
.float { animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.plate.flash { animation: flash .9s ease-out; transform-box: fill-box; }
@keyframes flash { 30% { filter: brightness(1.5) drop-shadow(0 0 6px #fff3c4); } }
.pawn { will-change: transform; }
.pawn .pawn-body { transform-box: fill-box; transform-origin: 50% 100%; }
.pawn.active .pawn-shadow { fill: #f0d18a; opacity: .9; animation: halo 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { 50% { transform: scale(1.35); opacity: .45; } }
.pawn.shake .pawn-body { animation: shake .38s; }
@keyframes shake { 20% { transform: rotate(-14deg); } 45% { transform: rotate(12deg); } 70% { transform: rotate(-6deg); } }

.ov { position: absolute; inset: 0; pointer-events: none; }
.plaque {
  position: absolute; left: 50%; top: 13.2%; transform: translate(-50%, 0); display: flex; align-items: center; gap: 8px;
  padding: 4px 14px 4px 8px; border-radius: 4px; background: var(--paper); border: 1.5px solid var(--ink);
  font-family: var(--display); font-size: clamp(13px, 1.5vw, 18px); white-space: nowrap; box-shadow: 0 3px 8px rgba(0,0,0,.25);
}
.plaque:empty { display: none; }
.plaque .pawn-icon { width: 18px; height: auto; }
.plaque.mine { background: var(--oxblood); color: var(--paper); border-color: #2a1410; }
.plaque.pop { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: translate(-50%, 0) scale(.6); opacity: 0; } }
.deck { position: absolute; left: 40%; top: 71%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.deck .stack { position: relative; width: clamp(48px, 7.4%, 82px); }
.deck .stack .card { width: 100%; box-shadow: 2px 2px 0 #c9b78f, 4px 4px 0 #b6a27a, 6px 6px 0 #9e8a63, 8px 10px 14px rgba(0,0,0,.35); }
.deck span { font-family: var(--fell); font-style: italic; font-size: clamp(10px, 1.1vw, 13px); color: var(--ink-2); background: rgba(234,217,176,.85); padding: 0 6px; border-radius: 3px; white-space: nowrap; }
.discard { position: absolute; left: 60%; top: 68.6%; width: clamp(48px, 7.4%, 82px); transform: translate(-50%, -50%) rotate(6deg); }
.discard .card { width: 100%; box-shadow: 3px 4px 8px rgba(0,0,0,.3); }
.empty-slot { aspect-ratio: 5/7; border: 1.5px dashed var(--ink-3); border-radius: 6px; display: grid; place-items: center; font-family: var(--fell); font-style: italic; font-size: 11px; color: var(--ink-3); transform: rotate(-6deg); }

/* dice */
.dice { position: absolute; left: 50%; top: 61%; transform: translate(-50%, -50%); display: flex; gap: 14px; align-items: center; opacity: 0; transition: opacity .3s; }
.dice.show { opacity: 1; }
.dice.dim { opacity: .0; }
.die { width: clamp(38px, 5.6vw, 60px); aspect-ratio: 1; perspective: 400px; }
.cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face {
  position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 14%;
  background: radial-gradient(circle at 30% 25%, #fffaf0, #efe4c9 60%, #d8c7a0); border: 1.5px solid #6d5c43; border-radius: 16%;
  box-shadow: inset 0 0 8px rgba(120,90,40,.35);
}
.face i { display: block; }
.face i.pip { margin: 15%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #a8403e, #5e1716); box-shadow: inset 0 1px 1px rgba(0,0,0,.5); }
.die { --h: calc(clamp(38px, 5.6vw, 60px) / 2); }
.f1 { transform: translateZ(var(--h)); }
.f6 { transform: rotateY(180deg) translateZ(var(--h)); }
.f3 { transform: rotateY(90deg) translateZ(var(--h)); }
.f4 { transform: rotateY(-90deg) translateZ(var(--h)); }
.f2 { transform: rotateX(90deg) translateZ(var(--h)); }
.f5 { transform: rotateX(-90deg) translateZ(var(--h)); }
.dice-total { font-family: var(--display); font-size: clamp(22px, 3vw, 34px); color: var(--oxblood); text-shadow: 0 1px 0 #fff6dd; min-width: 0; }
.dice-total:empty { display: none; }
.dice-mods { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; white-space: nowrap; font-family: var(--fell); font-style: italic; font-size: 14px; color: var(--paper); background: var(--ink); padding: 0 8px; border-radius: 3px; }
.dice-mods:empty { display: none; }

/* card reveal */
.reveal { position: absolute; left: 50%; top: 47%; width: clamp(140px, 25%, 250px); transform: translate(-50%, -50%) scale(.3); opacity: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.reveal.show { animation: rv-in .32s cubic-bezier(.25,1.3,.5,1) forwards; }
.reveal.away { animation: rv-out .26s ease-in forwards; }
.reveal.to-hand { animation: rv-hand .26s ease-in forwards; }
@keyframes rv-in { from { transform: translate(-90%, 40%) scale(.3) rotate(-12deg); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes rv-out { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(10%, 30%) scale(.3) rotate(10deg); opacity: 0; } }
@keyframes rv-hand { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(160%, -20%) scale(.4); opacity: 0; } }
.flip { width: 100%; perspective: 1000px; }
.flip-in { position: relative; width: 100%; aspect-ratio: 5/7; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,1.3,.5,1); }
.flip.flipped .flip-in { transform: rotateY(180deg); }
.flip.facedown .flip-in { transform: rotateY(0); }
.side-b, .side-f { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.side-f { transform: rotateY(180deg); }
.flip.facedown .side-f { display: none; }
.side-b .card, .side-f .card { width: 100%; height: 100%; box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.cap { font-family: var(--display); font-size: clamp(13px, 1.5vw, 17px); color: var(--paper); background: var(--ink); padding: 3px 12px; border-radius: 4px; white-space: nowrap; box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.stamp {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) rotate(-14deg) scale(2); opacity: 0;
  font-family: var(--display); font-size: clamp(20px, 2.4vw, 30px); letter-spacing: .12em; padding: 2px 12px; border: 3px solid currentColor; border-radius: 4px;
  color: var(--oxblood); background: rgba(239,226,195,.6); mix-blend-mode: multiply;
}
.stamp.boon { color: var(--verdigris); }
.stamp.good { color: var(--verdigris); }
.flip.flipped .stamp { animation: stamp .25s .45s cubic-bezier(.3,1.5,.5,1) forwards; }
@keyframes stamp { to { transform: translate(-50%, -50%) rotate(-14deg) scale(1); opacity: .92; } }

/* bubbles + confetti */
.bubbles { position: absolute; inset: 0; overflow: visible; }
.bubble {
  position: absolute; transform: translate(-50%, calc(-100% - 50px)); white-space: nowrap; padding: 3px 10px; border-radius: 12px;
  background: var(--paper); border: 1.5px solid var(--ink); font-family: var(--display); font-size: clamp(12px, 1.4vw, 16px); box-shadow: 0 3px 8px rgba(0,0,0,.3);
  animation: bub 1.9s ease-out forwards;
}
.bubble::after { content: ''; position: absolute; left: 50%; top: 100%; width: 8px; height: 8px; background: inherit; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: translate(-50%, -4px) rotate(45deg); }
.bubble.bad { background: #f3d6c8; color: var(--oxblood); }
.bubble.good { background: #d4e6dc; color: #1c4540; }
.bubble.say { font-family: var(--fell); font-style: italic; background: #fffaf0; }
@keyframes bub { 0% { opacity: 0; margin-top: 10px; } 12% { opacity: 1; margin-top: 0; } 80% { opacity: 1; } 100% { opacity: 0; margin-top: -14px; } }
.confetti { position: absolute; animation: conf var(--d) cubic-bezier(.2,.6,.4,1) forwards; }
.confetti.puff { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.9), rgba(255,255,255,0) 70%); }
@keyframes conf { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

/* ---------- side panel ---------- */
.side { display: flex; flex-direction: column; gap: 12px; }
.ledger { background: var(--paper); border-radius: 4px; box-shadow: var(--shadow); padding: 6px; }
.row { position: relative; display: grid; grid-template-columns: 18px 28px 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 3px; }
.row + .row { border-top: 1px solid rgba(91,74,58,.25); }
.row.active { background: rgba(196,146,63,.25); box-shadow: inset 3px 0 0 var(--oxblood); }
.row.me .nm { text-decoration: underline; text-decoration-color: var(--oxblood); text-underline-offset: 3px; }
.row.winner { background: rgba(47,109,102,.18); }
.place { font-family: var(--display); font-size: 18px; color: var(--ink-2); text-align: center; }
.row .pawn-icon { width: 24px; height: auto; }
.nm { font-family: var(--display); font-size: 16px; line-height: 1.1; }
.tag { font-family: var(--fell); font-style: italic; font-size: 12px; color: var(--ink-2); }
.sub { font-size: 12px; color: var(--ink-2); }
.gauge { position: relative; height: 6px; margin-top: 4px; border-radius: 3px; background: rgba(91,74,58,.2); box-shadow: inset 0 1px 1px rgba(0,0,0,.2); }
.gauge i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: linear-gradient(180deg, var(--brass-hi), var(--brass-lo)); transition: width .5s; }
.gauge b { position: absolute; top: -2px; bottom: -2px; width: 1.5px; background: var(--ink); opacity: .55; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.flag { font-size: 11px; padding: 0 6px; border-radius: 3px; border: 1px solid var(--ink-2); font-style: italic; }
.flag.bad { color: var(--oxblood); border-color: var(--oxblood); background: rgba(124,38,34,.08); }
.flag.good { color: var(--verdigris); border-color: var(--verdigris); background: rgba(47,109,102,.08); }
.hand-mini { display: flex; gap: 2px; }
.hand-mini i { width: 10px; height: 14px; border-radius: 2px; border: 1px dashed var(--ink-3); }
.hand-mini i.has { border: 1px solid #10302b; background: linear-gradient(135deg, #3f7f74, #1c4540); }
.timer { position: absolute; left: 8px; right: 8px; bottom: 1px; height: 2px; }
.timer i { display: block; height: 100%; background: var(--oxblood); width: 100%; transition: width .2s linear; }

.controls { display: flex; gap: 10px; align-items: stretch; }
.lever-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 64px; padding: 8px 16px;
  font-family: var(--display); font-size: 22px; color: #2a1a08; border-radius: 8px; border: 2px solid #3a240f;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 50%, var(--brass-lo));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -3px 0 rgba(0,0,0,.25), 0 4px 0 #3a240f, 0 10px 18px rgba(0,0,0,.4);
  text-shadow: 0 1px 0 rgba(255,240,200,.6); transition: transform .08s, filter .2s;
}
.lever-btn:not(:disabled) { animation: ready 1.8s ease-in-out infinite; }
@keyframes ready { 50% { filter: brightness(1.12); } }
.lever-btn:active:not(:disabled) { transform: translateY(3px); }
.lever-btn:disabled { filter: grayscale(.8) brightness(.8); opacity: .65; }
.lever { position: relative; width: 16px; height: 42px; border-radius: 8px; background: #3a240f; box-shadow: inset 0 0 0 3px #7a5a25; }
.lever i { position: absolute; left: 50%; top: 2px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e46a5a, var(--oxblood) 60%, #3c0e0c); box-shadow: 0 2px 3px rgba(0,0,0,.5); transition: top .2s; }
.lever.pull i { animation: pull .5s; }
@keyframes pull { 40% { top: 22px; } }
#endBtn { flex: 1; font-size: 20px; }
.say-wrap { position: relative; display: flex; }
.say-wrap .btn { color: var(--paper-2); border-color: var(--paper-3); }
.say-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; background: var(--paper); border-radius: 4px; box-shadow: var(--shadow); padding: 4px; display: grid; min-width: 150px; }
.say-menu button { text-align: left; background: none; border: 0; padding: 6px 10px; font-family: var(--fell); font-style: italic; font-size: 16px; border-radius: 3px; }
.say-menu button:hover { background: rgba(196,146,63,.25); }
.hint { margin: -2px 0 0; color: var(--paper-2); font-family: var(--fell); font-style: italic; font-size: 15px; min-height: 1.4em; }
.hand-wrap h3, .gz-mast { font-family: var(--display); font-weight: 400; color: var(--brass-hi); margin: 0 0 6px; font-size: 17px; text-shadow: 0 1px 0 #000; }
.hand { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-height: 60px; }
.empty-hand, .stands { grid-column: 1 / -1; margin: 0; padding: 12px; border: 1.5px dashed rgba(240,209,138,.35); border-radius: 6px; color: var(--paper-3); font-style: italic; font-size: 14px; text-align: center; }
.hand-card { position: relative; padding: 0; border: 0; background: none; text-align: left; transition: transform .18s cubic-bezier(.3,1.4,.5,1); }
.hand-card .card { width: 100%; }
.hand-card.ok:not(:disabled):hover { transform: translateY(-8px) rotate(-1.5deg); }
.hand-card:disabled { cursor: default; }
.hand-card:not(.ok) .card { filter: saturate(.55) brightness(.93); }
.hand-card.ok:not(:disabled) .card { box-shadow: 0 0 0 2px var(--brass-hi), 0 0 0 4px #3a240f, 0 10px 18px rgba(0,0,0,.45); }
.hc-tag { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-family: var(--display); font-size: 12px; padding: 0 8px; border-radius: 3px; background: var(--ink); color: var(--paper-2); white-space: nowrap; }
.hand-card.ok:not(:disabled) .hc-tag { background: var(--oxblood); color: var(--paper); }
.hand-card.passive .hc-tag { background: var(--verdigris); color: var(--paper); }

.gazette-wrap { background: var(--paper); border-radius: 3px; box-shadow: var(--shadow); padding: 10px 12px; background-image: linear-gradient(90deg, rgba(0,0,0,.04), transparent 20%, transparent 80%, rgba(0,0,0,.04)); }
.gz-mast { color: var(--ink); text-shadow: none; border-bottom: 3px double var(--ink); padding-bottom: 4px; font-size: 21px; text-align: center; }
.gz-mast span { font-family: var(--fell); font-style: italic; font-size: 13px; color: var(--ink-2); }
.gazette { max-height: 300px; overflow-y: auto; font-size: 13.5px; padding-right: 4px; }
.gz { margin: 0; padding: 5px 0; border-bottom: 1px solid rgba(91,74,58,.2); animation: gz-in .4s ease-out; }
@keyframes gz-in { from { background: rgba(196,146,63,.35); } }
.gz.round { font-family: var(--display); text-align: center; color: var(--ink-2); font-size: 13px; letter-spacing: .14em; border-bottom: 0; padding: 8px 0 2px; }
.gz.round::before, .gz.round::after { content: ' — '; }
.gz.big .hl, .hl { font-family: var(--display); font-size: 15px; }
.gz.say { color: var(--ink-2); }
.quote { font-family: var(--fell); font-style: italic; font-size: 15px; color: var(--ink); }
.who { font-weight: 700; font-family: var(--body); }
.who::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); border: 1px solid var(--ink); margin-right: 4px; vertical-align: 1px; }
.who.mine { text-decoration: underline; text-decoration-color: var(--oxblood); }
.cn { font-family: var(--fell); font-style: italic; font-weight: 400; }
.cn.mishap { color: var(--oxblood); }
.cn.boon { color: var(--verdigris); }
.eff { color: var(--ink-2); font-size: 12.5px; }
#gameLeave { color: var(--paper-3); align-self: center; }

/* ---------- cards ---------- */
.card { position: relative; aspect-ratio: 5/7; border-radius: 7px; padding: 5%; background: #f5ecd5; color: var(--ink); box-shadow: 0 2px 4px rgba(0,0,0,.25); container-type: inline-size; user-select: none; }
.card-in { position: relative; height: 100%; border: 1.5px solid currentColor; border-radius: 4px; outline: .7px solid currentColor; outline-offset: -4px; display: flex; flex-direction: column; align-items: center; padding: 6% 7% 5%; text-align: center; background: radial-gradient(ellipse at 50% 35%, #fbf5e4, #efe2c3 70%); }
.card.boon { color: #1d4a44; }
.card.mishap { color: #6a1f1b; }
.card .cc { position: absolute; width: 10%; color: currentColor; }
.card .cc:nth-child(1) { left: 3%; top: 2.5%; }
.card .cc:nth-child(2) { right: 3%; top: 2.5%; transform: scaleX(-1); }
.card .cc:nth-child(3) { right: 3%; bottom: 2.5%; transform: scale(-1); }
.card .cc:nth-child(4) { left: 3%; bottom: 2.5%; transform: scaleY(-1); }
.card-kind { font-family: var(--display); font-size: 9cqw; letter-spacing: .2em; padding: 0 8%; border-bottom: 1px solid currentColor; line-height: 1.3; }
.card-art { width: 62%; aspect-ratio: 1; margin: 5% 0 3%; color: var(--ink); }
.card.boon .card-art { color: #163d38; }
.card.mishap .card-art { color: #571814; }
.card-art svg { width: 100%; height: 100%; display: block; }
.card-name { font-family: var(--display); font-size: 11.2cqw; line-height: 1.02; color: var(--ink); }
.card-text { font-size: 7.2cqw; line-height: 1.25; margin-top: 4%; color: var(--ink); }
.card-flavor { font-family: var(--fell); font-style: italic; font-size: 6.3cqw; line-height: 1.2; margin-top: auto; color: var(--ink-2); }
.card.back { background: #20403b; color: #d9b56c; }
.card.back .card-in { background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 6px, transparent 6px 12px), radial-gradient(circle at 50% 50%, #2f5f58, #173430 75%); padding: 0; justify-content: center; }
.card.back svg { width: 92%; height: auto; }
.card.mini .card-flavor, .card.mini .card-text { display: none; }
.card.mini .card-art { width: 70%; margin: 8% 0 6%; }
.card.mini .card-name { font-size: 13cqw; }
.card.mini .card-kind { font-size: 11cqw; }

/* ---------- modal sheets ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20,10,4,.6); }
.sheet { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 24px; border-radius: 4px; background: var(--paper); box-shadow: inset 0 0 0 6px var(--paper), inset 0 0 0 7px var(--ink-3), var(--shadow); animation: sheet-in .25s cubic-bezier(.3,1.3,.5,1); text-align: center; }
.sheet.wide { width: min(860px, 100%); }
@keyframes sheet-in { from { transform: translateY(20px) scale(.97); opacity: 0; } }
.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 0 0 4px; }
.sheet h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 18px 0 8px; }
.lede { font-family: var(--fell); font-size: 18px; margin: 0 0 16px; color: var(--ink-2); }
.targets { display: grid; gap: 8px; margin-bottom: 14px; }
.target { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1.5px solid var(--ink-2); border-radius: 6px; background: rgba(255,255,255,.3); text-align: left; }
.target:hover { background: rgba(196,146,63,.25); border-color: var(--ink); }
.target span { display: flex; flex-direction: column; }
.target b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.target small { color: var(--ink-2); font-style: italic; }
.valves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.valve-opt { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border: 1.5px solid var(--ink-2); border-radius: 50% 50% 8px 8px / 40% 40% 8px 8px; background: radial-gradient(circle at 50% 30%, #fbf5e4, var(--paper-2)); }
.valve-opt:hover { border-color: var(--oxblood); background: radial-gradient(circle at 50% 30%, #fff, #f0d18a); }
.valve-opt b { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; }
.valve-opt small { font-size: 11.5px; color: var(--oxblood); font-style: italic; min-height: 1.3em; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.toss-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 6px 0 14px; }
.rules { text-align: left; padding-left: 22px; margin: 6px 0 4px; }
.rules li { margin-bottom: 6px; }
.rules b { font-family: var(--display); font-weight: 400; font-size: 16px; }
.card-ref { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 12px; }
.ref { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--display); font-size: 13px; color: var(--ink-2); }
.ref .card { width: 100%; }
.keys { font-size: 13px; color: var(--ink-2); }

/* final edition */
.modal[data-kind="final"] .sheet { background: #f1e8d0; padding: 18px 22px 20px; }
.paper { text-align: left; }
.mast { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 4px double var(--ink); padding-bottom: 4px; font-family: var(--fell); font-style: italic; font-size: 12px; color: var(--ink-2); }
.mast h1 { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 6vw, 52px); margin: 0; color: var(--ink); letter-spacing: .02em; text-align: center; }
.extra { text-align: center; font-family: var(--display); font-size: 13px; letter-spacing: .4em; border-bottom: 1px solid var(--ink); padding: 3px 0; }
.headline { font-family: var(--display); font-weight: 400; font-size: clamp(26px, 4.6vw, 44px); line-height: 1; text-align: center; margin: 14px 0 6px; }
.dek { font-family: var(--fell); font-style: italic; text-align: center; font-size: 17px; margin: 0 0 12px; color: var(--ink-2); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; border-top: 1px solid var(--ink); padding-top: 4px; }
.cols > div + div { border-left: 1px solid var(--ink); padding-left: 20px; }
.cols h3 { margin: 8px 0 6px; font-size: 18px; }
.standings { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.standings li { counter-increment: s; display: grid; grid-template-columns: 22px 20px 1fr; column-gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dotted var(--ink-3); }
.standings li::before { content: counter(s); font-family: var(--display); font-size: 18px; }
.standings li.me b { text-decoration: underline; text-decoration-color: var(--oxblood); }
.standings b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.standings span { grid-column: 3; font-size: 12px; color: var(--ink-2); font-style: italic; }
.standings .pawn-icon { width: 18px; height: auto; grid-row: span 2; }
.awards { list-style: none; padding: 0; margin: 0; }
.awards li { padding: 4px 0; border-bottom: 1px dotted var(--ink-3); display: flex; flex-direction: column; }
.awards b { font-family: var(--display); font-weight: 400; font-size: 16px; }
.awards span { font-size: 13px; color: var(--ink-2); }
.paper .row-btns { margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; z-index: 60; padding: 8px 16px; border-radius: 4px; background: var(--ink); color: var(--paper); font-family: var(--fell); font-size: 17px; box-shadow: 0 8px 20px rgba(0,0,0,.4); transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  #game { grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; }
}
@media (max-width: 860px) {
  .screen { padding: 14px 16px 30px; }
  #home { grid-template-columns: 1fr; }
  .lid, .register { transform: none; }
  #game { grid-template-columns: 1fr; padding-top: 6px; }
  .board { width: 100%; }
  .side { gap: 10px; }
  .gazette { max-height: 220px; }
  .seats { grid-template-columns: repeat(2, 1fr); }
  .card-ref { grid-template-columns: repeat(4, 1fr); }
  .topbar { padding: 8px 16px; gap: 10px; flex-wrap: wrap; }
  .top-actions { gap: 8px; }
  .wordmark span { font-size: 19px; }
  body[data-screen="game"] .side { order: 2; }
}
@media (max-width: 520px) {
  .wordmark span { display: none; }
  .picks { grid-template-columns: repeat(3, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .cols > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--ink); }
  .toss-row { grid-template-columns: repeat(2, 1fr); }
  .invitation { padding: 22px 16px; }
  .code-plate b { font-size: 32px; }
  .lever-btn { font-size: 19px; }
  .mast span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spin, .float, .lever-btn:not(:disabled), .pawn.active .pawn-shadow { animation: none; }
}
