/* Yahtzee — Tafelronde. Dark, clean, responsive. One stylesheet. */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0}
button,input{font:inherit;color:inherit}
button{background:none;border:0;cursor:pointer}
a{color:inherit;text-decoration:none}
[hidden]{display:none!important}
h1,h2,h3,p{margin:0}
ul{margin:0;padding:0;list-style:none}
table{border-collapse:collapse}

:root{
  --bg:#0a0c11;--bg-2:#0e1118;--surface:#131722;--surface-2:#1a1f2c;
  --line:rgba(255,255,255,.09);--line-2:rgba(255,255,255,.16);
  --tx:#e9edf5;--tx-2:#98a2b6;--tx-3:#626c80;
  --gold:#f2b840;--gold-2:#d0951d;--gold-dim:rgba(242,184,64,.14);
  --green:#3ddc97;--green-2:#28b479;
  --f-ui:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  --f-display:"Fraunces",Georgia,serif;
  --r:14px;--r-lg:20px;
  color-scheme:dark;
}
body{
  font-family:var(--f-ui);color:var(--tx);
  background:
    radial-gradient(1100px 620px at 50% -12%, rgba(242,184,64,.12), transparent 60%),
    radial-gradient(820px 560px at 92% 118%, rgba(61,220,151,.08), transparent 60%),
    var(--bg);
  min-height:100vh;min-height:100dvh;-webkit-font-smoothing:antialiased;
}
.game-body{overflow:hidden}

