:root {
  --parch: #EFE3C8;
  --parch-2: #E4D3AE;
  --parch-3: #D6C08F;
  --ink: #2B2118;
  --ink-2: #5A4632;
  --sea: #2F5D62;
  --sea-2: #1F4044;
  --black: #1C1C1C;
  --red: #8E2A1E;
  --gold: #B8892E;
  --green: #5B6B3A;
  --omen: #4B3F5E;
  --wood: #3A2A1D;
  --wood-2: #24190F;
  --good: #3F6B2E;
  --bad: #8E2A1E;
  --radius: 6px;
  --head: 'Trirong', 'IM Fell English', serif;
  --body: 'Sarabun', system-ui, sans-serif;
  --fell: 'IM Fell English', 'Trirong', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 0%, #34544f 0%, var(--sea-2) 55%, #13282a 100%) fixed;
  color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.hidden { display: none !important; }
.boot { color: var(--parch); font: 22px var(--head); text-align: center; padding-top: 30vh; }

/* ------------------------------------------------------------ parchment */
.parch {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(120,80,30,.18), transparent 55%),
    var(--parch);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(43,33,24,.25), inset 0 0 28px rgba(110,70,20,.25), 0 6px 18px rgba(0,0,0,.35);
}
.rope { border: 3px double var(--ink-2); }
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.25; }
.fell { font-family: var(--fell); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 4px; border: 1px solid var(--ink);
  background: var(--parch-2); cursor: pointer; font-weight: 600;
  box-shadow: 0 2px 0 var(--ink-2); transition: transform .06s, box-shadow .06s, background .15s;
}
.btn:hover { background: var(--parch-3); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink-2); }
.btn.primary { background: var(--black); color: var(--parch); border-color: var(--black); box-shadow: 0 2px 0 #000; }
.btn.primary:hover { background: #333; }
.btn.red { background: var(--red); color: var(--parch); border-color: #5c180f; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(43,33,24,.4); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=number], select {
  padding: 8px 10px; border: 1px solid var(--ink-2); border-radius: 4px; background: #fbf5e6; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* -------------------------------------------------------------- home */
.home { max-width: 520px; margin: 6vh auto; padding: 0 16px; }
.home .card-title { text-align: center; padding: 28px 24px 18px; }
.home h1 { font-family: var(--fell); font-size: 42px; letter-spacing: .5px; }
.home .sub { font-family: var(--head); color: var(--ink-2); margin-top: 4px; }
.home .body { padding: 6px 24px 24px; display: grid; gap: 14px; }
.home label { font-weight: 600; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; }
.flagpick { display: flex; gap: 6px; flex-wrap: wrap; }
.flagpick button { width: 42px; height: 42px; border-radius: 4px; border: 2px solid transparent; background: var(--black); color: var(--parch); font-size: 20px; cursor: pointer; }
.flagpick button.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184,137,46,.4); }
.flag { display: inline-flex; align-items: center; justify-content: center; background: var(--black); color: var(--parch); border-radius: 3px; padding: 0 4px; min-width: 30px; height: 24px; font-size: 13px; letter-spacing: -2px; flex-shrink: 0; }
.flag.big { min-width: 54px; height: 38px; font-size: 22px; }
.err { color: var(--red); font-weight: 600; min-height: 1.2em; }
.hint { color: var(--ink-2); font-size: 13px; }

/* ------------------------------------------------------------- lobby */
.lobby { max-width: 900px; margin: 4vh auto; padding: 0 16px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.lobby .pane { padding: 20px; }
.code { font: 700 46px/1 var(--fell); letter-spacing: 8px; }
.plist { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,.35); border-radius: 4px; }
.plist .grow { flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #999; flex-shrink: 0; }
.dot.on { background: #4f9a3a; box-shadow: 0 0 6px #6c6; }
.rules-mini { font-size: 14px; }
.rules-mini li { margin-bottom: 4px; }
.seg { display: inline-flex; border: 1px solid var(--ink-2); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--parch); }

/* -------------------------------------------------------------- game */
.game { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--black); color: var(--parch); box-shadow: 0 2px 10px rgba(0,0,0,.5); flex-wrap: wrap; }
.topbar .ship { font: 700 18px var(--fell); }
.topbar .phase { font: 600 16px var(--head); color: #f3d79a; }
.topbar .spacer { flex: 1; }
.topbar .timer { font: 700 18px var(--fell); min-width: 54px; text-align: right; }
.timer.low { color: #ff8f6f; animation: pulse 1s infinite; }
.topbar .btn { background: #2d2d2d; color: var(--parch); border-color: #555; box-shadow: none; }
.cal { display: flex; gap: 3px; }
.cal span { width: 22px; height: 22px; display: grid; place-items: center; font-size: 11px; border: 1px solid #555; border-radius: 3px; color: #bbb; }
.cal span.storm { border-color: #4b6a8a; }
.cal span.now { background: var(--gold); color: var(--black); border-color: var(--gold); font-weight: 700; }
.cal span.past { opacity: .4; }

.board { display: grid; grid-template-columns: 290px minmax(0, 1fr) 320px; gap: 12px; padding: 12px; min-height: 0; overflow: hidden; }
.col { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.panel { padding: 12px 14px; }
.panel h3 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.panel h3 .r { margin-left: auto; font: 600 12px var(--body); color: var(--ink-2); }

/* tracks */
.track { margin-bottom: 9px; }
.track .lbl { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.track .lbl b { font-family: var(--fell); font-size: 15px; }
.cells { display: flex; gap: 2px; margin-top: 3px; }
.cells i { flex: 1; height: 12px; border: 1px solid rgba(43,33,24,.5); border-radius: 2px; background: rgba(255,255,255,.3); }
.cells.hull i.on { background: linear-gradient(#8a6a44, #5e4428); }
.cells.hull i:not(.on) { background: #1d3b40; border-style: dashed; }
.cells.morale i.on { background: var(--green); }
.cells.fear i.on { background: var(--black); }
.cells.navy i.on { background: var(--red); }
.cells.navy i.ship { background: var(--red); position: relative; }
.cells.barn i.on { background: #7b8a5a; }
.cells.scurvy i.on { background: #a8743a; }
.teeth { letter-spacing: 2px; }
.teeth .lost { opacity: .18; }
.minirow { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; border-bottom: 1px dotted rgba(43,33,24,.25); }
.minirow:last-child { border-bottom: 0; }
.hold { display: flex; flex-wrap: wrap; gap: 6px; }
.tok { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; background: rgba(255,255,255,.45); border: 1px solid rgba(43,33,24,.3); border-radius: 12px; font-size: 13px; }
.tok small { color: var(--ink-2); font-size: 11px; }
.hold.warn .tok { border-color: var(--red); animation: pulse 1.2s infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: rgba(184,137,46,.25); border: 1px solid rgba(184,137,46,.6); cursor: help; }
.chip.blk { background: var(--black); color: var(--parch); border-color: #000; }
.chip.art { background: rgba(43,33,24,.08); border-color: rgba(43,33,24,.35); }

/* table */
.table { padding: 14px; min-height: 120px; background: radial-gradient(ellipse at center, #4a3624 0%, var(--wood) 60%, var(--wood-2) 100%); border-radius: 8px; box-shadow: inset 0 0 40px rgba(0,0,0,.6), 0 6px 18px rgba(0,0,0,.4); color: var(--parch); }
.table h2 { font-size: 20px; color: #f3d79a; }
.table .note { margin-top: 6px; font-size: 14px; color: #e8dcc0; }
.table .tcards { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }
.dice { display: flex; gap: 8px; margin-top: 10px; justify-content: center; }
.die { width: 42px; height: 42px; display: grid; place-items: center; background: #f6efe0; color: var(--ink); border-radius: 8px; font: 700 22px var(--fell); box-shadow: 0 3px 0 #b9a77f; animation: roll .5s ease-out; }

/* cards (5:7) */
.card {
  width: 160px; aspect-ratio: 5 / 7; border-radius: 7px; padding: 7px 9px; display: flex; flex-direction: column; gap: 3px;
  background:
    radial-gradient(ellipse at 30% 15%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(ellipse at 80% 95%, rgba(120,80,30,.22), transparent 55%), var(--parch);
  color: var(--ink); border: 3px solid var(--ink-2); box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 0 14px rgba(110,70,20,.3);
  font-size: 12px; position: relative; overflow: hidden;
}
/* face illustration: one-ink "engraving" over cross-hatched paper */
.cart { position: relative; height: 34%; min-height: 44px; margin: 1px -2px; border: 1px solid rgba(43,33,24,.45); border-radius: 3px; display: grid; place-items: center; overflow: hidden; flex-shrink: 0;
  background: repeating-linear-gradient(45deg, rgba(43,33,24,.07) 0 1px, transparent 1px 5px), repeating-linear-gradient(-45deg, rgba(43,33,24,.05) 0 1px, transparent 1px 6px), #f3e9d2; }
.ink { display: inline-block; filter: grayscale(1) sepia(1) saturate(.7) brightness(.55) contrast(1.4); line-height: 1; }
.cart .ink { font-size: 44px; }
.cart .ink.sub { position: absolute; right: 6px; bottom: 4px; font-size: 18px; }
.card.black .cart { background: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 1px, transparent 1px 5px), #2a2a2a; border-color: #555; }
.card.black .cart .ink { filter: grayscale(1) brightness(1.6) sepia(.4); }
.card.mini .cart { min-height: 32px; }
.card.mini .cart .ink { font-size: 30px; }
.card.mini .cart .ink.sub { font-size: 13px; }

/* card backs (one per deck) */
.cback { width: 160px; aspect-ratio: 5 / 7; border-radius: 7px; border: 3px solid #1a120b; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 0 0 5px rgba(239,227,200,.18), inset 0 0 0 7px rgba(0,0,0,.25); color: var(--parch); }
.cback.mini { width: 112px; }
.cback .bring { width: 58%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 2px solid rgba(239,227,200,.55); background: rgba(0,0,0,.18); }
.cback .bring .ink { font-size: 40px; filter: grayscale(1) brightness(2.2) sepia(.5); }
.cback.mini .bring .ink { font-size: 28px; }
.cback .blabel { font: 700 12px var(--head); letter-spacing: 1px; opacity: .85; }
.back-sea { background: repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.06) 0 2px, transparent 2px 12px), var(--sea); }
.back-target { background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, transparent 2px 10px), #234a4e; }
.back-intim { background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 2px, transparent 2px 9px), var(--black); }
.back-article { background: repeating-linear-gradient(0deg, rgba(43,33,24,.12) 0 1px, transparent 1px 8px), #c9b07a; color: var(--ink); border-color: var(--ink-2); }
.back-article .bring { border-color: var(--ink-2); background: rgba(255,255,255,.2); }
.back-article .bring .ink { filter: grayscale(1) sepia(1) brightness(.4) contrast(1.5); }
.back-cargo { background: repeating-linear-gradient(45deg, rgba(0,0,0,.14) 0 2px, transparent 2px 14px), repeating-linear-gradient(-45deg, rgba(0,0,0,.14) 0 2px, transparent 2px 14px), var(--gold); }
.back-trinket { background: radial-gradient(circle at 50% 40%, #7a2c4c, #3f1426); }
.back-injury { background: #efe3c8; color: var(--red); border-color: var(--red); }
.back-injury .bring { border-color: var(--red); background: transparent; }
.back-injury .bring .ink { filter: none; color: var(--red); font-size: 52px; font-weight: 700; }

/* dealing: fly in face down from the deck, then flip */
.d3 { perspective: 1000px; display: inline-block; }
.d3in { position: relative; transform-style: preserve-3d; animation: deal 1.15s cubic-bezier(.2,.75,.25,1) both; }
.d3.done .d3in { animation: none; }
.d3in > .card { backface-visibility: hidden; -webkit-backface-visibility: hidden; transform: rotateY(0deg); }
.d3in > .cback { position: absolute; inset: 0; width: auto; backface-visibility: hidden; -webkit-backface-visibility: hidden; transform: rotateY(180deg); }
@keyframes deal {
  0% { transform: translate(-240px, -30px) rotate(-14deg) rotateY(180deg) scale(.5); }
  48% { transform: translate(0, -10px) rotate(0) rotateY(180deg) scale(1.06); }
  62% { transform: translate(0, -14px) rotateY(180deg) scale(1.08); }
  100% { transform: translate(0, 0) rotateY(0deg) scale(1); }
}
.pile { position: relative; width: 70px; height: 98px; margin-right: 18px; align-self: center; flex-shrink: 0; }
.pile .cback { position: absolute; width: 70px; border-width: 2px; gap: 2px; }
.pile .cback .blabel { display: none; }
.pile .cback .bring .ink { font-size: 20px; }
.pile .cback:nth-child(1) { transform: translate(4px, 4px) rotate(3deg); }
.pile .cback:nth-child(2) { transform: translate(2px, 2px) rotate(-2deg); }
#drawpop { position: fixed; inset: 0; z-index: 55; display: none; place-items: center; background: rgba(5,10,10,.55); cursor: pointer; }
#drawpop.show { display: grid; }
#drawpop .dp { text-align: center; display: grid; gap: 14px; justify-items: center; padding: 16px; }
#drawpop .dptitle { font: 700 22px var(--head); color: #f3d79a; text-shadow: 0 2px 6px #000; }
#drawpop .dpcards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
#drawpop .card, #drawpop .cback { width: 190px; }
.card .ct { font: 700 14px/1.2 var(--head); }
.card .cv { position: absolute; top: 6px; right: 8px; font: 700 18px var(--fell); }
.card .ce { flex: 1; overflow: hidden; }
.card .cl { font-size: 10px; color: var(--ink-2); border-top: 1px dotted rgba(43,33,24,.4); padding-top: 3px; cursor: help; }
.card .cs { font-size: 11px; font-style: italic; color: var(--ink-2); }
.card.black { background: var(--black); color: var(--parch); border-color: #555; }
.card.black .cl, .card.black .cs { color: #bbb; border-color: #555; }
.card.sea { border-color: var(--sea); }
.card.omen { border-color: var(--omen); background: linear-gradient(#e9e0f0, var(--parch)); }
.card.red { border-color: var(--red); }
.card.gold { border-color: var(--gold); }
.card.velvet { border-color: #6b2440; background: linear-gradient(#efe0e6, var(--parch)); }
.card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; font-size: 12px; }
.card .stats b { font-family: var(--fell); font-size: 15px; }
.card .seal { position: absolute; bottom: 30px; right: 8px; width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #c0392b, #7a1c12); color: #f4d9c6; display: grid; place-items: center; font-size: 10px; font-weight: 700; text-align: center; line-height: 1.1; box-shadow: 0 2px 4px rgba(0,0,0,.5); animation: stamp .5s cubic-bezier(.2,1.6,.4,1); }
.card.mini { width: 112px; font-size: 11px; padding: 5px 7px; gap: 2px; }
.card.mini .ct { font-size: 12px; }
.card.mini .cv { font-size: 15px; }
.card.mini .stats { grid-template-columns: 1fr; gap: 0; font-size: 11px; }
.card.mini .stats b { font-size: 13px; }
.card.mini .seal { width: 30px; height: 30px; font-size: 8px; bottom: 24px; right: 5px; }
.card.mini .ce { font-size: 10.5px; }
.tablewrap { overflow-x: auto; }
.card.pick { cursor: pointer; transition: transform .12s; animation: none; }
.card.pick:hover { transform: translateY(-4px); }
.d3in > .card.pick { transition: none; }
.card.pick.on { outline: 3px solid var(--gold); transform: translateY(-6px); }
.card.pick.off { opacity: .4; cursor: not-allowed; }

/* prompt */
.prompt { padding: 16px; }
.prompt h2 { font-size: 19px; }
.prompt .desc { white-space: pre-line; color: var(--ink-2); margin: 6px 0 12px; font-size: 14px; }
.field { margin-bottom: 12px; }
.field > .fl { font-weight: 600; font-size: 14px; margin-bottom: 5px; display: block; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { flex: 1 1 160px; text-align: left; padding: 10px 12px; border: 2px solid var(--ink-2); border-radius: 6px; background: rgba(255,255,255,.4); cursor: pointer; }
.choice b { display: block; font-size: 15px; }
.choice small { color: var(--ink-2); font-size: 12px; display: block; margin-top: 2px; }
.choice.on { background: var(--black); color: var(--parch); border-color: var(--black); }
.choice.on small { color: #ccc; }
.choice:disabled { opacity: .4; cursor: not-allowed; }
.yn { display: inline-flex; gap: 6px; }
.yn button { min-width: 64px; padding: 6px 12px; border: 2px solid var(--ink-2); border-radius: 4px; background: rgba(255,255,255,.4); cursor: pointer; font-weight: 600; }
.yn button.on.y { background: var(--good); color: #fff; border-color: var(--good); }
.yn button.on.n { background: var(--red); color: #fff; border-color: var(--red); }
.ynrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dotted rgba(43,33,24,.3); }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--ink-2); border-radius: 4px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--parch-2); cursor: pointer; font-weight: 700; font-size: 18px; }
.stepper input { width: 64px; border: 0; border-radius: 0; text-align: center; background: #fbf5e6; height: 34px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.numrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dotted rgba(43,33,24,.3); }
.numrow .fl { font-weight: 500; font-size: 14px; }
.checkrow { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.checkrow input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--ink); }
.sig { border: 1px dashed var(--ink-2); border-radius: 4px; background: #fffaf0; touch-action: none; width: 100%; max-width: 420px; height: 120px; display: block; cursor: crosshair; }
.pfoot { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pfoot .status { font-size: 13px; color: var(--ink-2); }
.sent { color: var(--good); font-weight: 700; }
.wait { padding: 14px 16px; }
.wchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wchip { padding: 3px 9px; border-radius: 12px; font-size: 12px; border: 1px solid rgba(43,33,24,.4); background: rgba(255,255,255,.35); }
.wchip.done { background: var(--ink); color: var(--parch); }
.islands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.island { padding: 10px 6px; text-align: center; border-radius: 40% 50% 45% 55%; background: radial-gradient(circle, #d9c38e 0 45%, #6f9a8f 70%); border: 1px solid #2f5d62; font-size: 12px; font-weight: 600; }

/* players */
.pl { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px dotted rgba(43,33,24,.35); align-items: center; }
.pl:last-child { border-bottom: 0; }
.pl.me { background: linear-gradient(90deg, rgba(184,137,46,.2), transparent); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.pl .nm { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pl .nm span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .meta { grid-column: 2 / 4; display: flex; gap: 10px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.pl .meta b { color: var(--ink); font-family: var(--fell); font-size: 14px; }
.pl .st { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: rgba(43,33,24,.12); white-space: nowrap; }
.st.dead, .st.hanged { background: var(--black); color: var(--parch); }
.st.marooned { background: #c9b07a; }
.st.hunter { background: var(--sea); color: var(--parch); }
.st.think { background: transparent; border: 1px dashed var(--ink-2); }
.st.ok { background: var(--good); color: #fff; }
.roles { font-size: 14px; letter-spacing: 1px; }

/* log & chat */
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 5px; border: 1px solid var(--ink-2); background: transparent; border-radius: 4px; cursor: pointer; font-weight: 600; }
.tabs button.on { background: var(--ink); color: var(--parch); }
.tabs .badge { background: var(--red); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.log { max-height: 46vh; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.log .e { padding: 2px 0; }
.log .e.phase { font-family: var(--head); font-weight: 700; color: var(--sea); margin-top: 6px; }
.log .e.voyage { font-family: var(--head); font-weight: 700; background: var(--ink); color: var(--parch); padding: 3px 8px; border-radius: 3px; margin-top: 8px; }
.log .e.good { color: var(--good); }
.log .e.bad { color: var(--bad); }
.log .e.omen { color: var(--omen); font-style: italic; }
.log .e.story { color: var(--ink); }
.log .e.pardon { color: #6b4b00; font-weight: 700; }
.log .e.secret::before { content: '🔒 '; }
.log .e.chat b { color: var(--sea); }
.log .e.sys { color: var(--ink-2); font-style: italic; }
.chatin { display: flex; gap: 6px; margin-top: 8px; }
.chatin input { flex: 1; }

/* private strip */
.private { margin: 0 12px 12px; padding: 8px 14px; border: 2px dashed var(--ink-2); display: flex; gap: 18px; align-items: flex-start; overflow-x: auto; max-height: 132px; }
.private.collapsed > :not(.ptoggle) { display: none; }
.private .ptoggle { flex-shrink: 0; }
.private .grp { flex-shrink: 0; }
.private .grp h4 { margin: 0 0 4px; font: 600 12px var(--body); color: var(--ink-2); text-transform: none; }
.private .big { font: 700 22px var(--fell); }
.private .cardsrow { display: flex; gap: 6px; }

/* toast & modal */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--black); color: var(--parch); padding: 10px 18px; border-radius: 6px; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.modal { position: fixed; inset: 0; background: rgba(10,15,15,.75); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal .box { width: min(860px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; }
.book h1 { font-family: var(--fell); font-size: 30px; text-align: center; }
.book .subt { text-align: center; color: var(--ink-2); font-family: var(--head); margin-bottom: 16px; }
.book table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.book th, .book td { padding: 6px 8px; border-bottom: 1px solid rgba(43,33,24,.3); text-align: right; }
.book th:first-child, .book td:first-child, .book td:nth-child(2), .book th:nth-child(2) { text-align: left; }
.book tr.win td { background: rgba(184,137,46,.25); font-weight: 700; }
.book .sigimg { height: 34px; background: #fffaf0; border: 1px solid rgba(43,33,24,.2); }
.book .reveal { columns: 2 300px; font-size: 13px; }
.book .reveal div { break-inside: avoid; padding: 3px 0; border-bottom: 1px dotted rgba(43,33,24,.25); }
.rules h3 { margin-top: 14px; }
.rules p, .rules li { font-size: 14px; }

/* teaching layer */
.hintbox { background: #fff8e3; border: 1px solid var(--gold); border-left: 5px solid var(--gold); border-radius: 5px; padding: 9px 12px; margin: 8px 0 10px; font-size: 14px; display: grid; gap: 4px; }
.hintbox .hrow { display: flex; justify-content: space-between; align-items: center; }
.hintbox .hhow { color: var(--ink); }
.hintbox .htip { color: var(--ink-2); font-size: 13px; }
.hintx, .hintshow { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; }
.hintshow { margin: 4px 0 8px; }
.vstrip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 12px; }
.vs { padding: 3px 10px; border-radius: 12px; border: 1px solid rgba(239,227,200,.25); color: rgba(239,227,200,.55); }
.vs.done { color: rgba(239,227,200,.8); border-color: rgba(239,227,200,.4); }
.vs.on { background: var(--gold); color: var(--black); border-color: var(--gold); font-weight: 700; }
.varr { color: rgba(239,227,200,.4); }
#tour { position: fixed; inset: 0; z-index: 60; }
#tour .tdim { position: absolute; inset: 0; background: rgba(5,10,10,.7); }
#tour .thole { position: absolute; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(5,10,10,.7); outline: 3px solid var(--gold); pointer-events: none; transition: all .25s; }
#tour .tcard { position: absolute; padding: 16px 18px; max-width: calc(100vw - 32px); }
#tour .tcard h3 { font-size: 17px; margin-bottom: 6px; }
#tour .ttext { font-size: 14px; }
#tour .tstep { font-size: 12px; color: var(--ink-2); }
.guide h2 { font-family: var(--head); margin-bottom: 10px; }
.gtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.gtabs button { padding: 6px 12px; border: 1px solid var(--ink-2); border-radius: 4px; background: transparent; cursor: pointer; font-weight: 600; }
.gtabs button.on { background: var(--ink); color: var(--parch); }
.gbody { font-size: 15px; }
.gbody h4 { font-family: var(--head); margin: 12px 0 4px; }
.gbody li { margin-bottom: 4px; }
.gbox { background: var(--black); color: var(--parch); padding: 10px 14px; border-radius: 5px; margin: 8px 0; }
.flow { display: grid; gap: 8px; margin: 10px 0; }
.fstep { display: grid; gap: 2px; padding: 9px 12px; border-left: 4px solid var(--sea); background: rgba(255,255,255,.4); border-radius: 4px; }
.fstep span { font-size: 14px; color: var(--ink-2); }
.screenmap li { margin-bottom: 8px; }

@keyframes stamp { 0% { transform: scale(1.6) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes roll { 0% { transform: rotate(-200deg) scale(.4); } 100% { transform: rotate(0) scale(1); } }
@keyframes pulse { 50% { opacity: .55; } }

@media (max-width: 1180px) {
  .board { grid-template-columns: 260px minmax(0, 1fr); }
  .col.right { grid-column: 1 / 3; }
  .game { height: auto; min-height: 100vh; }
  .board { overflow: visible; }
  .col { overflow: visible; }
}
@media (max-width: 760px) {
  .board { grid-template-columns: 1fr; padding: 8px 16px; }
  .col.right { grid-column: auto; }
  .col.left { order: 2; }
  .col.center { order: 1; }
  .col.right { order: 3; }
  .lobby { grid-template-columns: 1fr; }
  .card { width: 128px; }
  .topbar { gap: 8px; }
  .cal { display: none; }
  .private { margin: 0 16px 12px; flex-wrap: wrap; }
  .home h1 { font-size: 34px; }
}
