@font-face { font-family: Rubik; src: url(assets/Rubik-latin.woff2) format('woff2'); font-weight: 300 900; font-display: swap; }
:root { --ink: #e8fbff; --muted: #8fb7c4; --cyan: #25dfeb; --gold: #f4e321; --red: #ff4d6d; --panel: rgba(6, 22, 32, .86); --line: rgba(120, 230, 240, .55); --safe-l: env(safe-area-inset-left); --safe-r: env(safe-area-inset-right); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #03080e; color: var(--ink); font-family: Rubik, 'Segoe UI', system-ui, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
#table { position: fixed; inset: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

.chip { min-width: 44px; min-height: 44px; padding: 6px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); font-weight: 800; font-size: 18px; box-shadow: 0 4px 0 rgba(0,0,0,.35); backdrop-filter: blur(6px); }
.chip:active { transform: translateY(2px); }
.panel { background: var(--panel); border: 2px solid var(--line); border-radius: 20px; box-shadow: 0 8px 30px rgba(0,0,0,.45), inset 0 0 30px rgba(37,223,235,.06); backdrop-filter: blur(8px); }

.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, var(--safe-l)); right: max(12px, var(--safe-r)); display: flex; align-items: center; gap: 10px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.phasewrap { margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; max-width: calc(100vw - 280px); pointer-events: none; }
.phasewrap > * { pointer-events: auto; }
.phasebar { display: flex; align-items: center; gap: 3px; padding: 5px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); }
.who { display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 8px; margin-right: 4px; border-radius: 11px; background: color-mix(in srgb, var(--c, #888) 22%, transparent); border: 2px solid var(--c, #888); font-size: 13px; max-width: 190px; }
.who i { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--c, #888); box-shadow: 0 0 10px var(--c, #888); }
.who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase, .phase-tag { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 11px; font-weight: 900; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); transition: background .25s, color .25s; }
.phase em { font-style: normal; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; border: 2px solid currentColor; font-size: 12px; letter-spacing: 0; }
.phase.done { color: #6fd7a0; }
.phase.done em { font-size: 0; background: #3df08a; border-color: #3df08a; }
.phase.done em::after { content: '\2713'; font-size: 12px; color: #04202a; }
.phase.on { background: linear-gradient(180deg, #ffd14d, #f59e0b); color: #1a1205; box-shadow: 0 0 18px rgba(255, 200, 60, .45); }
.phase.setup { opacity: .45; }
.phase .cnt { font-size: 13px; padding: 1px 7px; border-radius: 8px; background: #1a1205; color: #ffd14d; letter-spacing: 0; }
.phase .cnt:empty { display: none; }
.sep { color: var(--muted); font-style: normal; font-weight: 900; opacity: .6; }
.phase-tag { background: var(--cyan); color: #04202a; }
.phase-tag[hidden] { display: none; }
#instruction { max-width: min(760px, 100%); padding: 7px 16px; border-radius: 12px; background: rgba(4, 16, 24, .9); border: 2px solid color-mix(in srgb, var(--c, #8fb7c4) 60%, transparent); font-weight: 700; font-size: 15px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#instruction.mine { border-color: var(--gold); color: #fff6c8; box-shadow: 0 0 0 3px rgba(244,227,33,.18), 0 6px 20px rgba(0,0,0,.4); }
#instruction[hidden] { display: none; }
.turninfo { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 12px; background: var(--panel); border: 2px solid var(--line); min-width: 92px; }
.turninfo b { color: var(--ink); font-size: 14px; }
#timer.low { color: var(--red); font-weight: 900; }

#players { position: absolute; right: max(12px, var(--safe-r)); top: 72px; display: flex; flex-direction: column; gap: 6px; width: 220px; }
.pl { flex: none; display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center; padding: 7px 10px 7px 0; border-radius: 14px; background: var(--panel); border: 2px solid rgba(255,255,255,.12); overflow: hidden; transition: transform .2s, border-color .2s; }
.pl .bar { height: 100%; background: var(--c); }
.pl b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl small { color: var(--muted); font-size: 12px; }
.pl .num { text-align: right; font-weight: 900; font-size: 15px; }
.pl.active { border-color: var(--c); transform: translateX(-8px); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); }
.pl.out { opacity: .4; filter: grayscale(.8); }

#actions { position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, calc(100vw - 32px)); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.actor { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.actor b { font-size: 16px; }
.actor small { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.actor .skip { min-height: 40px; padding: 4px 14px; border-radius: 12px; border: 2px solid #fff1b8; background: linear-gradient(180deg, #ffd14d, #f59e0b); color: #1a1205; font-weight: 900; font-size: 14px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.actor .skip small { margin: 0; font-size: 12px; color: #4a3505; letter-spacing: .04em; }
.actor .skip[hidden] { display: none; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--c, #888); box-shadow: 0 0 10px var(--c, #888); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls button, .sheet button { min-height: 46px; padding: 8px 16px; border-radius: 14px; border: 2px solid var(--line); background: rgba(10, 45, 60, .9); font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.controls button:disabled, .sheet button:disabled { opacity: .4; cursor: default; }
.controls button.primary, .sheet button.primary { background: linear-gradient(180deg, #45f0f8, #14a9b8); color: #022028; border-color: #c9fbff; }
.controls button.danger { background: linear-gradient(180deg, #ff7a8f, #e0284a); color: #fff; border-color: #ffd0d8; }
.controls button.next { margin-left: auto; background: linear-gradient(180deg, #ffd14d, #f59e0b); color: #1a1205; border-color: #fff1b8; }
.stepper { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 14px; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.15); }
.stepper button { min-width: 46px; padding: 6px; font-size: 20px; box-shadow: none; }
.stepper b { min-width: 46px; text-align: center; font-size: 20px; }
.odds { font-size: 13px; color: var(--muted); }
.odds b { color: var(--gold); font-size: 16px; }
.dicepick { display: flex; gap: 4px; }
.dicepick button { min-width: 46px; padding: 6px; }
.dicepick button.on { background: var(--red); color: #fff; border-color: #fff; }

.cards-chip { position: absolute; left: max(12px, var(--safe-l)); bottom: max(12px, env(safe-area-inset-bottom)); font-size: 16px; }
.cards-chip.must { border-color: var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(244,227,33,.3); } }

/* battle panel next to the fight: names, dice in the owners' colours, result */
#battle { position: absolute; left: 50%; top: 30%; transform: translateX(-50%) scale(.9); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 12px 9px; border-radius: 16px; background: rgba(4, 16, 24, .93); border: 2px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.55); pointer-events: none; opacity: 0; transition: opacity .2s, transform .2s; }
#battle.show { opacity: 1; transform: translateX(-50%) scale(1); }
#battle::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; background: rgb(4, 16, 24); border: 2px solid var(--line); border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
.bt-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.bt-head .a { color: var(--ca); } .bt-head .d { color: var(--cd); } .bt-head b { color: var(--muted); }
.bt-dice { display: flex; align-items: center; gap: 10px; }
.bt-dice .vs { font-style: normal; font-weight: 900; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.dset { display: flex; gap: 6px; }
.die { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 900; font-size: 23px; border: 3px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.5); animation: roll .5s cubic-bezier(.2, 1.4, .4, 1) both; transition: opacity .3s, filter .3s, transform .3s; }
.die.att { background: var(--ca); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.die.def { background: var(--cd); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#battle.lighta .die.att, #battle.lightd .die.def { color: #0a2633; text-shadow: none; }
#battle.resolved .die[data-lost="true"] { opacity: .35; filter: grayscale(.7); transform: scale(.86); }
#battle .die[data-lost="none"] { opacity: .5; border-style: dashed; }
#battle.resolved .die[data-lost="false"] { box-shadow: 0 0 0 3px #fff, 0 0 16px #fff; }
@keyframes roll { from { transform: rotate(-200deg) scale(.2); opacity: 0; } }
.bt-res { display: flex; align-items: center; gap: 10px; min-height: 24px; font-weight: 900; }
.bt-res:empty { display: none; }
.bt-res span { font-size: 21px; padding: 0 8px; border-radius: 8px; color: #fff; background: #b3203c; }
.bt-res span.zero { background: rgba(255,255,255,.12); color: var(--muted); }
.bt-res em { font-style: normal; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.bt-res em.win { font-size: 16px; color: var(--gold); letter-spacing: .06em; }

/* turn banner and summary */
#banner { position: absolute; left: 50%; top: 26%; transform: translate(-50%, -12px); z-index: 25; display: flex; align-items: stretch; gap: 14px; padding: 14px 26px 14px 14px; border-radius: 20px; background: rgba(4, 16, 24, .94); border: 3px solid var(--c, var(--line)); box-shadow: 0 0 40px color-mix(in srgb, var(--c, #25dfeb) 35%, transparent), 0 12px 40px rgba(0,0,0,.6); pointer-events: none; opacity: 0; transition: opacity .3s, transform .3s; max-width: calc(100vw - 32px); }
#banner.show { opacity: 1; transform: translate(-50%, 0); }
#banner .sw { flex: none; width: 10px; border-radius: 6px; background: var(--c); box-shadow: 0 0 14px var(--c); }
#banner div { display: flex; flex-direction: column; gap: 2px; }
#banner b { font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
#banner span { font-size: 18px; font-weight: 800; color: var(--gold); }
#banner small { font-size: 13px; color: var(--muted); }
#summary { position: absolute; left: max(12px, var(--safe-l)); top: 70px; z-index: 15; width: 290px; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 10px 16px; border-radius: 14px; background: rgba(4, 16, 24, .92); border: 2px solid var(--c, var(--line)); border-left-width: 6px; font-size: 13px; color: var(--ink); pointer-events: none; opacity: 0; transform: translateX(-12px); transition: opacity .3s, transform .3s; }
#summary.show { opacity: 1; transform: none; }
#summary b { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--c); }
#summary .warn { color: #ff9cad; font-weight: 700; }

/* event ticker */
#ticker { position: absolute; left: max(12px, var(--safe-l)); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px); z-index: 12; width: min(330px, 28vw); display: flex; flex-direction: column-reverse; gap: 3px; }
#ticker[hidden] { display: none; }
.tk { display: flex; align-items: center; gap: 7px; min-height: 26px; padding: 3px 9px; border-radius: 9px; border: 1px solid rgba(255,255,255,.1); background: rgba(4, 16, 24, .78); color: var(--ink); font-size: 12px; font-weight: 600; text-align: left; }
.tk span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tk:nth-child(n+4) { opacity: .72; } .tk:nth-child(n+6) { opacity: .5; }
.tk.new { border-color: color-mix(in srgb, var(--c) 70%, transparent); animation: tkin .35s ease-out; }
.tk.capture { color: #ffe680; font-weight: 800; } .tk.turn { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; } .tk.summary { font-weight: 800; }
.tk:not(:disabled):hover { border-color: var(--c); }
.tk:disabled { cursor: default; }
@keyframes tkin { from { transform: translateX(-10px); opacity: 0; } }

#toast { position: absolute; left: 50%; top: 76px; transform: translate(-50%, -20px); padding: 10px 18px; border-radius: 14px; background: var(--panel); border: 2px solid var(--gold); font-weight: 900; opacity: 0; transition: .3s; pointer-events: none; text-align: center; max-width: 80vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(2, 8, 14, .7); backdrop-filter: blur(4px); padding: 16px; }
.overlay[hidden] { display: none; }
.sheet { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 20px 22px; border-radius: 22px; background: rgba(6, 26, 38, .97); border: 3px solid var(--line); box-shadow: 0 10px 0 rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 12px; }
.sheet.center { text-align: center; align-items: center; }
.sheet h2 { margin: 0; font-size: 26px; font-weight: 900; text-transform: uppercase; }
.sheet p { margin: 0; color: var(--muted); }
.sheet label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.sheet label.check { justify-content: flex-start; }
.sheet select, .sheet input[type=range] { min-height: 40px; min-width: 50%; accent-color: var(--cyan); background: rgba(0,0,0,.35); color: var(--ink); border: 2px solid var(--line); border-radius: 10px; }
.sheet input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--cyan); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; }
#hand-cards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.card { width: 92px; height: 128px; border-radius: 12px; border: 3px solid rgba(255,255,255,.6); background: linear-gradient(160deg, #0f3f52, #062230); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 8px 6px; font-size: 12px; font-weight: 700; text-align: center; }
.card .sym { font-size: 38px; }
.card.on { border-color: var(--gold); transform: translateY(-6px); box-shadow: 0 0 16px rgba(244,227,33,.5); }
.card.mine { background: linear-gradient(160deg, #165a40, #062a1c); }
#help-text { display: flex; flex-direction: column; gap: 8px; color: var(--ink); font-size: 14px; line-height: 1.45; }
#help-text b { color: var(--cyan); }
#rotate { position: fixed; inset: 0; z-index: 99; display: grid; place-content: center; gap: 12px; text-align: center; background: #03080e; font-weight: 800; }
#rotate[hidden] { display: none; }
#rotate b { font-size: 64px; color: var(--cyan); }

/* tablets and narrow windows */
@media (max-width: 1000px) { #players { width: 190px; } }
/* phones in landscape (S24 Ultra ~ 915x412 / 780x360 CSS px) */
@media (max-height: 520px) {
  .hud-top { top: max(6px, env(safe-area-inset-top)); gap: 6px; }
  .phase, .phase-tag { padding: 5px 8px; font-size: 12px; gap: 4px; }
  .phase em { display: none; } .who { max-width: 110px; font-size: 12px; padding: 3px 8px 3px 6px; }
  .phasewrap { gap: 4px; max-width: calc(100vw - 200px); }
  #instruction { font-size: 12px; padding: 4px 10px; }
  #ticker { width: min(260px, 34vw); bottom: calc(max(8px, env(safe-area-inset-bottom)) + 52px); }
  .tk { min-height: 22px; font-size: 12px; } .tk:nth-child(n+4) { display: none; }
  #summary { top: 52px; width: 230px; font-size: 12px; }
  #banner b { font-size: 20px; } #banner span { font-size: 14px; } #banner { padding: 10px 18px 10px 10px; top: 22%; }
  .actor .skip small { display: none; }
  .turninfo { min-width: 70px; padding: 2px 8px; }
  #players { top: 66px; width: 168px; gap: 4px; } /* clears the menu/help chips (44 px + shadow) on landscape phones */
  .pl { padding: 4px 8px 4px 0; border-radius: 10px; }
  .pl b { font-size: 12px; } .pl small { display: none; } .pl .num { font-size: 13px; }
  .pl.active small { display: block; font-size: 12px; }
  #actions { left: auto; right: max(10px, var(--safe-r)); transform: none; bottom: max(8px, env(safe-area-inset-bottom)); width: min(430px, 56vw); padding: 8px 10px; gap: 6px; border-radius: 16px; }
  .actor b { font-size: 14px; } .actor small { font-size: 12px; }
  .controls { gap: 6px; }
  .controls button { min-height: 44px; padding: 6px 12px; font-size: 14px; }
  #players { max-height: calc(100vh - 66px - 150px); overflow: auto; }
  .die { width: 30px; height: 30px; font-size: 17px; border-width: 2px; border-radius: 8px; }
  .bt-res span { font-size: 16px; }
}
@media (max-height: 520px) and (orientation: landscape) { #players { display: flex; } }
@media (max-width: 1000px) { .phasewrap { max-width: calc(100vw - 230px); } .who { max-width: 130px; } }
@media (prefers-reduced-motion: reduce) { .die, .pl, #toast, #banner, #summary, #battle, .tk { animation: none !important; transition: none !important; } }
body.still .die, body.still #banner, body.still #summary, body.still #battle, body.still .tk { animation: none !important; transition: none !important; }