/* ---------- shared bits ---------- */
.panel{
  background:linear-gradient(180deg,var(--surface),var(--bg-2));
  border:1px solid var(--line);border-radius:var(--r-lg);
  padding:22px;
  box-shadow:0 20px 50px -24px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.04);
}
.muted{color:var(--tx-2)}
.center{text-align:center}
.brand-mini{font-weight:800;letter-spacing:.14em;font-size:12px;color:var(--tx-3);transition:color .15s}
.brand-mini:hover{color:var(--gold)}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:11px 20px;border-radius:999px;font-weight:700;font-size:14px;
  border:1px solid transparent;transition:transform .12s,filter .15s,background .15s,border-color .15s;
  width:100%;
}
.btn:active{transform:translateY(1px) scale(.99)}
.btn[disabled]{opacity:.45;cursor:not-allowed}
.btn-primary{background:linear-gradient(135deg,var(--gold),var(--gold-2));color:#241a04;box-shadow:0 12px 26px -12px rgba(242,184,64,.7)}
.btn-primary:hover:not([disabled]){filter:brightness(1.07)}
.btn-ghost{background:var(--surface-2);color:var(--tx);border-color:var(--line-2)}
.btn-ghost:hover:not([disabled]){background:#232a3a}
.btn.is-busy{position:relative;color:transparent}
.btn.is-busy::after{content:"";position:absolute;width:16px;height:16px;border:2px solid rgba(0,0,0,.3);border-top-color:#241a04;border-radius:50%;animation:spin .6s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.btn-icon{
  width:38px;height:38px;display:grid;place-items:center;border-radius:11px;
  border:1px solid var(--line-2);background:var(--surface);color:var(--tx-2);font-size:15px;
  transition:background .15s,color .15s;
}
.btn-icon:hover{background:var(--surface-2);color:var(--tx)}
.linkbtn{color:var(--tx-3);font-size:12.5px;margin-top:4px;width:100%;text-align:center}
.linkbtn:hover{color:#fb7185}

.field{
  width:100%;padding:11px 13px;background:var(--bg-2);color:var(--tx);
  border:1px solid var(--line-2);border-radius:11px;font-size:15px;outline:none;
  transition:border-color .15s,box-shadow .15s;
}
.field:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(242,184,64,.18)}
.field-code{text-transform:uppercase;letter-spacing:.4em;text-align:center;font-weight:800;font-size:20px}
.field-label{display:block;font-size:11px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;color:var(--tx-3);margin:12px 0 5px}

/* ---------- lobby page ---------- */
.lobby-page{max-width:940px;margin:0 auto;padding:min(9vh,64px) 18px 60px}
.lp-head{text-align:center;margin-bottom:30px}
.lp-title{font-family:var(--f-display);font-weight:700;font-size:clamp(38px,8vw,60px);line-height:1;margin:14px 0 0;
  background:linear-gradient(175deg,#fff 8%,#ffe2a5 46%,var(--gold-2));-webkit-background-clip:text;background-clip:text;color:transparent}
.lp-sub{color:var(--tx-2);margin-top:12px}
.lp-cards{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.lp-cards h2{font-family:var(--f-display);font-weight:600;font-size:20px;margin-bottom:4px}
.lp-cards .muted{font-size:13.5px;margin-bottom:6px}
.lp-cards form{display:flex;flex-direction:column}
.lp-cards .btn{margin-top:16px}
.lp-error{color:#fb7185;font-size:13.5px;min-height:1.2em;text-align:center;margin-top:14px}
.rules{margin-top:26px;padding:0;overflow:hidden}
.rules-toggle{display:flex;width:100%;align-items:center;justify-content:space-between;padding:20px 22px}
.rules-toggle h2{font-family:var(--f-display);font-weight:600;font-size:18px}
.rules-toggle .chev{color:var(--tx-3);transition:transform .2s}
.rules-toggle[aria-expanded="true"] .chev{transform:rotate(180deg)}
.rules-body{padding:0 22px 22px;display:flex;flex-direction:column;gap:10px;color:var(--tx-2);font-size:13.5px;line-height:1.6}
.rules-body b{color:var(--tx)}
.lp-foot{text-align:center;color:var(--tx-3);font-size:12px;margin-top:30px}
@media (max-width:720px){.lp-cards{grid-template-columns:1fr}}

/* ---------- game board ---------- */
#app{height:100dvh;display:flex;flex-direction:column}
.topbar{
  flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 14px;border-bottom:1px solid var(--line);background:rgba(10,12,17,.9);
}
.tb-left,.tb-right{display:flex;align-items:center;gap:8px}
.code-chip{
  font-family:ui-monospace,Menlo,monospace;font-size:12px;font-weight:800;letter-spacing:.14em;
  padding:6px 10px;border-radius:9px;border:1px solid var(--line-2);background:var(--surface);color:var(--tx);
}
.code-chip .cc-label{color:var(--tx-3);font-weight:600;letter-spacing:.05em;margin-right:3px}
.code-chip:hover{background:var(--surface-2)}
.turn-banner{
  flex:1 1 auto;text-align:center;min-width:0;font-size:13px;font-weight:700;color:var(--tx-2);
  padding:6px 10px;border-radius:999px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  transition:background .25s,color .25s,box-shadow .25s;
}
.turn-banner.is-you{color:#052e16;background:linear-gradient(135deg,var(--green),var(--green-2));box-shadow:0 0 22px -4px rgba(61,220,151,.6)}

.board{flex:1 1 auto;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.sheet-wrap{flex:1 1 auto;overflow:auto;padding:12px}

.sheet{width:100%;max-width:640px;margin:0 auto;font-size:13.5px}
.sheet th,.sheet td{padding:7px 8px;border-bottom:1px solid var(--line);text-align:right}
.sheet th.cat,.sheet td.cat{text-align:left;color:var(--tx-2);font-weight:500;white-space:nowrap}
.sheet thead th{
  position:sticky;top:-12px;background:var(--bg);z-index:2;
  font-weight:700;color:var(--tx);text-align:right;padding-top:10px;padding-bottom:10px;
}
.sheet thead th.cat{text-align:left}
.sheet thead th.me{color:var(--gold)}
.sheet thead th .pcol{display:flex;flex-direction:column;align-items:flex-end;gap:1px}
.sheet thead th .pdot{width:6px;height:6px;border-radius:50%;background:var(--tx-3)}
.sheet thead th .pdot.on{background:var(--green);box-shadow:0 0 7px var(--green)}
.sheet .sec-row td{
  background:var(--surface-2);color:var(--tx-3);font-size:10.5px;font-weight:800;
  letter-spacing:.1em;text-transform:uppercase;text-align:left;padding:6px 8px;
}
.sheet .val{font-variant-numeric:tabular-nums;color:var(--tx)}
.sheet .val.empty{color:var(--tx-3)}
.sheet td.pcell{transition:background .12s}
.sheet td.pick{cursor:pointer;color:var(--gold);font-weight:700;background:var(--gold-dim);border-radius:6px}
.sheet td.pick:hover{background:rgba(242,184,64,.26)}
.sheet td.pick.zero{color:var(--tx-3);background:rgba(255,255,255,.05)}
.sheet .subtotal td,.sheet .total td{font-weight:800;color:var(--tx)}
.sheet .total td{font-size:15px;border-top:2px solid var(--line-2)}
.sheet .bonus-hit .val{color:var(--green)}

/* dice tray */
.tray{
  flex:0 0 auto;border-top:1px solid var(--line);background:#101420;
  padding:14px 14px calc(14px + env(safe-area-inset-bottom));
  display:flex;flex-direction:column;gap:12px;align-items:center;
}
.dice-row{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.die{
  --ds:clamp(44px,13vw,60px);
  width:var(--ds);height:var(--ds);border-radius:calc(var(--ds)*.24);
  background:linear-gradient(155deg,#fff,#e6ebf2);color:#1a2030;
  display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);
  padding:calc(var(--ds)*.15);gap:calc(var(--ds)*.06);position:relative;
  box-shadow:0 8px 16px -8px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.9);
  transition:transform .16s cubic-bezier(.2,.8,.3,1),box-shadow .16s,outline-color .16s;
  outline:2px solid transparent;outline-offset:2px;
}
.die.clickable{cursor:pointer}
.die.clickable:hover{transform:translateY(-3px)}
.die.held{outline-color:var(--gold);box-shadow:0 0 20px -4px rgba(242,184,64,.7), inset 0 1px 0 rgba(255,255,255,.9);transform:translateY(-4px)}
.die.rolling{animation:diroll .5s ease}
@keyframes diroll{0%{transform:rotate(0) scale(1)}40%{transform:rotate(160deg) scale(.85)}100%{transform:rotate(360deg) scale(1)}}
.die .pips{display:contents}
.die .pip{background:#1a2030;border-radius:50%;align-self:center;justify-self:center;width:78%;height:78%}
.die .pip.hidden{visibility:hidden}
.die.placeholder{background:#1a2030;box-shadow:inset 0 0 0 1px var(--line-2);opacity:.55}
.die.placeholder .pip{background:var(--tx-3)}

.tray-actions{display:flex;flex-direction:column;align-items:center;gap:6px;width:100%;max-width:320px}
.tray-hint{font-size:12px;color:var(--tx-3);min-height:1.1em;text-align:center}

/* log panel */
.log-panel{
  position:fixed;top:0;right:0;bottom:0;width:min(340px,86vw);z-index:40;
  background:linear-gradient(180deg,var(--surface),var(--bg-2));border-left:1px solid var(--line);
  transform:translateX(100%);transition:transform .28s cubic-bezier(.4,0,.2,1);
  display:flex;flex-direction:column;
}
.log-panel.open{transform:none}
.log-head{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--line)}
.log-head h2{font-size:15px;font-weight:800}
.log-list{flex:1;overflow-y:auto;padding:12px 16px}
.log-list li{font-size:12.5px;color:var(--tx-2);padding:6px 0;border-bottom:1px solid rgba(255,255,255,.05);line-height:1.45}
.log-list li .time{color:var(--tx-3);font-size:11px;margin-right:6px}
.scrim{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:35}

/* overlays */
.overlay{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:18px;background:rgba(7,9,16,.95)}
.overlay .ov-panel{width:100%;max-width:380px;display:flex;flex-direction:column;gap:10px;animation:panelIn .22s ease-out both}
@keyframes panelIn{from{transform:translateY(12px) scale(.97)}to{transform:none}}
.ov-panel h2{font-family:var(--f-display);font-weight:600;font-size:22px}
.ov-panel .btn{margin-top:6px}
.share-row{display:flex;gap:8px}
.share-row .field{font-size:12px}
.share-row .btn{width:auto;flex:0 0 auto;padding:11px 14px}
.lobby-players{display:flex;flex-direction:column;gap:8px;margin:6px 0}
.lobby-players li{display:flex;align-items:center;gap:10px;padding:9px 11px;border-radius:11px;background:rgba(255,255,255,.04);border:1px solid var(--line)}
.avatar{width:28px;height:28px;border-radius:50%;flex:0 0 auto;display:grid;place-items:center;font-weight:800;font-size:12px;color:#fff}
.tag-host{font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)}
.end-emoji{font-size:52px}
.end-scores{display:flex;flex-direction:column;gap:6px;margin:8px 0}
.end-scores li{display:flex;justify-content:space-between;padding:8px 12px;border-radius:10px;background:rgba(255,255,255,.04);font-size:14px}
.end-scores li.win{background:var(--gold-dim);color:var(--gold);font-weight:800}
.end-scores li .es-total{font-variant-numeric:tabular-nums}

.toast{
  position:fixed;left:50%;bottom:calc(120px + env(safe-area-inset-bottom));transform:translate(-50%,16px);
  z-index:60;padding:10px 16px;border-radius:11px;font-size:13.5px;font-weight:600;
  background:var(--surface-2);border:1px solid var(--line-2);color:#fff;box-shadow:0 16px 40px -16px #000;
  opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;max-width:90vw;text-align:center;
}
.toast.show{opacity:1;transform:translate(-50%,0)}
.toast.err{background:#3b1220;border-color:#7f1d3a;color:#fecdd3}

.confetti{position:fixed;top:-14px;width:9px;height:14px;z-index:70;pointer-events:none;border-radius:2px;animation:fall linear forwards}
@keyframes fall{to{transform:translateY(110vh) rotate(720deg);opacity:.2}}

@media (max-width:520px){
  .sheet{font-size:12.5px}
  .sheet th,.sheet td{padding:6px 5px}
  .topbar{padding:8px 10px;flex-wrap:wrap}
  .turn-banner{order:3;flex-basis:100%;margin-top:4px}
}
@media (prefers-reduced-motion:reduce){
  *{transition-duration:.01ms!important;animation-duration:.01ms!important}
}

/* ---------- open games (public rooms) ---------- */
.open-games{margin-top:20px}
.og-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.og-head h2{font-family:var(--f-display);font-weight:600;font-size:18px}
.og-refresh{width:34px;height:34px;border-radius:10px;border:1px solid var(--line-2);background:var(--surface-2);color:var(--tx-2);font-size:15px;transition:background .15s,transform .3s}
.og-refresh:hover{background:#232a3a;color:var(--tx)}
.og-refresh.spin{transform:rotate(360deg)}
.og-hint{font-size:13px;margin:6px 0 12px}
.og-list{display:flex;flex-direction:column;gap:8px}
.og-list li{display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:12px;background:var(--surface-2);border:1px solid var(--line)}
.og-list .og-av{width:30px;height:30px;border-radius:50%;flex:0 0 auto;display:grid;place-items:center;font-weight:800;font-size:12px;color:#fff}
.og-list .og-meta{flex:1;min-width:0;line-height:1.2}
.og-list .og-host{font-weight:700;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.og-list .og-sub{font-size:11.5px;color:var(--tx-3)}
.og-list .og-join{flex:0 0 auto;width:auto;padding:8px 16px;font-size:13px}
.og-empty{font-size:13px;padding:6px 0}

/* ---------- lobby: public toggle + share ---------- */
.pub-toggle{display:flex;gap:10px;align-items:flex-start;padding:12px;border-radius:12px;background:rgba(255,255,255,.04);border:1px solid var(--line);cursor:pointer;margin:6px 0}
.pub-toggle input{width:18px;height:18px;margin-top:1px;accent-color:var(--gold);flex:0 0 auto}
.pub-toggle small{display:block;font-size:11.5px;margin-top:2px;line-height:1.4}
.code-big{font-family:ui-monospace,Menlo,monospace;font-weight:800;letter-spacing:.32em;font-size:26px;text-align:center;color:var(--gold);background:var(--bg-2);border:1px solid var(--line-2);border-radius:12px;padding:12px;margin:2px 0}
.share-btns{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.share-btns .btn{width:100%;font-size:13px;padding:10px 12px}
.share-btns .btn.full{grid-column:1/-1}

