@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; }
.phasebar { margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); }
.phase, .phase-tag { padding: 7px 16px; 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%); }
.phase.on { background: linear-gradient(180deg, #ffd14d, #f59e0b); color: #1a1205; }
.phase-tag { background: var(--cyan); color: #04202a; }
.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: 11px; }
.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: 13px; margin-left: auto; text-align: right; }
.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); } }

#dice { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); display: flex; gap: 22px; pointer-events: none; }
.dset { display: flex; gap: 8px; }
.die { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 30px; border: 3px solid #fff; box-shadow: 0 8px 20px rgba(0,0,0,.5); animation: roll .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.die.att { background: #e0284a; color: #fff; }
.die.def { background: #f2f6f8; color: #0a2633; }
.die.lost { opacity: .45; filter: grayscale(.6); }
@keyframes roll { from { transform: rotate(-200deg) scale(.2); opacity: 0; } }
#dice.fade { transition: opacity .6s; 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: 11px; 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 9px; font-size: 11px; }
  .turninfo { min-width: 70px; padding: 2px 8px; }
  #players { top: 56px; width: 168px; gap: 4px; }
  .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: 10px; }
  #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: 11px; }
  .controls { gap: 6px; }
  .controls button { min-height: 44px; padding: 6px 12px; font-size: 14px; }
  #players { max-height: calc(100vh - 56px - 150px); overflow: auto; }
  .die { width: 42px; height: 42px; font-size: 24px; }
}
@media (max-height: 520px) and (orientation: landscape) { #players { display: flex; } }
@media (prefers-reduced-motion: reduce) { .die, .pl, #toast { animation: none !important; transition: none !important; } }
