@font-face { font-family: 'Pixelify Sans'; src: url(../assets/fonts/pixelify.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'IM Fell English SC'; src: url(../assets/fonts/imfell.woff2) format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --ink: #0a0608; --ink2: #140c10; --panel: #1a1015; --panel2: #231419;
  --bone: #eadfc6; --bone2: #b8ab90; --gold: #d9a845; --gold2: #8f6a22;
  --blood: #b3151f; --blood2: #5f0a10; --moss: #1b3025; --ghost: #8fb4d6; --poison: #7bd36a;
  --cs: 2.4;            /* playing-card scale (set by JS) */
  --ui: 'Pixelify Sans', ui-monospace, monospace;
  --gothic: 'IM Fell English SC', 'Times New Roman', serif;
  --num: 'Segoe UI', 'Helvetica Neue', Arial, system-ui, sans-serif; /* numerals: unambiguous lining figures */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--bone); font-family: var(--ui); overflow: hidden; }
img, .pc, .tarot { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input, select { font-family: inherit; }
#app { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 30%, #1c0f15 0%, #0a0608 70%); overflow: hidden; }
#bgfx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 90; pointer-events: none; }
#vignette { position: fixed; inset: 0; z-index: 80; pointer-events: none; box-shadow: inset 0 0 18vmin 6vmin rgba(0,0,0,.75); transition: background .6s; }
#vignette.hurt { background: radial-gradient(ellipse at center, transparent 40%, rgba(150,10,20,.45) 100%); }
#vignette.low { animation: heartbeat 1.1s infinite; }
@keyframes heartbeat { 0%,100% { background: radial-gradient(ellipse at center, transparent 55%, rgba(120,8,16,.0) 100%); } 15% { background: radial-gradient(ellipse at center, transparent 40%, rgba(150,10,20,.45) 100%); } 30% { background: radial-gradient(ellipse at center, transparent 55%, rgba(120,8,16,.1) 100%); } 45% { background: radial-gradient(ellipse at center, transparent 45%, rgba(150,10,20,.3) 100%); } }

.screen { position: absolute; inset: 0; display: none; z-index: 1; }
.screen.on { display: flex; }
.screen.center { align-items: center; justify-content: center; }
.gothic { font-family: var(--gothic); letter-spacing: .04em; font-weight: 400; }
.tiny { font-size: 14px; color: var(--bone2); }
.sub { font-family: var(--gothic); color: var(--gold); letter-spacing: .3em; font-weight: 400; text-transform: uppercase; margin: 0; }

/* ---------- buttons & fields ---------- */
.btn { background: linear-gradient(#2a1a20, #170d11); color: var(--bone); border: 2px solid var(--gold2); padding: 10px 18px; font-size: 18px; cursor: pointer; letter-spacing: .04em; box-shadow: 0 0 0 2px #000, inset 0 0 12px rgba(0,0,0,.6); transition: transform .08s, box-shadow .2s, border-color .2s, filter .2s; text-transform: uppercase; }
.btn:hover:not(:disabled) { border-color: var(--gold); box-shadow: 0 0 0 2px #000, 0 0 18px rgba(217,168,69,.35), inset 0 0 12px rgba(0,0,0,.6); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.big { font-size: 23px; padding: 13px 26px; }
.btn.small { padding: 6px 12px; font-size: 16px; }
.btn.red { background: linear-gradient(#7a1018, #3d070c); border-color: #d8434a; }
.btn.red:hover:not(:disabled) { box-shadow: 0 0 0 2px #000, 0 0 22px rgba(220,40,50,.55); border-color: #ff6a70; }
.tiny-btn { padding: 4px 10px; font-size: 19px; }
.field { background: #0c0709; color: var(--bone); border: 2px solid #4a3326; padding: 9px 11px; font-size: 19px; outline: none; width: 100%; }
.field:focus { border-color: var(--gold); box-shadow: 0 0 10px rgba(217,168,69,.3); }
.check { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--bone2); font-size: 17px; margin: 14px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blood); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- warning screen ---------- */
.warn-card { max-width: 520px; width: calc(100% - 32px); text-align: center; background: linear-gradient(#170c11, #0d0709); border: 3px double var(--gold2); padding: 28px 24px; box-shadow: 0 0 80px rgba(150,10,20,.35); position: relative; }
.warn-tarot { width: 92px; margin: 0 auto 10px; display: block; filter: drop-shadow(0 0 14px rgba(217,168,69,.4)); animation: bob 4s ease-in-out infinite; }
.warn-card h1 { margin: 0; font-size: clamp(30px, 8vw, 46px); color: var(--bone); text-shadow: 0 0 20px rgba(179,21,31,.6); }
.warn-text { line-height: 1.55; color: var(--bone2); font-size: 18px; }
.warn-text b { color: #e5575f; font-weight: 400; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- main menu ---------- */
.menu-wrap { position: relative; width: min(920px, 100%); padding: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 100%; overflow: auto; }
.title-block { position: relative; }
.crown { font-size: 34px; color: var(--gold); text-shadow: 0 0 18px rgba(217,168,69,.6); animation: bob 3.5s ease-in-out infinite; }
.title { margin: 0; font-size: clamp(40px, 11vw, 92px); line-height: 1; color: var(--bone); text-shadow: 0 3px 0 #000, 0 0 30px rgba(179,21,31,.8), 0 0 60px rgba(179,21,31,.35); }
.drips { position: relative; height: 44px; margin-top: -4px; pointer-events: none; }
.drips i { position: absolute; top: 0; width: 6px; background: linear-gradient(var(--blood), var(--blood2)); border-radius: 0 0 6px 6px; animation: drip 5s infinite ease-in; opacity: .9; }
.drips i::after { content: ''; position: absolute; bottom: -5px; left: -1px; width: 8px; height: 9px; border-radius: 50%; background: var(--blood2); }
@keyframes drip { 0% { height: 0; opacity: 0; } 10% { opacity: .9; } 55% { height: var(--h); } 85% { height: var(--h); transform: translateY(20px); opacity: .8; } 100% { height: var(--h); transform: translateY(46px); opacity: 0; } }
.menu-cards { position: absolute; inset: 0; pointer-events: none; z-index: -1; }
.mc { position: absolute; width: clamp(70px, 13vw, 130px); opacity: .55; filter: drop-shadow(0 8px 14px #000); }
.mc1 { left: 3%; top: 18%; transform: rotate(-12deg); animation: bob 5s ease-in-out infinite; }
.mc2 { right: 3%; top: 14%; transform: rotate(10deg); animation: bob 6s ease-in-out infinite .6s; }
.mc3 { left: 9%; bottom: 8%; transform: rotate(8deg); animation: bob 5.5s ease-in-out infinite 1.2s; }
.mc4 { right: 9%; bottom: 10%; transform: rotate(-9deg); animation: bob 6.5s ease-in-out infinite .3s; }
.menu-btns { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); }
.menu-btns .btn { width: 100%; }
.menu-btns .row .btn { width: auto; flex: 1; }
.name-row { width: min(340px, 100%); color: var(--bone2); font-size: 16px; text-align: left; }
.name-row label { display: block; }
.name-row input { margin-top: 5px; }

/* ---------- lobby ---------- */
.lobby { width: min(980px, 100%); max-height: 100%; padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.lobby-head h2 { margin: 0; font-size: clamp(26px, 6vw, 40px); color: var(--bone); }
.code-box { text-align: center; background: var(--panel); border: 2px solid var(--gold2); padding: 8px 16px; }
.code { font-size: 34px; letter-spacing: .25em; color: var(--gold); text-shadow: 0 0 12px rgba(217,168,69,.5); padding-left: .25em; }
.lobby-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
@media (max-width: 760px) { .lobby-body { grid-template-columns: 1fr; } }
.seats-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.lseat { background: linear-gradient(var(--panel2), var(--panel)); border: 2px solid #3a2630; padding: 10px; display: flex; gap: 10px; align-items: center; min-height: 92px; position: relative; }
.lseat.me { border-color: var(--gold); box-shadow: 0 0 16px rgba(217,168,69,.25); }
.lseat.empty { opacity: .5; border-style: dashed; justify-content: center; color: var(--bone2); }
.lseat.bot { border-color: #3d3350; }
.lseat .nm { font-size: 18px; word-break: break-word; }
.lseat .tag { font-size: 14px; color: var(--gold); letter-spacing: .1em; text-transform: uppercase; }
.lseat .kick { position: absolute; top: 3px; right: 3px; }
.lseat .avs { display: flex; gap: 3px; margin-top: 4px; }
.lseat .avs i { width: 14px; height: 14px; border: 1px solid #5b4332; cursor: pointer; opacity: .6; }
.lseat .avs i.on { opacity: 1; outline: 2px solid var(--gold); }
.panel-sm { background: var(--panel); border: 2px solid #3a2630; padding: 12px; margin-bottom: 10px; }
.panel-sm h3 { margin: 0 0 8px; font-family: var(--gothic); font-weight: 400; color: var(--gold); letter-spacing: .1em; }
.row-opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; font-size: 17px; }
.row-opt .field { width: auto; padding: 6px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.lobby-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chat { background: var(--panel); border: 2px solid #3a2630; display: flex; flex-direction: column; height: 220px; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px; font-size: 16px; line-height: 1.4; }
.chat-log .m b { color: var(--gold); font-weight: 400; }
.chat-log .sys { color: var(--bone2); font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 6px; border-top: 2px solid #3a2630; }
.chat-form .field { padding: 6px 8px; font-size: 17px; }

/* ---------- game screen ---------- */
#scr-game { flex-direction: column; }
#hud { height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; background: linear-gradient(#150b0f, #0c0709); border-bottom: 2px solid #3a2630; z-index: 5; }
#hud .hud-l, #hud .hud-r { display: flex; align-items: center; gap: 8px; min-width: 120px; }
#hud .hud-r { justify-content: flex-end; }
#bell-label { font-family: var(--gothic); font-size: 28px; color: var(--gold); letter-spacing: .15em; text-shadow: 0 0 12px rgba(217,168,69,.5); }
#bell-label .of { color: var(--bone2); font-size: 17px; }
.timer { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; font-weight: 700; font-size: 24px; color: var(--bone); min-width: 44px; text-align: right; }
.timer.warn { color: #ff5a60; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }
#table-wrap { flex: 1; position: relative; min-height: 0; padding: 8px 8px 0; }
#table { position: absolute; inset: 6px 8px 0; margin: 0 auto; max-width: 1200px; transition: transform .05s; }
#felt, #stains { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 48% / 50%; }
#felt { box-shadow: 0 0 0 5px #2a170d, 0 0 0 8px #5a3a1c, 0 0 0 10px #1a0d07, 0 22px 50px #000, inset 0 0 90px rgba(0,0,0,.85); }
#stains { pointer-events: none; mix-blend-mode: normal; }
#candles { position: absolute; inset: 0; pointer-events: none; }
.candle { position: absolute; width: 10px; height: 20px; margin: -10px 0 0 -5px; transform-origin: bottom; }
.candle::before { content: ''; position: absolute; bottom: 0; left: 1px; width: 8px; height: 12px; background: linear-gradient(90deg, #cfc3a4, #8f8368); }
.candle .fl { position: absolute; left: 1px; bottom: 11px; width: 8px; height: 12px; background: radial-gradient(ellipse at 50% 70%, #fff6c9 0%, #ffb23a 45%, rgba(255,110,20,0) 75%); border-radius: 50% 50% 40% 40%; filter: blur(.4px); animation: flick .35s infinite alternate; box-shadow: 0 0 14px 6px rgba(255,160,50,.4); }
.candle.out .fl { display: none; }
.candle.out::before { background: linear-gradient(90deg, #5a5240, #3a3427); height: 7px; }
.candle.now .fl { transform: scale(1.35); box-shadow: 0 0 20px 9px rgba(255,160,50,.6); }
@keyframes flick { from { transform: scale(1) rotate(-3deg); } to { transform: scale(1.12, .92) rotate(3deg); } }
#center { position: absolute; left: 50%; top: 66%; transform: translate(-50%, -50%); text-align: center; width: min(26%, 260px); pointer-events: none; z-index: 2; }
.omen-card { width: clamp(46px, 7.6vmin, 80px); margin: 0 auto 4px; perspective: 600px; filter: drop-shadow(0 6px 10px #000); }
.omen-card img { width: 100%; display: block; }
.omen-card.flip img { animation: flipin .8s ease-out; }
@keyframes flipin { 0% { transform: rotateY(90deg) scale(.7); } 100% { transform: rotateY(0) scale(1); } }
.omen-name { font-family: var(--gothic); color: var(--gold); font-size: clamp(17px, 3vmin, 24px); text-shadow: 0 0 8px #000; }
.omen-text { font-size: clamp(14px, 2.2vmin, 17px); color: var(--bone2); line-height: 1.25; text-shadow: 0 1px 2px #000; margin-top: 2px; }

/* seats */
#seats { position: absolute; inset: 0; }
.seat { position: absolute; transform: translate(-50%, -50%); width: clamp(150px, 21vmin, 210px); text-align: center; z-index: 3; transition: filter .6s, opacity .6s; }
.seat .pwrap { position: relative; display: inline-block; }
.seat .pc { --cs: 1.45; box-shadow: 0 4px 12px #000; transition: transform .2s, box-shadow .2s; }
/* names */
.seat .sname { font-size: clamp(15px, 2.5vmin, 19px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px #000; margin-top: 2px; }
.seat .sname .bot { color: #b3a4e6; font-size: .7em; text-transform: uppercase; letter-spacing: .08em; }
.lifebar { position: relative; height: 22px; background: #1a0b0d; border: 2px solid #000; box-shadow: 0 0 0 1px #5b3b2a; margin: 2px auto; width: 92%; }
.lifebar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#e34b52, #8a111a); transition: width .5s; }
.lifebar .num { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; position: absolute; inset: 0; font-size: 15px; line-height: 18px; font-weight: 700; text-align: center; color: #fff; text-shadow: 0 1px 1px #000; }
.lifebar .ghostfill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.35); transition: width 1s .3s; }
.sstat { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; font-weight: 600; display: flex; justify-content: center; gap: 8px; font-size: 16px; min-height: 22px; color: var(--bone2); }
.sstat .po { color: var(--poison); } .sstat .hcount { color: #c8b48a; }
.seat .badge { position: absolute; top: -8px; right: -10px; background: var(--gold); color: #000; font-size: 13px; padding: 1px 5px; display: none; }
.seat.sealed .badge { display: block; }
.seat.sealed .pc { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(217,168,69,.7); }
.seat.targetable { cursor: pointer; }
.seat.targetable .pc { animation: tgt .7s infinite alternate; }
@keyframes tgt { from { box-shadow: 0 0 0 2px #e34b52, 0 0 8px rgba(227,75,82,.5); } to { box-shadow: 0 0 0 3px #ff8a8f, 0 0 26px rgba(255,90,100,.9); } }
.seat.targetable.friendly .pc { animation-name: tgtf; }
@keyframes tgtf { from { box-shadow: 0 0 0 2px #6fd57b, 0 0 8px rgba(111,213,123,.5); } to { box-shadow: 0 0 0 3px #a5f2ad, 0 0 26px rgba(130,240,150,.9); } }
.seat.hit .pc { animation: hit .45s; }
@keyframes hit { 0%,100% { transform: translate(0); filter: none; } 15% { transform: translate(-7px, 2px) rotate(-3deg); filter: brightness(2) sepia(1) saturate(6) hue-rotate(-30deg); } 35% { transform: translate(6px, -2px) rotate(2deg); } 60% { transform: translate(-3px, 1px); } }
.seat.healed .pc { animation: healed .8s; }
@keyframes healed { 0%,100% { filter: none; } 40% { filter: brightness(1.5) saturate(.5) drop-shadow(0 0 12px #8f8); } }
.seat.dead { filter: grayscale(.9) brightness(.55); }
.seat.dead .pc { opacity: .75; }
.seat.ghost-me { }
.seat .ghosticon { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); font-size: 22px; display: none; animation: bob 2.5s ease-in-out infinite; filter: drop-shadow(0 0 8px var(--ghost)); }
.seat.dead .ghosticon { display: block; }
.seat .crack { position: absolute; inset: 0; display: none; background: linear-gradient(115deg, transparent 38%, #000 39%, #000 41%, transparent 42%), linear-gradient(70deg, transparent 55%, #000 56%, #000 57%, transparent 58%), linear-gradient(160deg, transparent 20%, #000 21%, #000 22%, transparent 23%); opacity: .85; }
.seat.dead .crack { display: block; }
.seat .skull { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-size: 30px; display: none; filter: drop-shadow(0 0 6px #000); }
.seat.dead .skull { display: block; }
.seat .tail { font-size: 14px; color: var(--bone2); min-height: 18px; }
.seat.fatefix .tail { color: var(--gold); }

/* played cards */
#plays { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.play { position: absolute; transform: translate(-50%, -50%); text-align: center; transition: left .4s, top .4s, opacity .4s; }
.play .pc { --cs: 1.8; box-shadow: 0 6px 16px #000; }
.play .plabel { font-size: 15px; background: rgba(0,0,0,.7); border: 1px solid #5b3b2a; padding: 1px 6px; margin-top: 3px; white-space: nowrap; }
.play.flip .pc { animation: cflip .5s ease-out; }
@keyframes cflip { 0% { transform: rotateY(90deg) scale(.8); } 100% { transform: rotateY(0) scale(1); } }
.play.fade { opacity: 0; }

/* playing-card sprites (aged deck, 53x76 per card, 55px pitch / 77px row pitch) */
.pc { --x: 1; --y: 0; display: inline-block; width: calc(53px * var(--cs)); height: calc(76px * var(--cs)); background-image: url(../assets/cards/aged.png); background-repeat: no-repeat; background-size: calc(770px * var(--cs)) calc(308px * var(--cs)); background-position: calc(var(--x) * var(--cs) * -1px) calc(var(--y) * var(--cs) * -1px); position: relative; }
.pc.wide { width: calc(55px * var(--cs)); height: calc(77px * var(--cs)); }

/* bottom area */
#bottom { flex: none; position: relative; display: grid; grid-template-columns: var(--sidew) minmax(0, 1fr) var(--sidew); --sidew: clamp(230px, 24vw, 350px); align-items: end; gap: 10px; padding: 0 10px 6px; min-height: calc(76px * var(--cs) + 100px); z-index: 6; }
#me-panel { width: clamp(170px, 21vmin, 240px); justify-self: start; flex: none; text-align: center; position: relative; }
#me-panel .mp { background: linear-gradient(var(--panel2), var(--panel)); border: 2px solid #3a2630; padding: 6px; }
#me-panel .mp.target { cursor: pointer; }
#me-panel .fate-btn { margin-top: 6px; width: 100%; display: flex; gap: 8px; align-items: center; background: #0c0709; border: 2px solid var(--gold2); color: var(--bone); padding: 4px; cursor: pointer; text-align: left; }
#me-panel .fate-btn img { width: 38px; }
#me-panel .fate-btn span { font-size: 15px; line-height: 1.2; }
#me-panel .fate-btn small { display: block; color: var(--gold); font-size: 14px; }
#me-panel .me-name { font-size: 18px; margin: 3px 0; }
#me-panel .mp.targetable { animation: tgtf .7s infinite alternate; }
#handzone { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.prompt { min-height: 28px; font-size: 19px; color: var(--gold); text-align: center; text-shadow: 0 1px 3px #000; }
.prompt.waiting { color: var(--bone2); }
#hand { display: flex; justify-content: center; align-items: flex-end; min-height: calc(76px * var(--cs) + 6px); padding-top: 40px; max-width: 100%; }
.hc { margin: 0 calc(-3px * var(--cs)); transform-origin: bottom center; transform: rotate(var(--rot, 0deg)) translateY(var(--drop, 0px)); transition: transform .15s, filter .2s; cursor: pointer; position: relative; filter: drop-shadow(0 4px 6px #000); animation: dealin .35s backwards; animation-delay: var(--delay, 0s); }
@keyframes dealin { from { transform: translateY(-120px) rotate(30deg) scale(.5); opacity: 0; } }
.hc:hover:not(.dim) { transform: rotate(0) translateY(-18px) scale(1.06); z-index: 5; }
.hc.sel { transform: rotate(0) translateY(-30px) scale(1.1); z-index: 6; filter: drop-shadow(0 0 14px rgba(217,168,69,.9)); }
.hc.dim { filter: brightness(.55) drop-shadow(0 3px 4px #000); cursor: default; }
.hc .tip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 8px; background: #0c0709; border: 2px solid var(--gold2); padding: 4px 8px; font-size: 16px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 20; }
.hc:hover .tip { opacity: 1; }
.hc.stolen { animation: stolen .5s; }
@keyframes stolen { 50% { filter: brightness(2) drop-shadow(0 0 20px #d6a); } }
#actionbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 36px; }
#side { width: 100%; justify-self: end; flex: none; height: calc(76px * var(--cs) + 100px); background: var(--panel); border: 2px solid #3a2630; display: flex; flex-direction: column; }
#side .tabs { display: flex; }
#side .tab { flex: 1; background: #0e080b; color: var(--bone2); border: 0; border-bottom: 2px solid #3a2630; padding: 5px; font-size: 15px; cursor: pointer; text-transform: uppercase; letter-spacing: .06em; }
#side .tab.on { color: var(--gold); border-bottom-color: var(--gold); }
#side .pane { display: none; flex: 1; min-height: 0; overflow-y: auto; font-size: 16px; line-height: 1.4; padding: 6px; }
#side .pane.on { display: block; }
#chatpane.on { display: flex; flex-direction: column; padding: 0; }
#chatpane .chat-log { flex: 1; }
#log p { margin: 0 0 4px; padding-left: 6px; border-left: 2px solid #3a2630; }
#log p.dmg { border-color: var(--blood); } #log p.heal { border-color: #5fbf6a; } #log p.sys { border-color: var(--gold); color: var(--gold); } #log p.death { border-color: #fff; color: #ff9a9f; }
#log b { font-weight: 400; color: var(--gold); }
@media (max-width: 900px) { #side { display: none; } #bottom { display: flex; flex-wrap: wrap; } #handzone { flex: 1 1 100%; order: 2; } }
@media (max-width: 640px) { #me-panel { width: 100%; display: flex; gap: 8px; align-items: center; } #me-panel .mp { flex: 1; } #me-panel .fate-btn { margin: 0; width: auto; flex: 1; } }

/* ---------- cutscenes ---------- */
.cut { position: fixed; inset: 0; z-index: 70; background: #000; display: none; flex-direction: column; align-items: center; justify-content: center; opacity: 0; transition: opacity .7s; }
.cut.on { display: flex; }
.cut.show { opacity: 1; }
.cut.clear { background: radial-gradient(ellipse at center, rgba(0,0,0,.55) 0%, rgba(0,0,0,.92) 100%); }
.cut-stage { position: relative; width: min(900px, 100%); height: min(56vh, 480px); display: flex; align-items: center; justify-content: center; gap: 2vw; perspective: 900px; }
.cut-cap { margin-top: 22px; max-width: min(760px, 92vw); min-height: 90px; text-align: center; font-family: var(--gothic); font-size: clamp(20px, 4.2vw, 34px); line-height: 1.35; color: var(--bone); text-shadow: 0 0 18px rgba(179,21,31,.6), 0 2px 0 #000; padding: 0 10px; }
.cut-cap .death { color: #e8e0c8; }
.cut-cap em { color: #e5575f; font-style: normal; }
.cut .skip { position: absolute; right: 14px; bottom: 14px; opacity: .6; }
.ctarot { width: clamp(110px, 24vw, 220px); filter: drop-shadow(0 0 30px rgba(179,21,31,.55)); animation: kb 7s ease-out forwards; transform-origin: center; }
.ctarot.sm { width: clamp(80px, 16vw, 150px); }
.ctarot.in { animation: tarin 1.2s ease-out both, kb 8s 1.2s linear forwards; }
@keyframes tarin { from { transform: translateY(40px) scale(.8) rotateY(70deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kb { from { transform: scale(1); } to { transform: scale(1.12); } }
.cqueen { --cs: 3.4; filter: drop-shadow(0 0 24px rgba(217,168,69,.4)); animation: tarin 1s ease-out both; }
.cqueen:nth-child(2) { animation-delay: .25s; } .cqueen:nth-child(3) { animation-delay: .5s; } .cqueen:nth-child(4) { animation-delay: .75s; }
.slash-line { position: absolute; left: -10%; top: 50%; width: 120%; height: 6px; background: linear-gradient(90deg, transparent, #fff 40%, #fff 60%, transparent); transform: rotate(-24deg) scaleX(0); box-shadow: 0 0 30px 6px rgba(255,255,255,.8); animation: slashline .45s .1s ease-out forwards; }
@keyframes slashline { 0% { transform: rotate(-24deg) scaleX(0); opacity: 1; } 60% { transform: rotate(-24deg) scaleX(1); opacity: 1; } 100% { transform: rotate(-24deg) scaleX(1); opacity: 0; } }
.fall-card { animation: fall 2.4s ease-in forwards; }
@keyframes fall { 0% { transform: none; filter: none; } 30% { transform: rotate(-4deg); filter: brightness(1.8) sepia(1) saturate(5) hue-rotate(-35deg); } 100% { transform: translateY(80px) rotate(8deg) scale(.9); filter: grayscale(1) brightness(.3); opacity: .5; } }
.rise-ghost { animation: rise 2.8s ease-out forwards; }
@keyframes rise { from { transform: translateY(0); opacity: .7; filter: grayscale(1) brightness(1.6) drop-shadow(0 0 16px #8fb4d6); } to { transform: translateY(-120px); opacity: 0; } }
.big-text { font-family: var(--gothic); font-size: clamp(34px, 8vw, 78px); color: #e5575f; text-shadow: 0 0 30px rgba(220,40,50,.8), 0 4px 0 #000; animation: tarin .8s ease-out both; text-align: center; }
.big-text.gold { color: var(--gold); text-shadow: 0 0 30px rgba(217,168,69,.8), 0 4px 0 #000; }
.bell-roman { font-family: var(--gothic); font-size: clamp(50px, 14vw, 140px); color: var(--gold); text-shadow: 0 0 40px rgba(217,168,69,.7); animation: bellswing 1.6s ease-out both; letter-spacing: .1em; }
@keyframes bellswing { 0% { transform: scale(.3) rotate(-14deg); opacity: 0; } 30% { transform: scale(1.1) rotate(7deg); opacity: 1; } 55% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } 100% { transform: none; } }

/* judgement reveal */
.verdicts { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; max-width: 98vw; max-height: 66vh; overflow: auto; padding: 8px; }
.verdict { width: clamp(140px, 14vw, 186px); text-align: center; background: linear-gradient(var(--panel2), var(--panel)); border: 2px solid #3a2630; padding: 8px; position: relative; opacity: 0; animation: tarin .8s forwards; }
.verdict.won { border-color: var(--gold); box-shadow: 0 0 24px rgba(217,168,69,.55); }
.verdict.lost { filter: grayscale(.6) brightness(.8); }
.verdict .vname { font-size: 18px; margin-bottom: 4px; }
.verdict img.tarot { width: 100%; max-width: 110px; }
.verdict .vfate { font-family: var(--gothic); color: var(--gold); font-size: 19px; margin-top: 4px; }
.verdict .vwhy { font-size: 15px; color: var(--bone2); line-height: 1.3; min-height: 44px; }
.verdict .vtag { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 14px; padding: 2px 8px; background: #000; border: 1px solid var(--gold); color: var(--gold); display: none; white-space: nowrap; }
.verdict.won .vtag { display: block; }
.verdict .flipper { transition: transform .7s; transform-style: preserve-3d; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(4,2,3,.82); display: none; align-items: center; justify-content: center; padding: 14px; }
.modal.on { display: flex; }
.panel { width: min(860px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(#1b1016, #0f080b); border: 3px double var(--gold2); padding: 18px 20px; box-shadow: 0 0 60px rgba(0,0,0,.9); position: relative; }
.panel h2 { font-family: var(--gothic); font-weight: 400; color: var(--gold); margin: 0 0 10px; font-size: 34px; letter-spacing: .06em; }
.panel h3 { font-family: var(--gothic); font-weight: 400; color: var(--bone); margin: 16px 0 6px; font-size: 24px; border-bottom: 1px solid #3a2630; }
.panel p, .panel li { line-height: 1.5; color: var(--bone); font-size: 18px; }
.panel li { margin-bottom: 4px; }
.panel .x { position: absolute; top: 8px; right: 10px; }
.panel .tabrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.panel .tabrow .btn.on { border-color: var(--gold); color: var(--gold); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.fcard { display: flex; gap: 10px; background: var(--panel); border: 2px solid #3a2630; padding: 8px; }
.fcard img { width: 54px; align-self: flex-start; }
.fcard b { color: var(--gold); font-weight: 400; display: block; font-family: var(--gothic); font-size: 21px; }
.fcard span { font-size: 15px; color: var(--bone2); line-height: 1.35; }
.suit-row { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.suit-row .pc { --cs: 1.2; flex: none; }
.suit-row b { color: var(--gold); font-weight: 400; }
.tbl { width: 100%; border-collapse: collapse; font-size: 17px; }
.tbl td, .tbl th { border-bottom: 1px solid #3a2630; padding: 6px 8px; text-align: left; vertical-align: top; }
.tbl th { color: var(--gold); font-weight: 400; }
.slider-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.slider-row input[type=range] { flex: 1; accent-color: var(--blood); }
.list-rooms { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 50vh; overflow: auto; }
.room-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 2px solid #3a2630; padding: 8px 12px; }
.room-row .rn { font-size: 19px; } .room-row .rs { font-size: 15px; color: var(--bone2); }
.form-grid { display: grid; gap: 10px; }
.form-grid label { font-size: 16px; color: var(--bone2); display: block; }
.form-grid label .field { margin-top: 4px; }
.err { color: #ff7078; min-height: 18px; font-size: 17px; }
.results { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.rrow { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 2px solid #3a2630; padding: 6px 10px; }
.rrow.won { border-color: var(--gold); }
.rrow img { width: 30px; }
.rrow .rn { flex: 1; font-size: 17px; } .rrow small { color: var(--bone2); display: block; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); background: #0c0709; border: 2px solid var(--gold); padding: 10px 18px; z-index: 95; opacity: 0; pointer-events: none; transition: all .3s; max-width: 90vw; text-align: center; font-size: 18px; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.shake { animation: shake .5s; }
.shake-big { animation: shakeb .7s; }
@keyframes shake { 0%,100% { transform: translate(0); } 15% { transform: translate(-5px, 3px); } 35% { transform: translate(5px, -3px); } 55% { transform: translate(-3px, 2px); } 75% { transform: translate(3px, -1px); } }
@keyframes shakeb { 0%,100% { transform: translate(0); } 10% { transform: translate(-12px, 7px) rotate(-.4deg); } 25% { transform: translate(11px, -8px) rotate(.4deg); } 45% { transform: translate(-8px, 5px); } 65% { transform: translate(6px, -4px); } 85% { transform: translate(-3px, 2px); } }
.reduce-gore .blood-only { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: #4a3326; } ::-webkit-scrollbar-track { background: #0c0709; }

/* crowded tables (5-6 players): tighter seats so nobody overlaps */
#seats.crowd .seat { width: clamp(130px, 11vw, 172px); }
#seats.crowd .seat .sname { font-size: clamp(14px, 2.1vmin, 17px); }
#seats.crowd .seat .sstat { font-size: 15px; }

/* phones */
@media (max-width: 640px) {
  #hud { height: 46px; } #bell-label { font-size: 21px; } #bell-label .of { display: none; } .timer { font-size: 20px; } #hud .hud-l, #hud .hud-r { min-width: 70px; } #g-room { display: none; }
  #table { inset: 4px 2px 0; }
  .seat, #seats.crowd .seat { width: 104px; }
  .seat .sname, #seats.crowd .seat .sname { font-size: 14px; }
  .lifebar { height: 20px; } .lifebar .num { font-size: 13px; line-height: 16px; }
  .sstat, #seats.crowd .seat .sstat { font-size: 13px; min-height: 18px; } .seat .tail { font-size: 12px; }
  #center { width: 46%; } .omen-card { width: 38px; } .omen-name { font-size: 15px; } .omen-text { font-size: 12px; line-height: 1.2; }
  .candle { transform: scale(.7); }
  .prompt { font-size: 16px; min-height: 40px; } #hand { padding-top: 34px; }
  #bottom { padding: 0 6px 6px; gap: 6px; }
  .btn.small { padding: 8px 12px; } #actionbar .btn { padding: 8px 12px; }
  .play .plabel { font-size: 13px; }
  .panel { padding: 14px 12px; } .panel h2 { font-size: 28px; }
  .verdict { width: 44vw; }
  .cut-cap { font-size: 22px; }
}

@media (max-width: 640px) {
  #me-panel .mp .pwrap { display: none !important; }
  #me-panel .mp { display: flex; flex-direction: column; justify-content: center; min-height: 66px; padding: 8px 10px; }
  #me-panel .me-name { font-size: 17px; margin: 0 0 4px; }
  #center { top: 64%; }
}

@media (max-width: 640px) {
  #seats.crowd .seat { width: 98px; }
  #seats.crowd .seat .hcount { display: none; }
  #seats.crowd .seat .sname { font-size: 13px; }
}

/* unambiguous numerals everywhere numbers matter */
.stepper b, select.field, .code, .room-row .rs, .lseat .tag { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; }
.stepper b { font-size: 20px; min-width: 22px; text-align: center; }
.code { font-weight: 800; }

/* leaderboard */
.panel.lbpanel { width: min(900px, 100%); }
.lb-desc { color: var(--bone2); margin: 4px 0 10px; }
.lb-empty { color: var(--bone2); padding: 18px 4px; }
.lb-table td, .lb-table th { font-size: 17px; }
.lb-table .num, .lb-table .rk { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; font-weight: 700; text-align: right; }
.lb-table .rk { text-align: center; width: 46px; color: var(--bone2); }
.lb-table tr.top1 .rk { color: #ffd76a; } .lb-table tr.top2 .rk { color: #d6dbe2; } .lb-table tr.top3 .rk { color: #d9a070; }
.lb-table tr.you { background: rgba(217,168,69,.14); }
.lb-table .tg { color: var(--bone2); font-size: 13px; font-family: var(--num); }
.lb-table .yb { background: var(--gold); color: #000; font-size: 12px; padding: 1px 6px; margin-left: 4px; }
.lb-me { background: var(--panel); border: 2px solid var(--gold2); padding: 10px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.lb-me b { color: var(--gold); font-weight: 400; font-family: var(--gothic); font-size: 20px; }
.lb-me span { font-size: 15px; color: var(--bone); line-height: 1.5; } .lb-me i { font-style: normal; font-family: var(--num); font-weight: 700; color: var(--gold); }
.lb-me em { color: #ff9a9f; font-style: normal; }
.lb-me .tg { font-family: var(--num); font-size: 14px; color: var(--bone2); }
.lb-foot { margin-top: 10px; }
@media (max-width: 640px) { .lb-table td, .lb-table th { font-size: 15px; padding: 6px 4px; } }

/* quick match */
#m-quick small { display: block; font-size: 14px; letter-spacing: .02em; text-transform: none; color: #ffd0d2; min-height: 17px; font-family: var(--num); }
#m-quick small:empty { display: none; }
.qm-status { background: linear-gradient(var(--panel2), var(--panel)); border: 2px solid var(--gold2); padding: 14px 18px; text-align: center; }
.qm-status .qm-title { font-family: var(--gothic); font-size: clamp(24px, 5vw, 34px); color: var(--gold); text-shadow: 0 0 14px rgba(217,168,69,.4); }
.qm-status .qm-sub { color: var(--bone); font-size: 17px; margin-top: 4px; line-height: 1.4; }
.qm-status .qm-actions { margin-top: 10px; }
.qm-status.found { border-color: #6fd57b; box-shadow: 0 0 22px rgba(111,213,123,.25); }
.qm-status.found .qm-title { color: #a5f2ad; text-shadow: 0 0 14px rgba(111,213,123,.4); }
.lseat.searching { animation: tgtpulse 1.6s ease-in-out infinite; }
@keyframes tgtpulse { 0%,100% { opacity: .35; } 50% { opacity: .75; } }

.qm-status .qm-queue { margin: 10px auto 0; display: inline-block; font-size: 16px; padding: 5px 14px; border: 2px solid #4a3326; background: #0c0709; color: var(--bone); }
.qm-status .qm-queue:empty { display: none; }
.qm-status .qm-queue::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 9px; vertical-align: middle; background: #d9a845; animation: pulse 1.2s infinite alternate; }
.qm-status .qm-queue.busy { border-color: #6fd57b; }
.qm-status .qm-queue.busy::before { background: #6fd57b; }

/* ---- pixel-art table + skull candle holders (mock) ---- */
#felt { box-shadow: 0 22px 50px #000; image-rendering: pixelated; }
.candle { width: 45px; height: 69px; margin: -62px 0 0 -22px; background: var(--candle-lit) no-repeat 0 0 / 45px 69px; image-rendering: pixelated; }
.candle::before { content: none !important; }
.candle .fl { left: 18px; bottom: auto; top: 7px; width: 9px; height: 12px; background: var(--flame) no-repeat 0 0 / 9px 12px; image-rendering: pixelated; border-radius: 0; filter: drop-shadow(0 0 7px rgba(255,170,60,.9)); box-shadow: none; }
.candle.out { background-image: var(--candle-out); }
.candle.now .fl { transform: scale(1.3); filter: drop-shadow(0 0 11px #ffb23a); }

/* emotes */
.emote-pop { position: fixed; top: 52px; right: 10px; z-index: 40; display: none; flex-direction: column; gap: 6px; background: var(--panel); border: 2px solid var(--gold2); padding: 8px; box-shadow: 0 6px 24px #000; }
.emote-pop.on { display: flex; }
.emote-pop .btn { text-align: left; white-space: nowrap; }
.emote-bubble { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); z-index: 30; background: #000d; border: 1px solid var(--gold); color: var(--bone); padding: 4px 10px; white-space: nowrap; font-size: clamp(13px, 2.2vmin, 17px); pointer-events: none; animation: emotepop 3.2s ease-out forwards; }
@keyframes emotepop { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 8% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }

/* ---------- drag and drop ---------- */
.hc { touch-action: none; user-select: none; -webkit-user-select: none; }
.hc.dragging { opacity: .25; }
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging .hc .tip { display: none; }
.dragghost { position: fixed; z-index: 9999; pointer-events: none; transform: translate(-50%, -55%) rotate(-5deg) scale(1.18); filter: drop-shadow(0 14px 18px rgba(0,0,0,.75)) drop-shadow(0 0 10px rgba(217,168,69,.6)); will-change: left, top; }
.dragghost.back { transition: left .24s ease-in, top .24s ease-in, opacity .24s; }
.seat.dropover .pc { transform: scale(1.1); filter: drop-shadow(0 0 16px #fff) drop-shadow(0 0 28px rgba(217,168,69,.9)); transition: transform .12s, filter .12s; }
#me-panel .mp.dropover { filter: drop-shadow(0 0 16px #fff) drop-shadow(0 0 28px rgba(217,168,69,.9)); transform: scale(1.04); transition: transform .12s, filter .12s; }

/* ---------- "You were haunted by ..." ---------- */
.haunted-banner { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); z-index: 96; max-width: 90vw; text-align: center; padding: 14px 26px 16px; background: rgba(8,14,26,.93); border: 2px solid #8fb4d6; box-shadow: 0 0 34px rgba(143,180,214,.55), inset 0 0 24px rgba(143,180,214,.18); color: #dbe9f7; pointer-events: none; animation: hauntin 3.2s ease forwards; }
.haunted-banner.kind { border-color: #9be08a; box-shadow: 0 0 34px rgba(155,224,138,.5), inset 0 0 24px rgba(155,224,138,.15); }
.haunted-banner .hb-ico { font-size: 38px; line-height: 1; filter: drop-shadow(0 0 10px #8fb4d6); animation: hauntfloat 1.6s ease-in-out infinite alternate; }
.haunted-banner .hb-main { font-family: var(--gothic); font-size: 26px; letter-spacing: 1px; margin-top: 4px; }
.haunted-banner .hb-main b { color: #fff; text-shadow: 0 0 10px #8fb4d6; }
.haunted-banner .hb-sub { font-size: 18px; margin-top: 4px; color: #b9cde0; }
.haunted-banner .hb-sub b { color: #8fb4d6; }
.haunted-banner.kind .hb-sub b { color: #9be08a; }
@keyframes hauntin { 0% { opacity: 0; transform: translate(-50%, 18px) scale(.94); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px); } }
@keyframes hauntfloat { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@media (max-width: 600px) { .haunted-banner { top: 14%; padding: 10px 14px; } .haunted-banner .hb-main { font-size: 20px; } .haunted-banner .hb-sub { font-size: 15px; } }

/* ---------- mobile ---------- */
.hc { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
@media (hover: none), (max-width: 900px) { .hc .tip { display: none !important; } }
@media (max-width: 900px) { .play .plabel { font-size: 12px; max-width: 120px; white-space: normal; line-height: 1.15; padding: 1px 4px; } }
@media (max-width: 640px) { .play .plabel { font-size: 11px; max-width: 104px; } .play .pc { box-shadow: 0 3px 8px #000; } }
