*{box-sizing:border-box}body{margin:0;background:#0b1020;color:#f8fafc;font:16px system-ui,sans-serif;padding:env(safe-area-inset-top) 12px env(safe-area-inset-bottom)}header,.tools{text-align:center;max-width:1100px;margin:auto}h1{font-size:1.4rem;letter-spacing:.12em;color:#f5c96a}.toolbar{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;align-items:center;margin:14px 0}label{font-size:.85rem}select,button,input{font:inherit;border-radius:10px;border:1px solid #526079;padding:11px;background:#202b43;color:white}button{cursor:pointer;touch-action:manipulation}button:active{transform:scale(.97)}#board{display:grid;grid-template-columns:1fr;gap:12px;max-width:1100px;margin:0 auto}.panel{background:linear-gradient(145deg,var(--accent),#151e33 65%);border:2px solid var(--accent);border-radius:18px;padding:14px;text-align:center;min-width:0}.panel h2{margin:2px 0 8px;font-size:1.1rem}.lp{font-size:clamp(3rem,12vw,5.5rem);font-weight:800;font-variant-numeric:tabular-nums;overflow-wrap:anywhere;margin:8px 0}.controls{display:grid;grid-template-columns:repeat(4,1fr);gap:7px}.controls button{padding:12px 2px;font-weight:700}.entry{display:flex;gap:7px;margin:10px 0}.entry input{min-width:0;flex:1;width:100%;font-size:1.2rem;text-align:center}.entry button{flex:0 0 55px}.bottom{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:10px}.bottom input[type=color]{width:48px;height:40px;padding:3px}.tools{padding:18px 0}.tools button{margin:4px}#result{font-size:1.6rem;font-weight:700;min-height:2.5rem;margin-top:12px}#clock{font-size:1.7rem;font-variant-numeric:tabular-nums}.danger{background:#832b39}dialog{border:1px solid #65718a;border-radius:18px;background:#19243a;color:white;max-width:min(90vw,420px)}dialog::backdrop{background:#000a}.actions{display:flex;justify-content:flex-end;gap:10px}.flash{animation:flash .45s}@keyframes flash{50%{filter:brightness(2.1)}}@media(min-width:720px){#board.wide{grid-template-columns:repeat(2,minmax(0,1fr))}}#board.wide{grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:390px){.controls{grid-template-columns:repeat(2,1fr)}}
#calcDialog{width:min(94vw,390px);text-align:center}#calcScreen{background:#0b1020;border:1px solid #64748b;border-radius:12px;padding:14px 10px;margin:12px 0;font-size:1.9rem;font-weight:750;min-height:66px;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.calc-keys{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}.calc-keys button{font-size:1.3rem;min-height:53px;padding:7px 0}.calc-target{display:flex;align-items:center;justify-content:center;gap:12px;margin:15px 0}.calc-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0}.calc-actions button{font-weight:700}#calcClose{width:100%}

/* V3: responsive compact mode, including narrow mobile screens */
html,body{width:100%;max-width:100%;overflow-x:hidden}
#board{width:100%;min-width:0;grid-template-columns:minmax(0,1fr)}
#board.wide{grid-template-columns:repeat(2,minmax(0,1fr))}
.panel{min-width:0;max-width:100%;overflow:hidden}
.controls{grid-template-columns:repeat(4,minmax(0,1fr))}
.controls button{min-width:0;width:100%;min-height:44px;line-height:1.1;overflow-wrap:anywhere}
.entry{min-width:0}
.entry input{min-width:0;width:0;flex:1 1 0}
.entry button{flex:0 0 auto;min-width:0}
.bottom{min-width:0;flex-wrap:wrap}
.bottom button{min-width:0;flex:1 1 auto}
.bottom label{display:flex;align-items:center;justify-content:center;gap:4px;min-width:0}
.lp{max-width:100%;font-size:clamp(1.65rem,8vw,5.5rem);line-height:1.12}
#board.wide .panel{padding:clamp(5px,1.5vw,14px);border-radius:12px}
#board.wide .panel h2{font-size:clamp(.72rem,2.8vw,1.1rem)}
#board.wide .lp{font-size:clamp(1.45rem,7vw,4.5rem)}
#board.wide .controls{grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}
#board.wide .controls button{font-size:clamp(.68rem,2.7vw,.95rem);padding:8px 1px;min-height:42px}
#board.wide .entry{gap:4px;margin:8px 0}
#board.wide .entry input{font-size:16px;padding:7px 2px;min-height:42px}
#board.wide .entry button{width:30px;padding:6px 0;min-height:42px}
#board.wide .bottom{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}
#board.wide .bottom button{width:100%;font-size:clamp(.65rem,2.4vw,.9rem);padding:8px 2px;min-height:42px}
#board.wide .bottom label{grid-column:1/-1}
#board.wide .bottom input[type=color]{width:44px;max-width:100%}
@media(max-width:380px){body{padding-left:6px;padding-right:6px}#board{gap:6px}#board.wide .panel{padding:5px}#board.wide .entry button{width:27px}#board.wide .lp{font-size:clamp(1.25rem,6.5vw,2.1rem)}.toolbar{gap:5px}.toolbar select,.toolbar button{padding:8px 5px}}
@media(max-width:290px){#board.wide{grid-template-columns:minmax(0,1fr)}}

/* V4: compact cards, responsive controls and animations */
body{background:var(--page,#0b1020);color:var(--ink,#f8fafc)}body[data-theme="classic"]{--page:#161026;--ink:#fff1d4}body[data-theme="minimal"]{--page:#14171c;--ink:#f4f4f4}.toolbar button,.toolbar select{max-width:100%}.matchbar{max-width:1100px;margin:0 auto 12px;display:flex;justify-content:center;align-items:center;gap:7px;flex-wrap:wrap}.matchbar button{padding:8px}.matchbar span{font-size:.85rem;padding:4px}.panel{position:relative}.lp{transition:color .2s;text-wrap:nowrap;overflow-wrap:normal;font-size:clamp(2rem,9vw,5.5rem)}.panel.gain .lp{color:#4ade80}.panel.loss .lp{color:#fb7185}.panel.gain{animation:glowgain .55s}.panel.loss{animation:glowloss .55s}@keyframes glowgain{50%{box-shadow:0 0 25px #22c55e88}}@keyframes glowloss{50%{box-shadow:0 0 25px #ef444488}}#board.wide .panel{padding:clamp(5px,1.3vw,12px)}#board.wide .controls{grid-template-columns:repeat(2,minmax(0,1fr))}#board.wide .controls button{min-width:0;min-height:48px;font-size:clamp(.7rem,2.5vw,1rem);white-space:nowrap}#board.wide .entry,#board.wide .bottom{display:none}#board.wide .compact-calc{display:block;width:100%;min-height:46px;margin-top:7px;font-size:clamp(.72rem,2.6vw,1rem);padding:7px 2px}.compact-calc{display:none}.controls button[data-d^="-"]{background:#522535}.controls button[data-d="1000"],.controls button[data-d="500"]{background:#18543e}#board.wide .lp{font-size:clamp(1.5rem,7vw,4rem);letter-spacing:-.035em}#board.wide .panel h2{font-size:clamp(.72rem,2.5vw,1.1rem)}#result{display:flex;align-items:center;justify-content:center;min-height:65px}#result.rolling{animation:pulse .18s infinite alternate}#result.coinflip{animation:coinspin .2s infinite linear}@keyframes pulse{to{transform:scale(1.12);opacity:.65}}@keyframes coinspin{50%{transform:scaleX(.12)}}#history{margin:12px auto;max-width:500px;text-align:left;font-size:.82rem}#historyitems{max-height:100px;overflow-y:auto;color:#cbd5e1}#historyitems div{padding:3px 0;border-bottom:1px solid #ffffff1c}button:focus-visible{outline:3px solid #facc15;outline-offset:2px}dialog{max-height:90dvh;overflow-y:auto}#calcDialog{max-width:calc(100vw - 16px)}@media(max-width:360px){body{padding-left:5px;padding-right:5px}#board{gap:5px}#board.wide .panel{padding:5px;border-width:1px}#board.wide .controls{gap:4px}#board.wide .controls button{font-size:11px;padding:8px 1px}#board.wide .lp{font-size:clamp(1.3rem,6.6vw,2.3rem)}.toolbar{gap:4px}.toolbar button,.toolbar select{font-size:12px;padding:7px 4px}.matchbar button{font-size:12px;padding:6px}}

#board.wide .controls button[data-d="-500"],#board.wide .controls button[data-d="500"]{display:none}#board.wide .controls button[data-d="1000"]{order:0}#board.wide .controls button[data-d="-1000"]{order:1}#board.wide .controls{grid-template-columns:repeat(2,minmax(0,1fr))}

/* Duel Judge beta */
.judge-dialog{width:min(680px,calc(100vw - 20px));max-width:680px;box-sizing:border-box}.judge-dialog small{font-size:.55em;color:#fbbf24}.judge-warning{border:1px solid #f59e0b66;border-radius:10px;padding:12px;line-height:1.5}.judge-dialog #judgeSearch{width:100%;box-sizing:border-box;margin:10px 0 14px;padding:12px;font-size:16px;border-radius:9px}.judge-dialog #judgeResults{display:grid;gap:10px;max-height:45dvh;overflow:auto}.judge-dialog #judgeResults article{border:1px solid #ffffff28;border-radius:10px;padding:10px 12px}.judge-dialog #judgeResults h3{margin:0 0 7px;font-size:1rem}.judge-dialog #judgeResults p{margin:0;line-height:1.5;font-size:.9rem}.judge-links{font-size:.85rem;line-height:1.6}.judge-links a{color:#93c5fd}.toolbar button[hidden]{display:none!important}

/* V5 Duel Arena — visual design and dedicated settings */
:root{color-scheme:dark}body{--page:#090c19;--ink:#f9f0d9;background:radial-gradient(ellipse at 50% -180px,#34254f 0%,transparent 55%),radial-gradient(ellipse at 100% 80%,#131b39 0%,transparent 50%),var(--page);min-height:100dvh;padding:env(safe-area-inset-top) max(8px,env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px,env(safe-area-inset-left));font-family:system-ui,-apple-system,'Segoe UI',sans-serif}body[data-theme="classic"]{--page:#150e21}body[data-theme="minimal"]{--page:#11151c}button,select,input{border-color:#675780;background:#1d2038;color:#fff5dc}button{transition:filter .15s,transform .15s}button:hover{filter:brightness(1.16)}.app-header{max-width:1100px;display:flex;align-items:center;justify-content:space-between;text-align:left;padding:15px 6px 12px;border-bottom:1px solid #c7a66c55}.brand{display:flex;align-items:center;gap:11px;min-width:0}.brand-symbol{width:46px;height:46px;display:grid;place-items:center;font-size:30px;color:#ffda78;border:1px solid #c7a66c;border-radius:12px;background:linear-gradient(145deg,#3c2953,#15152b);box-shadow:0 0 18px #e8b86125;flex-shrink:0}.brand-kicker,.brand-subtitle,.eyebrow,.tools-label{font-size:10px;font-weight:800;letter-spacing:.2em;color:#c8a66b}.brand h1{margin:0;font-family:Georgia,'Times New Roman',serif;font-weight:900;font-size:clamp(1.25rem,5.3vw,2.3rem);line-height:1.08;letter-spacing:.06em;color:#fce9ac;text-shadow:0 2px 0 #6d3c23,0 0 16px #d5aa503b}.brand h1 em{font-style:normal;color:#fff9e9}.brand-subtitle{font-size:9px;letter-spacing:.12em;margin-top:3px;color:#9e9db9}.icon-button{border:1px solid #d1aa6d88;background:#29213b;color:#ffe4a6;min-width:48px;min-height:48px;font-size:23px;display:grid;place-items:center;padding:5px;flex-shrink:0}.arena-top{max-width:1100px;margin:12px auto}.arena-heading{display:flex;align-items:center;gap:12px;justify-content:center}.arena-rule{height:1px;max-width:200px;flex:1;background:linear-gradient(90deg,transparent,#b48d53,transparent)}.matchbar{margin:9px auto 13px;padding:7px 9px;border:1px solid #7d658044;border-radius:13px;background:#16192bd9;gap:6px}.matchbar button{background:#29253d;border-color:#695576}.matchbar span{color:#ead7ad}.panel{background:radial-gradient(circle at 50% -20%,color-mix(in srgb,var(--accent),transparent 52%),transparent 70%),linear-gradient(160deg,#22203a,#101628 76%);border:1px solid color-mix(in srgb,var(--accent),#c7a66c 38%);border-radius:17px;box-shadow:inset 0 1px 0 #ffffff1d,0 6px 20px #0005}.panel h2{font-size:clamp(.8rem,2.8vw,1.1rem);color:#e4d7b6;text-transform:uppercase;letter-spacing:.07em}.lp{font-family:Georgia,'Times New Roman',serif;font-weight:900;text-shadow:0 2px 8px #0008}.controls button,.compact-calc{border:1px solid #9c836455;background:linear-gradient(180deg,#35314e,#202138);font-weight:800}.controls button[data-d^="-"]{background:linear-gradient(180deg,#743348,#442136)}.controls button[data-d="1000"],.controls button[data-d="500"]{background:linear-gradient(180deg,#28654c,#1b3e35)}.tools{margin:15px auto;padding:16px 10px 24px;border-top:1px solid #c7a66c44}.tools-label{margin-bottom:11px}.tool-buttons{display:flex;flex-wrap:wrap;justify-content:center;gap:7px}.tool-buttons button{margin:0;min-height:46px;border:1px solid #9c795f70;background:linear-gradient(180deg,#322b47,#1b2038)}.tool-buttons .danger{background:linear-gradient(180deg,#793047,#4b2334)}#result{font-family:Georgia,serif;color:#ffe5a4}#history{background:#151b2dcc;border:1px solid #6c5b7755;border-radius:12px;padding:10px 12px}#history strong{color:#e5c991}.settings-dialog{width:min(94vw,540px);max-width:540px;padding:0;border:1px solid #b99a68;background:linear-gradient(155deg,#27213a,#111727 65%);box-shadow:0 24px 70px #000c}.settings-head{display:flex;align-items:center;justify-content:space-between;padding:19px 18px 13px;border-bottom:1px solid #b99a6855}.settings-head h2{margin:4px 0 0;font-family:Georgia,serif;color:#f4d997}.settings-group{padding:15px 18px;border-bottom:1px solid #ffffff12}.settings-group h3{margin:0 0 12px;color:#f3dca7;font-size:.95rem}.settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.settings-grid label{display:grid;gap:6px;color:#d5cce0}.settings-grid select{min-width:0;width:100%;padding:10px 5px}.settings-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.settings-actions button,.setting-action{min-height:45px}.setting-action{width:100%;margin-top:10px}.settings-description{color:#bcb6c8;font-size:.85rem;line-height:1.5;margin:0}.settings-dialog button[hidden],.tool-buttons button[hidden]{display:none!important}dialog::backdrop{background:#050611d9;backdrop-filter:blur(5px)}@media(max-width:420px){.brand-symbol{width:39px;height:39px;font-size:25px}.brand-kicker{font-size:8px}.brand-subtitle{font-size:8px}.brand h1{letter-spacing:0}.matchbar button,.matchbar span{font-size:11px;padding:6px}.tool-buttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.tool-buttons button{font-size:12px;padding:9px 4px;min-width:0}.tool-buttons .danger{grid-column:1/-1}.settings-group{padding:12px}.settings-head{padding:13px}.settings-actions button{font-size:12px;padding:9px 4px}}@media(max-width:340px){.brand-symbol{display:none}.brand h1{font-size:1.18rem}.settings-grid{grid-template-columns:1fr}#board.wide .panel h2{font-size:10px}}

/* V6 — compact truly responsive and high-visibility feedback */
#board{gap:clamp(6px,2vw,14px)}
#board.wide{grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(5px,1.6vw,12px)}
#board.wide .panel{min-width:0;width:100%;padding:clamp(5px,1.8vw,15px);overflow:hidden;contain:layout paint}
#board.wide .panel h2{font-size:clamp(10px,2.6vw,17px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#board.wide .lp{font-family:system-ui,-apple-system,'Segoe UI',sans-serif;font-size:clamp(20px,6.5vw,65px);line-height:1.25;letter-spacing:-.055em;white-space:nowrap;overflow:hidden;text-overflow:clip;font-variant-numeric:tabular-nums}
#board.wide .controls{grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(3px,1vw,9px)}
#board.wide .controls button{min-width:0;width:100%;height:clamp(44px,12vw,57px);min-height:44px;font-size:clamp(10px,2.7vw,16px);padding:4px 0;white-space:nowrap;overflow:hidden}
#board.wide .compact-calc{display:block;width:100%;min-width:0;min-height:46px;font-size:clamp(10px,2.7vw,16px);padding:7px 2px;white-space:nowrap}
#board.wide .entry,#board.wide .bottom{display:none}
#board.wide .controls button[data-d="-500"],#board.wide .controls button[data-d="500"]{display:none}
@media(max-width:330px){#board.wide .panel{padding:4px}#board.wide .panel h2{font-size:10px}#board.wide .lp{font-size:clamp(17px,6vw,22px)}#board.wide .compact-calc{font-size:10px}#board.wide .controls button{font-size:10px}}
@media(max-width:245px){#board.wide{grid-template-columns:1fr}}
/* Flash on the entire LP panel, not just a subtle border */
.panel.gain{animation:lp-gain-flash 1.05s ease-out both!important}
.panel.loss{animation:lp-loss-flash 1.05s ease-out both!important}
.panel.gain .lp{animation:lp-green-number 1.05s ease-out!important}
.panel.loss .lp{animation:lp-red-number 1.05s ease-out!important}
@keyframes lp-gain-flash{0%,25%,55%{background-color:#126b36;box-shadow:inset 0 0 60px #22ff7766,0 0 28px #22ff77aa;border-color:#4aff8a}12%,40%,75%,100%{background-color:transparent;box-shadow:inset 0 1px 0 #ffffff1d,0 6px 20px #0005}}
@keyframes lp-loss-flash{0%,25%,55%{background-color:#791e29;box-shadow:inset 0 0 60px #ff354d66,0 0 28px #ff354daa;border-color:#ff5268}12%,40%,75%,100%{background-color:transparent;box-shadow:inset 0 1px 0 #ffffff1d,0 6px 20px #0005}}
@keyframes lp-green-number{0%,20%,50%{color:#67ff91;text-shadow:0 0 22px #00ff73}35%,70%,100%{color:#f9f0d9;text-shadow:0 2px 8px #0008}}
@keyframes lp-red-number{0%,20%,50%{color:#ff6d7c;text-shadow:0 0 22px #ff1737}35%,70%,100%{color:#f9f0d9;text-shadow:0 2px 8px #0008}}
/* Dice and coin visual objects: visible motion, independent of the label */
#result{display:flex;flex-direction:column;gap:5px;min-height:100px;overflow:visible}
.die-object{display:grid;place-items:center;width:62px;height:62px;border-radius:14px;border:3px solid #f6d88b;background:linear-gradient(140deg,#f8e2ac,#bb8b41);color:#1b1326;font:900 35px system-ui;box-shadow:0 7px 20px #0009,0 0 20px #e7bd6a55;animation:die-tumble .18s ease-in-out infinite alternate}
.die-final{animation:die-land .35s ease-out both}
.die-caption,.coin-caption{font:800 12px system-ui;letter-spacing:.15em;color:#f5d88c}
.coin-object{display:grid;place-items:center;width:76px;height:76px;border:3px solid #ffe49a;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff5bf,#e8b754 52%,#765023);font:900 43px system-ui;box-shadow:0 8px 22px #0009,0 0 22px #d9b45c55;backface-visibility:visible;animation:coin-rotate .35s linear infinite}
.coin-final{animation:coin-land .5s ease-out both}
#result.rolling,#result.coinflip{animation:none}
@keyframes die-tumble{from{transform:rotate(-18deg) translateY(-5px) scale(.95)}to{transform:rotate(20deg) translateY(4px) scale(1.07)}}
@keyframes die-land{0%{transform:translateY(-30px) rotate(45deg) scale(1.25)}70%{transform:translateY(4px) rotate(-8deg)}100%{transform:none}}
@keyframes coin-rotate{0%{transform:perspective(220px) rotateY(0deg) rotateZ(-8deg)}100%{transform:perspective(220px) rotateY(360deg) rotateZ(8deg)}}
@keyframes coin-land{0%{transform:perspective(220px) rotateY(160deg) scale(1.2)}70%{transform:perspective(220px) rotateY(355deg) scale(.94)}100%{transform:perspective(220px) rotateY(360deg)}}
@media(prefers-reduced-motion:reduce){.panel.gain,.panel.loss,.panel.gain .lp,.panel.loss .lp,.die-object,.coin-object{animation-duration:.01ms!important;animation-iteration-count:1!important}}

/* V7: distinct full visual themes and genuine miniature previews */
body[data-theme="millennium"],.theme-choice[data-name="millennium"]{--t-bg:#100d17;--t-surface:#23192d;--t-card:#292037;--t-text:#ffebbb;--t-accent:#e5b95e;--t-line:#b98a46;--t-button:#413047;--t-font:Georgia,serif}
body[data-theme="kaiba"],.theme-choice[data-name="kaiba"]{--t-bg:#e9f4ff;--t-surface:#d3e8ff;--t-card:#f9fcff;--t-text:#153b6e;--t-accent:#007fe9;--t-line:#52a8e8;--t-button:#d7ecff;--t-font:system-ui,sans-serif}
body[data-theme="crimson"],.theme-choice[data-name="crimson"]{--t-bg:#15090c;--t-surface:#2b1018;--t-card:#38131c;--t-text:#ffe2d3;--t-accent:#ff5b39;--t-line:#a93d35;--t-button:#5c1b28;--t-font:Georgia,serif}
body[data-theme="shadow"],.theme-choice[data-name="shadow"]{--t-bg:#0c0919;--t-surface:#21143b;--t-card:#2c1a4b;--t-text:#eee0ff;--t-accent:#c18cff;--t-line:#8655bd;--t-button:#392356;--t-font:Georgia,serif}
body[data-theme="tournament"],.theme-choice[data-name="tournament"]{--t-bg:#111418;--t-surface:#242b32;--t-card:#2a323b;--t-text:#f5f7f9;--t-accent:#e3ebf1;--t-line:#73828e;--t-button:#38434d;--t-font:system-ui,sans-serif}
body[data-theme]{background:var(--t-bg)!important;color:var(--t-text)}
body[data-theme] .app-header,body[data-theme] .arena-top,body[data-theme] .tools{color:var(--t-text)}
body[data-theme] .brand h1,body[data-theme] .brand h1 em{font-family:var(--t-font);color:var(--t-accent);text-shadow:none}
body[data-theme] .brand-symbol{color:var(--t-accent);border-color:var(--t-line)}
body[data-theme] .panel{background:linear-gradient(155deg,var(--t-card),var(--t-surface))!important;border:2px solid var(--t-line);box-shadow:0 6px 22px #0004}
body[data-theme] .panel h2,body[data-theme] .lp{color:var(--t-text);font-family:var(--t-font)}
body[data-theme] .matchbar,body[data-theme] #history{background:var(--t-surface);border-color:var(--t-line)}
body[data-theme] .matchbar span,body[data-theme] #history strong{color:var(--t-text)}
body[data-theme] .matchbar button,body[data-theme] .tool-buttons button,body[data-theme] .compact-calc,body[data-theme] .controls button,body[data-theme] .icon-button{background:var(--t-button);border-color:var(--t-line);color:var(--t-text)}
body[data-theme] .controls button[data-d^="-"]{background:#782a38;color:#fff}
body[data-theme] .controls button[data-d="1000"],body[data-theme] .controls button[data-d="500"]{background:#236744;color:#fff}
body[data-theme] .settings-dialog{background:var(--t-surface);border-color:var(--t-line);color:var(--t-text)}
body[data-theme] .settings-head h2,body[data-theme] .settings-group h3{color:var(--t-accent)}
body[data-theme="kaiba"] .panel{border-radius:5px;clip-path:polygon(0 0,96% 0,100% 9%,100% 100%,4% 100%,0 91%)}
body[data-theme="crimson"] .panel{border-radius:3px;box-shadow:inset 0 0 24px #b0181833,0 0 12px #e12e1a33}
body[data-theme="shadow"] .panel{border-radius:23px;box-shadow:inset 0 0 28px #923cf72c,0 0 18px #8c42c833}
body[data-theme="tournament"] .panel{border-radius:6px;box-shadow:none}
.theme-gallery{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.theme-choice{position:relative;display:flex;flex-direction:column;gap:0;overflow:hidden;padding:0!important;text-align:left;background:var(--t-surface)!important;color:var(--t-text)!important;border:2px solid var(--t-line)!important;border-radius:12px;min-width:0}
.theme-choice.selected{outline:3px solid var(--t-accent);outline-offset:1px}
.theme-preview{height:116px;width:100%;padding:9px;background:var(--t-bg);display:flex;flex-direction:column;gap:9px;color:var(--t-text)}
.mini-header{font-family:var(--t-font);font-size:12px;font-weight:900;letter-spacing:.06em;color:var(--t-accent);text-align:center}
.mini-panels{display:grid;grid-template-columns:1fr 1fr;gap:6px;flex:1;min-height:0}
.mini-panels>span{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;background:var(--t-card);border:1px solid var(--t-line);border-radius:6px;min-width:0}
.mini-panels b{font-family:var(--t-font);font-size:clamp(14px,4vw,22px);line-height:1}
.mini-panels small{font:700 8px system-ui;color:var(--t-text)}
.theme-info{display:flex;flex-direction:column;gap:3px;padding:9px 28px 10px 9px;min-height:55px}
.theme-info strong{font-size:12px}.theme-info small{font-size:10px;opacity:.8;line-height:1.3}
.theme-check{display:none;position:absolute;right:8px;bottom:17px;color:var(--t-accent);font-weight:900}.theme-choice.selected .theme-check{display:block}
@media(max-width:360px){.theme-gallery{gap:7px}.theme-preview{height:95px;padding:6px}.mini-panels small{font-size:7px}.theme-info strong{font-size:11px}}
/* Two-player landscape and portrait: no clipped buttons */
#board.wide .panel{overflow:visible;contain:none}#board.wide .lp{overflow:visible;font-size:clamp(18px,6vw,52px)}
@media(max-width:420px){.app-header{padding-top:6px;padding-bottom:6px}.arena-top{margin:4px auto}.matchbar{margin:5px auto;padding:4px}.tools{margin:5px auto;padding:7px 5px 12px}.tools-label{margin-bottom:4px}.tool-buttons button{min-height:38px}#board.wide .panel{padding:5px}#board.wide .controls button{min-height:40px;height:40px}#board.wide .compact-calc{min-height:40px}}

/* V8 performance-first duel disk layout */
body{--p1:#e8bb59;--p2:#b77b55}
body[data-theme="kaiba"]{--p1:#168af7;--p2:#0bafba}
body[data-theme="crimson"]{--p1:#e93d49;--p2:#f3a144}
body[data-theme="shadow"]{--p1:#a77aff;--p2:#e277c4}
body[data-theme="tournament"]{--p1:#7d9eb9;--p2:#c1cbd1}
body[data-theme] .panel.player-0{--player-accent:var(--p1);border-color:var(--p1)!important}
body[data-theme] .panel.player-1{--player-accent:var(--p2);border-color:var(--p2)!important}
body[data-theme] .panel.player-2{--player-accent:#6bbd88;border-color:var(--player-accent)!important}
body[data-theme] .panel.player-3{--player-accent:#d29bc6;border-color:var(--player-accent)!important}
body[data-theme] .panel h2{color:var(--player-accent);text-transform:uppercase;letter-spacing:.11em;font-size:clamp(.7rem,2.7vw,1rem)}
body[data-theme] .panel .lp{font-family:ui-monospace,'SFMono-Regular',Consolas,monospace;font-weight:900;letter-spacing:-.055em;font-variant-numeric:tabular-nums}
body[data-theme] .panel.active-turn{box-shadow:inset 0 0 0 1px var(--player-accent),0 0 15px color-mix(in srgb,var(--player-accent) 24%,transparent)}
body[data-theme] .panel.gain{animation:duel-gain .75s ease-out 2!important}
body[data-theme] .panel.loss{animation:duel-loss .75s ease-out 2!important}
body[data-theme] .panel.gain .lp{animation:lp-gain .75s ease-out 2!important}
body[data-theme] .panel.loss .lp{animation:lp-loss .75s ease-out 2!important}
@keyframes duel-gain{0%,100%{box-shadow:inset 0 0 0 0 transparent}50%{box-shadow:inset 0 0 45px #18e76b99,0 0 26px #18e76b99;border-color:#4cff93}}
@keyframes duel-loss{0%,100%{box-shadow:inset 0 0 0 0 transparent}50%{box-shadow:inset 0 0 45px #f52c4a99,0 0 26px #f52c4a99;border-color:#ff4e65}}
@keyframes lp-gain{50%{color:#65ff99;text-shadow:0 0 20px #36f873}}
@keyframes lp-loss{50%{color:#ff5b72;text-shadow:0 0 20px #ff3859}}
body[data-theme] .theme-choice .mini-panels>span:first-child{border-color:var(--p1)}
body[data-theme] .theme-choice .mini-panels>span:last-child{border-color:var(--p2)}
.theme-choice[data-name="millennium"]{--p1:#e8bb59;--p2:#b77b55}
.theme-choice[data-name="kaiba"]{--p1:#168af7;--p2:#0bafba}
.theme-choice[data-name="crimson"]{--p1:#e93d49;--p2:#f3a144}
.theme-choice[data-name="shadow"]{--p1:#a77aff;--p2:#e277c4}
.theme-choice[data-name="tournament"]{--p1:#7d9eb9;--p2:#c1cbd1}
.theme-choice .mini-panels>span:first-child{border-color:var(--p1)}
.theme-choice .mini-panels>span:last-child{border-color:var(--p2)}
.duel-overlay{width:min(90vw,460px);text-align:center;border:2px solid #c49b56;background:radial-gradient(ellipse at 50% 0%,#483352,#101323 75%);color:#fff1cf;box-shadow:0 0 80px #d4a75545}
.duel-overlay h2{font:900 clamp(2rem,8vw,3.6rem) Georgia,serif;letter-spacing:.08em;color:#f8d88a;text-shadow:0 0 20px #e6ac68;margin:16px 0}
.duel-overlay small{letter-spacing:.2em;color:#d2a964}
.duel-overlay p{font-size:1.1rem}
.duel-overlay button{width:100%;margin-top:20px}
body.lp-locked .panel button:not(.compact-calc),body.lp-locked .entry input{opacity:.45;pointer-events:none}
body.power-save .panel,body.power-save .panel .lp,body.power-save .die-object,body.power-save .coin-object{animation-duration:.12s!important;animation-iteration-count:1!important;transition:none!important}
/* Two-player screen: fit available height; overlays and history stay outside the duel surface */
@media(max-width:700px){
body.two-player{min-height:100dvh;display:flex;flex-direction:column;gap:0;padding-top:max(3px,env(safe-area-inset-top));padding-bottom:max(3px,env(safe-area-inset-bottom))}
body.two-player .app-header{flex:0 0 auto;width:100%;padding:4px 4px 5px}
body.two-player .brand-symbol{width:31px;height:31px;font-size:20px}
body.two-player .brand-kicker,body.two-player .brand-subtitle{display:none}
body.two-player .brand h1{font-size:clamp(1.05rem,4.5vw,1.45rem)}
body.two-player .arena-top{flex:0 0 auto;width:100%;margin:2px auto}
body.two-player .arena-heading{display:none}
body.two-player .matchbar{margin:0 auto;padding:3px;gap:3px}
body.two-player .matchbar button{padding:5px 6px;font-size:clamp(.62rem,2.6vw,.78rem)}
body.two-player .matchbar span{padding:2px;font-size:clamp(.62rem,2.6vw,.78rem)}
body.two-player #board{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;flex:1 1 auto;min-height:0;align-items:stretch;margin:3px auto;width:100%}
body.two-player #board .panel{display:flex;flex-direction:column;justify-content:center;min-height:0;overflow:hidden;padding:clamp(4px,1vw,10px);gap:clamp(2px,.65dvh,7px)}
body.two-player #board .panel h2{margin:0;font-size:clamp(.65rem,2.7vw,.9rem)}
body.two-player #board .lp{font-size:clamp(1.4rem,7vw,3.6rem);margin:0;line-height:1.08;white-space:nowrap}
body.two-player #board .controls{gap:3px;grid-template-columns:repeat(2,minmax(0,1fr))}
body.two-player #board .controls button{min-height:32px;height:auto;padding:6px 1px;font-size:clamp(.62rem,2.5vw,.84rem)}
body.two-player #board .entry{margin:0;gap:3px}
body.two-player #board .entry input{font-size:16px;min-height:33px;padding:3px 1px}
body.two-player #board .entry button{min-height:33px;width:26px;padding:3px 0}
body.two-player #board .bottom{margin:0;gap:3px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
body.two-player #board .bottom button{padding:4px 0;min-height:32px;font-size:clamp(.59rem,2.2vw,.77rem)}
body.two-player #board .bottom label{display:none}
body.two-player #board.wide .entry,body.two-player #board.wide .bottom{display:none}
body.two-player #board.wide .compact-calc{margin:0;min-height:35px;padding:5px 0}
body.two-player .tools{flex:0 0 auto;width:100%;padding:3px 0 4px;margin:0 auto}
body.two-player .tools-label,body.two-player #history{display:none}
body.two-player .tool-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px}
body.two-player .tool-buttons button{margin:0;min-height:34px;padding:5px 2px;font-size:clamp(.65rem,2.6vw,.83rem)}
body.two-player #result{min-height:0;height:0;margin:0;overflow:visible;position:relative;z-index:2;pointer-events:none}
body.two-player #result:not(:empty){height:auto;max-height:75px;font-size:1rem}
body.two-player #result .die-object{width:42px;height:42px;font-size:26px}
body.two-player #result .coin-object{width:42px;height:42px;font-size:24px}
body.two-player #clock{font-size:clamp(.8rem,3.2vw,1.05rem);line-height:1.1;margin:1px 0}
}
@media(max-width:700px) and (max-height:670px){body.two-player #board .entry,body.two-player #board .bottom{display:none}body.two-player #board .panel{gap:2px}body.two-player .tool-buttons button{min-height:30px}body.two-player .matchbar #matchreset{display:none}}
@media(max-width:700px) and (max-height:520px){body.two-player .tool-buttons{grid-template-columns:repeat(5,minmax(0,1fr))}body.two-player .tool-buttons button{font-size:10px}body.two-player #board .controls button{min-height:28px}body.two-player .brand-symbol{display:none}}
@media(prefers-reduced-motion:reduce){body[data-theme] .panel.gain,body[data-theme] .panel.loss,body[data-theme] .panel.gain .lp,body[data-theme] .panel.loss .lp{animation-duration:.01ms!important}}

/* V9 MOBILE REBUILD — full mode stacks panels, compact mode places them side by side.
   No layout-dependent hiding of essential LP controls. */
@media (max-width:700px) {
  html { height:100%; }
  body.two-player {
    height:100dvh; min-height:0; max-height:100dvh;
    overflow:hidden; display:grid;
    grid-template-rows:auto auto minmax(0,1fr) auto;
    padding: max(4px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
    gap:3px;
  }
  body.two-player .app-header { width:100%; min-height:37px; padding:2px 3px 3px; }
  body.two-player .brand-symbol { width:30px;height:30px; }
  body.two-player .brand h1 { font-size:clamp(16px,4.8vw,23px); }
  body.two-player #settingsOpen { min-width:36px; min-height:34px; padding:4px; }
  body.two-player .arena-top { width:100%; min-width:0; margin:0; }
  body.two-player .matchbar { display:grid; grid-template-columns:minmax(0,1.4fr) auto auto auto auto; align-items:center; gap:2px; padding:2px; min-width:0; }
  body.two-player .matchbar button,body.two-player .matchbar span { min-width:0; white-space:nowrap; font-size:clamp(9px,2.35vw,12px); padding:5px 2px; }
  body.two-player .matchbar #turn { overflow:hidden;text-overflow:ellipsis; }
  body.two-player .matchbar #matchwin { font-size:0; min-width:30px; }
  body.two-player .matchbar #matchwin::after { content:'🏆';font-size:15px; }
  body.two-player .matchbar #matchreset { display:block; min-width:25px; }
  body.two-player #board,body.two-player #board.wide {
    min-height:0; width:100%; max-width:100%; margin:0; display:grid;
    grid-template-columns:minmax(0,1fr); grid-template-rows:repeat(2,minmax(0,1fr));
    gap:5px; overflow:hidden;
  }
  body.two-player #board.wide { grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr); }
  body.two-player #board .panel,body.two-player #board.wide .panel {
    min-height:0; min-width:0; max-width:100%; height:100%; overflow:hidden;
    display:flex;flex-direction:column; justify-content:center;
    gap:clamp(2px,.5dvh,6px);padding:clamp(4px,.9dvh,9px);
    border-width:1px; border-radius:12px;
  }
  body.two-player #board .panel h2 { margin:0; font-size:clamp(10px,2.7vw,15px); line-height:1.1; }
  body.two-player #board .lp { margin:0;line-height:1.08;font-size:clamp(25px,8.8vw,48px);white-space:nowrap; }
  body.two-player #board .controls { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px; }
  body.two-player #board .controls button { display:block; min-width:0;min-height:36px;height:36px;padding:3px 0;font-size:clamp(10px,2.6vw,14px);white-space:nowrap; }
  body.two-player #board .entry { display:flex; gap:4px; margin:0; min-height:34px; }
  body.two-player #board .entry input { min-height:34px;height:34px;min-width:0;font-size:16px;padding:3px 5px; }
  body.two-player #board .entry button { min-height:34px;height:34px;width:36px;flex:0 0 36px;padding:2px; }
  body.two-player #board .bottom { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;margin:0; }
  body.two-player #board .bottom button { min-width:0;min-height:32px;height:32px;padding:3px 1px;font-size:clamp(10px,2.6vw,13px); }
  body.two-player #board .bottom label { display:none; }
  body.two-player #board .compact-calc { display:none; }
  /* Compact: two cards, two large +/-1000 buttons and calculator only */
  body.two-player #board.wide .panel { padding:clamp(4px,.8dvh,9px); }
  body.two-player #board.wide .panel h2 { font-size:clamp(10px,2.6vw,14px); }
  body.two-player #board.wide .lp { font-size:clamp(21px,6.8vw,43px); }
  body.two-player #board.wide .controls { grid-template-columns:repeat(2,minmax(0,1fr));gap:4px; }
  body.two-player #board.wide .controls button { min-height:44px;height:44px;font-size:clamp(11px,2.6vw,14px); }
  body.two-player #board.wide .controls button[data-d="-500"],body.two-player #board.wide .controls button[data-d="500"] {display:none}
  body.two-player #board.wide .entry,body.two-player #board.wide .bottom {display:none}
  body.two-player #board.wide .compact-calc {display:block;min-height:42px;height:42px;margin:2px 0 0;padding:4px 1px;font-size:clamp(11px,2.7vw,14px)}
  body.two-player .tools { width:100%;min-width:0;margin:0;padding:2px 0 0; }
  body.two-player .tools-label,body.two-player #history {display:none}
  body.two-player .tool-buttons {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;}
  body.two-player .tool-buttons button {margin:0;min-width:0;min-height:35px;height:35px;padding:3px 1px;font-size:clamp(10px,2.5vw,13px);white-space:nowrap;}
  body.two-player #clock {font-size:14px;line-height:17px;margin:2px 0 0;}
  body.two-player #result {position:fixed;z-index:12;left:50%;top:15%;transform:translateX(-50%);width:max-content;max-width:85vw;min-height:0;height:auto;max-height:90px;overflow:visible;pointer-events:none;margin:0;filter:drop-shadow(0 2px 12px #000);}
  body.two-player #result:empty {display:none}
  body.two-player #result .die-object,body.two-player #result .coin-object {width:48px;height:48px;font-size:26px}
  dialog {max-width:calc(100vw - 16px);max-height:calc(100dvh - 24px)}
}
@media (max-width:700px) and (max-height:670px) {
  body.two-player #board .entry {display:flex}
  body.two-player #board .bottom {display:grid}
  body.two-player #board .panel {gap:2px;padding:4px}
  body.two-player #board .lp {font-size:clamp(21px,7vw,37px)}
  body.two-player #board .controls button {min-height:30px;height:30px}
  body.two-player #board .entry,body.two-player #board .entry input,body.two-player #board .entry button {min-height:29px;height:29px}
  body.two-player #board .bottom button {min-height:28px;height:28px}
  body.two-player .tool-buttons button {min-height:31px;height:31px}
}
@media (max-width:700px) and (max-height:540px) {
  /* Landscape or exceptionally short viewport: retain all primary controls, allow scrolling rather than clipping. */
  body.two-player {height:auto;min-height:100dvh;max-height:none;overflow-y:auto;grid-template-rows:auto auto auto auto}
  body.two-player #board {grid-template-rows:repeat(2,minmax(155px,auto));overflow:visible}
  body.two-player #board.wide {grid-template-rows:minmax(175px,auto)}
  body.two-player #board .panel {overflow:visible}
}

/* V10 FINAL MOBILE — layout compatto a tutta altezza, controlli verticali. */
@media(max-width:700px){
 body.two-player #board.wide{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr);align-items:stretch;gap:7px}
 body.two-player #board.wide .panel{height:100%;min-height:0;display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;gap:clamp(7px,1.5dvh,18px);padding:clamp(9px,1.7dvh,18px) clamp(5px,1.5vw,12px);overflow:hidden}
 body.two-player #board.wide .panel h2{text-align:center;font-size:clamp(11px,3vw,16px);margin:0}
 body.two-player #board.wide .lp{font-size:clamp(27px,8vw,49px);line-height:1.1;text-align:center;margin:auto 0;min-width:0}
 body.two-player #board.wide .controls{display:flex;flex-direction:column;gap:clamp(7px,1.5dvh,15px);width:100%;margin:0}
 body.two-player #board.wide .controls button{width:100%;min-height:clamp(49px,8dvh,80px);height:auto;flex:0 0 auto;font-size:clamp(14px,3.8vw,19px);font-weight:800;border-radius:10px}
 body.two-player #board.wide .controls button[data-d="-1000"]{order:2}
 body.two-player #board.wide .controls button[data-d="1000"]{order:1}
 body.two-player #board.wide .compact-calc{display:block;width:100%;min-height:clamp(45px,7dvh,65px);height:auto;font-size:clamp(12px,3.3vw,16px);margin:0 0 auto;border-radius:10px}
 body.two-player #board.wide .entry,body.two-player #board.wide .bottom{display:none}
}
@media(max-width:700px) and (max-height:540px){
 body.two-player #board.wide{grid-template-rows:minmax(265px,auto)}
 body.two-player #board.wide .panel{min-height:265px}
}
/* Dialog centrale: leggibile indipendentemente dal tema e dal layout. */
.random-dialog{position:fixed;inset:0;margin:auto;width:min(88vw,360px);max-height:min(86dvh,470px);padding:0;border:2px solid #d5aa58;border-radius:20px;background:linear-gradient(160deg,#27304d,#101726 75%);color:#f5edda;box-shadow:0 18px 70px #000b,0 0 30px #bda05744;overflow:hidden;text-align:center}
.random-dialog::backdrop{background:rgba(0,0,0,.72);backdrop-filter:blur(3px)}
.random-shell{padding:clamp(20px,5vw,32px);display:flex;flex-direction:column;align-items:center;gap:15px}
.random-title{font-weight:900;font-size:clamp(15px,4vw,19px);letter-spacing:.09em;color:#f3d18c}
.random-object{width:clamp(125px,35vw,170px);height:clamp(125px,35vw,170px);display:grid;place-items:center;border:2px solid #bd9856;border-radius:23px;background:radial-gradient(circle at 35% 25%,#475a80,#1b2437 72%);box-shadow:inset 0 2px 20px #0008,0 6px 25px #0007;color:white;font-size:clamp(54px,17vw,85px);font-weight:900;font-family:ui-monospace,Consolas,monospace;line-height:1;will-change:auto}
.random-object.random-coin{border-radius:50%;font-size:clamp(31px,8vw,46px);color:#ffe6a5}
.random-object.is-rolling{animation:random-shake .2s ease-in-out infinite alternate}
.random-object.random-coin.is-rolling{animation:random-flip .35s ease-in-out infinite}
.random-object.is-final{animation:random-arrive .3s ease-out}
.random-caption{font-size:13px;font-weight:750;letter-spacing:.09em;color:#e9d9b5;min-height:18px}
.random-shell button{width:100%;min-height:44px;font-size:16px}
.random-shell button[hidden]{display:none}
@keyframes random-shake{from{transform:rotate(-8deg) scale(.94)}to{transform:rotate(8deg) scale(1.04)}}
@keyframes random-flip{from{transform:rotateY(0)}to{transform:rotateY(180deg)}}
@keyframes random-arrive{from{transform:scale(.83)}to{transform:scale(1)}}
body.power-save .random-object.is-rolling{animation:none}
@media(prefers-reduced-motion:reduce){.random-object.is-rolling,.random-object.is-final{animation:none!important}.random-dialog::backdrop{backdrop-filter:none}}
