/* Dice Delve: chalk on slate. One dark world, one amber torch. */
body{background:#14181c;color:#e9e4d4}
.game-header{background:#1d2329;color:#e9e4d4;padding:.6rem 1rem;display:flex;justify-content:space-between;align-items:center}
.game-header a,.game-tag{color:#cfc9b8;font-size:.85rem;text-decoration:none}
.game-title h1{color:#e9e4d4;font-size:1.25rem;margin:.1rem 0 .6rem}
.game-title p,.game-title a{color:#9aa3ab;font-size:.78rem}
.pip-actions .btn{background:#262e35;color:#e9e4d4;border:1px solid #3a444d}

.dd{--chalk:#e9e4d4;--dim:#7d8791;--amber:#f2b04a;--red:#ef6f5e;--blue:#7fc4e8;--ink:#14181c;--slate:#1d2329;--slate2:#262e35;--line:#3a444d;
  position:relative;display:flex;flex-direction:column;gap:6px;width:100%;
  height:clamp(560px,calc(100svh - 210px),720px);
  background:var(--slate);border:2px solid var(--line);border-radius:14px;overflow:hidden;
  padding:8px 8px calc(8px + env(safe-area-inset-bottom));
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:var(--chalk);
  user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;touch-action:none}
.dd *{box-sizing:border-box}
.dd button{font:inherit;color:inherit;cursor:pointer;touch-action:manipulation}
.dd button:focus-visible{outline:3px solid var(--amber);outline-offset:2px}
.dd-noscript{padding:2rem;text-align:center}

/* HUD */
.dd-hud{display:grid;grid-template-columns:1fr auto;grid-template-areas:"hp tools" "info tools" "pool pool";gap:2px 8px;align-items:center}
.hp{grid-area:hp;display:flex;align-items:center;gap:8px}
.hp-bar{flex:1;height:12px;background:#0f1316;border:2px solid var(--chalk);border-radius:3px;overflow:hidden}
.hp-bar i{display:block;height:100%;width:100%;background:var(--chalk);transition:width .25s}
.dd-hud.low .hp-bar i{background:var(--red)}
.hp span{font-weight:800;font-size:.85rem;min-width:84px;text-align:right}
.info{grid-area:info;display:flex;justify-content:space-between;font-size:.76rem;color:#b9b4a4}
.tools{grid-area:tools;display:flex;gap:4px}
.ico{width:44px;height:44px;border-radius:10px;border:2px solid var(--line);background:var(--slate2);display:grid;place-items:center;color:var(--chalk);padding:0}
.ico svg{width:24px;height:24px}
.pool{grid-area:pool;display:flex;gap:5px;flex-wrap:wrap;min-height:14px;align-items:center}
.pd{width:13px;height:13px;border-radius:3px;border:2px solid var(--chalk);background:var(--chalk);display:inline-block}
.pd.spent{background:transparent;border-color:var(--dim);opacity:.7}
.pd.k-forged{border-color:var(--amber)}.pd.k-thorn{border-color:#9bd48a}.pd.k-leech{border-color:var(--red)}
.pd.k-ember{border-color:#ff9a3c}.pd.k-echo{border-color:var(--blue)}.pd.k-bulwark{border-color:#b79cf0}
.pd:not(.spent).k-forged{background:var(--amber)}.pd:not(.spent).k-thorn{background:#9bd48a}.pd:not(.spent).k-leech{background:var(--red)}
.pd:not(.spent).k-ember{background:#ff9a3c}.pd:not(.spent).k-echo{background:var(--blue)}.pd:not(.spent).k-bulwark{background:#b79cf0}

/* Stage */
.dd-stage{position:relative;flex:1 1 0;min-height:150px;border-radius:10px;overflow:hidden;border:2px solid var(--line);touch-action:none}
.dd-stage canvas{position:absolute;left:0;top:0;display:block}
.flash{position:absolute;inset:0;pointer-events:none;box-shadow:inset 0 0 0 0 rgba(239,111,94,0);opacity:0}
.flash.go{animation:ddflash .35s ease-out}
@keyframes ddflash{0%{opacity:1;box-shadow:inset 0 0 60px 14px rgba(239,111,94,.7)}100%{opacity:0;box-shadow:inset 0 0 60px 14px rgba(239,111,94,0)}}
.dd-hint{font-size:.78rem;color:#cfc9b8;text-align:center;min-height:2.2em;line-height:1.15;display:flex;align-items:center;justify-content:center;padding:0 4px}

/* Slots */
.dd-slots{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.slot{border:2px dashed var(--dim);border-radius:10px;padding:5px;min-height:92px;display:flex;flex-direction:column;gap:3px;background:rgba(0,0,0,.18);transition:background .12s,border-color .12s}
.slot.hot{border-color:var(--amber);background:rgba(242,176,74,.14);border-style:solid}
.s-atk{color:var(--amber)}.s-shd{color:var(--blue)}.s-mov{color:#b9d9a6}
.slot-h{display:flex;align-items:center;gap:4px;font-weight:800;font-size:.8rem}
.slot-h svg{width:18px;height:18px}
.slot-h .sv{margin-left:auto;font-style:normal;font-size:1.15rem;color:var(--chalk)}
.slot-dice{display:flex;flex-wrap:wrap;gap:4px;flex:1;align-content:flex-start}
.slot-dice .die{width:44px;height:44px;border-radius:9px}
.slot-note{font-size:.66rem;color:#a9a393;min-height:.9em;line-height:1}

/* Tray */
.dd-tray{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;align-content:center;min-height:116px;padding:6px;border-radius:10px;border:2px solid transparent;transition:background .12s}
.dd-tray.hot{background:rgba(233,228,212,.08);border-color:var(--dim)}
.tray-empty{color:var(--dim);font-size:.85rem;align-self:center}

/* Dice */
.dd .die{position:relative;width:52px;height:52px;border-radius:11px;border:0;padding:0;background:#ece6d3;color:var(--ink);
  box-shadow:inset 0 -4px 0 rgba(0,0,0,.18),0 0 0 2px #0f1316,0 0 0 4px var(--kc,#ece6d3);display:grid;place-items:center;
  transition:transform .12s;touch-action:none}
.dd .die.mini{width:44px;height:44px;border-radius:9px}
.dd .die.drag{z-index:30;box-shadow:0 8px 16px rgba(0,0,0,.5),0 0 0 2px #0f1316,0 0 0 4px var(--amber);transition:none}
.die .pips{display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);width:70%;height:70%}
.die .pips i{width:72%;height:72%;border-radius:50%;background:var(--ink);place-self:center}
.die .pips b{display:block}
.die .num{font-weight:900;font-size:1.5rem;line-height:1}
.die.down{background:#2d363e;color:var(--dim);box-shadow:inset 0 0 0 2px #3a444d,0 0 0 2px #0f1316,0 0 0 4px var(--kc,#3a444d);animation:ddtap 1.6s ease-in-out infinite}
@keyframes ddtap{50%{transform:translateY(-3px)}}
.die.jam{opacity:.55;filter:grayscale(1)}
.die .lock{position:absolute;inset:6px;border:3px solid var(--red);border-radius:6px;background:repeating-linear-gradient(45deg,transparent 0 5px,rgba(239,111,94,.35) 5px 7px)}
.die.rolled{animation:ddroll .35s ease-out}
.k-forged{--kc:var(--amber)}.k-thorn{--kc:#9bd48a}.k-leech{--kc:var(--red)}.k-ember{--kc:#ff9a3c}.k-echo{--kc:var(--blue)}.k-bulwark{--kc:#b79cf0}
@keyframes ddroll{0%{transform:rotate(-30deg) translateY(-18px);opacity:.3}100%{transform:none;opacity:1}}
.dd-tray .die,.slot-dice .die{animation:ddroll .32s ease-out}
.dd-tray .die.down{animation:ddtap 1.6s ease-in-out infinite}

/* Actions */
.dd-actions{display:grid;grid-template-columns:1fr 1.7fr;gap:8px}
.dd .btn{min-height:48px;border-radius:12px;border:2px solid var(--chalk);background:transparent;color:var(--chalk);font-weight:800;font-size:1rem;padding:0 14px;display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none}
.dd .btn.main{background:var(--amber);border-color:var(--amber);color:#1a1409}
.dd .btn.main.dim,.dd .btn:disabled{opacity:.4;cursor:default}
.dd .btn.rest.need{border-color:var(--red);color:var(--red);animation:ddtap 1s infinite}
.dd .btn.alt{border-color:var(--dim);color:#cfc9b8}
.dd .btn.big{min-height:56px;font-size:1.15rem;width:100%}
.dd .btn svg{width:22px;height:22px}

/* Panel (doors and rewards) */
.dd-panel{position:absolute;left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom));padding:10px;border-radius:12px;background:#171c21;border:2px solid var(--line);display:flex;flex-direction:column;gap:8px;z-index:5;animation:ddup .25s ease-out}
.dd-panel[hidden]{display:none}
@keyframes ddup{from{transform:translateY(24px);opacity:0}to{transform:none;opacity:1}}
.dd-panel h2{font-size:1rem;text-align:center}
.cards{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.cards.two{grid-template-columns:1fr 1fr}
.card{display:flex;flex-direction:column;align-items:center;gap:4px;text-align:center;min-height:128px;padding:10px 6px;border-radius:44px 44px 10px 10px;border:2px solid var(--chalk);background:var(--slate2);color:var(--chalk)}
.card strong{font-size:.95rem}
.card small{font-size:.74rem;color:#b9b4a4;line-height:1.2}
.card .ci{display:grid;place-items:center;height:36px;color:var(--chalk)}
.card.offer{border-radius:12px}
.card.t-elite{border-color:var(--red)}.card.t-elite .ci{color:var(--red)}
.card.t-rest{border-color:var(--amber)}.card.t-rest .ci{color:var(--amber)}
.card.t-cache{border-color:var(--blue)}.card.t-cache .ci{color:var(--blue)}
.card.t-boss{border-color:var(--red);grid-column:1/-1;background:#2a1f1f}.card.t-boss .ci{color:var(--red)}
.card:active{transform:scale(.97)}
.dd .btn.camp{font-size:.88rem;border-color:var(--dim)}
.sub{font-size:.76rem;color:#a9a393;text-align:center}

/* Overlays */
.dd-ov{position:absolute;inset:0;background:rgba(15,19,22,.93);display:grid;place-items:center;padding:14px;z-index:20;overflow:auto;touch-action:pan-y;animation:ddfade .25s ease-out}
.dd-ov[hidden]{display:none}
@keyframes ddfade{from{opacity:0}to{opacity:1}}
.ov-card{width:100%;max-width:340px;display:flex;flex-direction:column;gap:10px;align-items:stretch;text-align:center}
.logo{font-size:2.3rem;line-height:1;letter-spacing:.02em;color:var(--chalk);text-shadow:3px 3px 0 #0f1316;transform:rotate(-2deg)}
.logo::after{content:"";display:block;height:4px;margin:8px auto 0;width:60%;background:var(--amber);border-radius:2px}
.lead{font-size:.92rem;color:#cfc9b8;line-height:1.35}
.opts{display:flex;flex-direction:column;gap:6px;text-align:left}
.opt{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.88rem;color:#cfc9b8;border-bottom:1px dashed var(--line);padding-bottom:6px}
.step{display:flex;align-items:center;gap:10px}
.chip{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 10px;border-radius:10px;border:2px solid var(--line);background:var(--slate2);font-weight:700}
.chip.sq{width:44px;justify-content:center;font-size:1.3rem;padding:0}
.chip:disabled{opacity:.35}
.chip .die.mini{width:30px;height:30px;border-radius:7px}
.chip .die .num{font-size:1rem}
.stats{font-size:.75rem;color:#8d949b}
.big-score{font-size:3rem;font-weight:900;color:var(--amber);line-height:1}
.result.lost h2{color:var(--red)}.result.won h2{color:#9bd48a}
.wins{list-style:none;display:flex;flex-direction:column;gap:3px;color:var(--amber);font-weight:700;font-size:.9rem}
.help{text-align:left}.help h2{text-align:center}
.help ol{padding-left:1.1rem;display:flex;flex-direction:column;gap:6px;font-size:.88rem;color:#d8d2c0;line-height:1.3}

/* Coaching, progress, streak */
.dd .btn.coach{animation:ddglow 1.1s ease-in-out infinite}
.slot.coach{border-style:solid;border-color:var(--amber);animation:ddglow 1.1s ease-in-out infinite}
@keyframes ddglow{0%,100%{box-shadow:0 0 0 0 rgba(242,176,74,0)}50%{box-shadow:0 0 0 5px rgba(242,176,74,.45)}}
.dd .btn.slim{min-height:44px;font-size:.88rem}
.streak{font-size:.82rem;color:var(--amber);font-weight:700}
.next{display:flex;flex-direction:column;gap:4px;text-align:left;font-size:.82rem;color:#cfc9b8}
.nbar{height:8px;border-radius:4px;background:#0f1316;border:1px solid var(--line);overflow:hidden}
.nbar i{display:block;height:100%;background:var(--amber)}
.next small{font-size:.72rem;color:#8d949b}
.dd-stage::after{content:"";position:absolute;inset:0;pointer-events:none;box-shadow:inset 0 0 40px 6px rgba(0,0,0,.45)}

@media (max-width:360px){.die{width:48px;height:48px}.card{min-height:116px}.logo{font-size:2rem}}
@media (prefers-reduced-motion:reduce){
  .dd *,.dd *::before,.dd *::after{animation:none!important;transition:none!important}
}

/* Full screen (native and immersive): the delve fills the stage under the dock */
html.pip-immersive .game-wrap.pip-stage{display:flex;flex-direction:column;overflow:hidden;padding-left:8px;padding-right:8px;padding-bottom:calc(8px + env(safe-area-inset-bottom))}
html.pip-immersive .game-wrap.pip-stage>.dd{flex:1 1 0;min-height:0;height:auto;max-width:560px;width:100%;margin:0 auto}
html.pip-immersive .dd-stage{min-height:0}
html.pip-immersive .dd-hint{min-height:1.2em}
html.pip-immersive .dd-ov,html.pip-immersive .dd-panel{max-height:100%;overflow:auto}
@media (orientation:landscape) and (max-height:520px){
  html.pip-immersive .game-wrap.pip-stage{padding-top:calc(var(--pip-dock-h,44px) + 4px + env(safe-area-inset-top,0px))!important}
  html.pip-immersive .game-wrap.pip-stage>.dd{max-width:none;display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);grid-template-rows:auto auto auto minmax(0,1fr) auto;
    grid-template-areas:"hud hint" "stage slots" "stage tray" "stage tray" "stage act";gap:4px 8px;padding:6px}
  html.pip-immersive .dd-hud{grid-area:hud}
  html.pip-immersive .dd-stage{grid-area:stage;min-height:0}
  html.pip-immersive .dd-hint{grid-area:hint;min-height:0;font-size:.74rem}
  html.pip-immersive .dd-slots{grid-area:slots}
  html.pip-immersive .dd-tray{grid-area:tray;min-height:56px;padding:2px;gap:6px;overflow:hidden}
  html.pip-immersive .dd-actions{grid-area:act}
  html.pip-immersive .slot{min-height:70px;padding:3px}
  html.pip-immersive .dd .btn{min-height:44px}
  html.pip-immersive .dd-hud{grid-template-areas:"hp tools" "info tools" "pool pool"}
}

/* Full screen (shell immersive / native): the board takes the screen */
html.pip-immersive .game-wrap.pip-stage,html.pip-native .game-wrap.pip-stage{display:flex;flex-direction:column;padding-left:6px;padding-right:6px;padding-bottom:6px;overflow:hidden}
html.pip-native .game-wrap.pip-stage{padding-top:6px}
html.pip-immersive .game-wrap.pip-stage>.dd,html.pip-native .game-wrap.pip-stage>.dd{flex:1 1 0;min-height:0;height:auto;border:0;border-radius:10px;padding:4px 4px calc(4px + env(safe-area-inset-bottom));gap:4px}
:is(html.pip-immersive,html.pip-native) .dd-hint{display:none}
:is(html.pip-immersive,html.pip-native) .dd .dd-stage{min-height:0;border-width:1px}
:is(html.pip-immersive,html.pip-native) .dd .slot{min-height:72px;padding:3px}
:is(html.pip-immersive,html.pip-native) .dd .dd-tray{min-height:64px;padding:2px;gap:6px}
:is(html.pip-immersive,html.pip-native) .dd .dd-panel{max-height:calc(100% - 16px);overflow:auto}
:is(html.pip-immersive,html.pip-native) .dd .dd-panel[hidden]{display:none}
:is(html.pip-immersive,html.pip-native) .dd .dd-ov[hidden]{display:none}
@media (orientation:landscape) and (max-height:520px){
  :is(html.pip-immersive,html.pip-native) .dd{display:grid;grid-template-columns:minmax(0,1fr) 290px;grid-template-rows:auto auto auto 1fr auto;column-gap:6px;row-gap:4px;align-content:stretch}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-stage{grid-column:1;grid-row:1/-1}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-hud{grid-column:2;grid-row:1}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-slots{grid-column:2;grid-row:2}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-tray{grid-column:2;grid-row:4;min-height:0;overflow:auto}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-actions{grid-column:2;grid-row:5}
  :is(html.pip-immersive,html.pip-native) .dd>.dd-panel,:is(html.pip-immersive,html.pip-native) .dd>.dd-ov{grid-column:auto;grid-row:auto}
  :is(html.pip-immersive,html.pip-native) .dd .btn{min-height:44px}
}
