:root{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:#0e1116;color:#e8edf3}*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#0e1116}body{overflow-x:hidden}header{height:52px;padding:0 14px;display:flex;align-items:center;gap:12px;background:#171c24;border-bottom:1px solid #2a3340}header span{margin-left:auto}.hidden{display:none!important}main{max-width:1280px;margin:auto;padding:12px}.panel{background:#151b23;border:1px solid #2a3442;border-radius:10px;padding:14px;margin-top:10px}.narrow{max-width:520px;margin:60px auto}.row{display:flex;gap:6px;align-items:center;flex-wrap:wrap}input,select,textarea,button{background:#0f141b;color:#e8edf3;border:1px solid #364253;border-radius:7px;padding:8px}button{cursor:pointer;background:#243249}button:hover{filter:brightness(1.14)}button.ghost{background:transparent}button.danger{background:#5a2630}button.warn{background:#6a4a18}nav{display:flex;gap:6px}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.grid textarea{grid-column:1/-1}.check{display:block;margin:10px 0}.card-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:6px;margin-top:8px}.card{border:1px solid #303b4b;border-radius:8px;padding:8px;background:#10161e}.card hr{border:none;border-top:1px solid #303b4b}.muted{color:#9aa7b6;font-size:12px}.builder{display:grid;grid-template-columns:1fr 1fr;gap:12px}.deckline{display:flex;justify-content:space-between;align-items:center;padding:5px;border-bottom:1px solid #26303c}.room{padding:8px;border-bottom:1px solid #26303c}.admin-grid{display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:14px;align-items:start}.admin-grid>section{background:#10161e;border:1px solid #2a3442;border-radius:9px;padding:10px}.admin-grid h3{margin-top:0}.admin-line{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:7px 0;border-bottom:1px solid #26303c}.admin-badge{display:inline-block;margin-left:6px;padding:2px 6px;border-radius:999px;background:#364c32;font-size:11px}

/* v5 game layout */
.in-game{height:100dvh;overflow:hidden}.in-game>header{display:none}.in-game>main{max-width:none;padding:0;height:100dvh;overflow:hidden}.game-shell{height:100dvh;display:grid;grid-template-columns:280px minmax(0,1fr);background:#0b0f14}.sidebar{height:100dvh;overflow-y:auto;overscroll-behavior:contain;border-right:1px solid #2a3442;background:#121820;padding:8px;display:flex;flex-direction:column;gap:9px}.sidebar-block{background:#0e141c;border:1px solid #263242;border-radius:8px;padding:7px}.sidebar h3{margin:2px 0 6px;font-size:14px}.log{height:32vh;min-height:160px;overflow-y:auto;overscroll-behavior:contain;background:#080c11;border:1px solid #25303c;border-radius:7px;padding:7px;font-size:11px;line-height:1.45}.log time{color:#7f8d9d}.chatrow{display:grid;grid-template-columns:1fr auto;gap:5px;margin-top:5px}.sidebar input[type=number]{width:58px}.sidebar-block>button{width:100%;margin-top:5px}.shortcut-note{font-size:10px;color:#9aa7b6;line-height:1.5;padding:4px}
.game-main{height:100dvh;min-width:0;display:flex;flex-direction:column;padding:0;overflow:hidden}.game-topbar{flex:0 0 auto;min-height:46px;padding:6px 9px;display:flex;gap:10px;align-items:center;justify-content:space-between;border-bottom:1px solid #2a3442;background:#151b23}.actions{display:flex;gap:4px;align-items:center;justify-content:flex-end;flex-wrap:wrap}.actions button{padding:6px 8px;font-size:11px}.block-notice{font-size:11px;padding:4px 7px;border:1px solid #55708d;border-radius:7px;background:#111c28}.selection-bar{flex:0 0 auto;min-height:40px;padding:5px 9px;display:flex;align-items:center;gap:5px;background:#1b2430;border-bottom:1px solid #364253;flex-wrap:wrap}.selection-bar button{padding:5px 7px;font-size:11px}.stack-mode{background:#2a2114}.board-scroll{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:5px;scrollbar-gutter:stable;background:#090d12}.player-side{min-width:760px;background:#121820;border:1px solid #2c3542;border-radius:8px;padding:5px;margin-bottom:5px}.side-head{display:flex;gap:8px;align-items:center;justify-content:space-between;min-height:28px;font-size:12px}.counters{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.counters>span{background:#0b1118;border:1px solid #2a3542;border-radius:999px;padding:2px 6px;font-size:10px}.direct-target{background:#6a2525;border-color:#a54d4d;animation:targetPulse .8s infinite alternate}.zone-row{display:grid;grid-template-columns:1fr 2.25fr 1.35fr;gap:4px}.zone{min-height:104px;background:#0c1117;border:1px dashed #3a4656;border-radius:6px;padding:3px;overflow-x:auto;overflow-y:hidden;white-space:nowrap}.zone h4{position:sticky;left:0;margin:0 0 3px;padding:1px 3px;width:max-content;background:#0c1117e8;color:#aab5c2;font-size:10px;z-index:3}.shield-zone,.hand-zone{min-height:95px;margin-top:4px}.hand-zone{min-height:110px}.hand-zone h4 em{font-style:normal;color:#f0c674}.grave-zone,.mana-zone{min-width:150px}.battle-zone{min-width:310px}
/* fixed slots prevent tapped cards from shifting the whole row */
.mini-slot{position:relative;display:inline-flex;width:76px;height:92px;margin:2px;vertical-align:top;align-items:center;justify-content:center;white-space:normal}.mini-card{position:relative;display:flex;flex-direction:column;justify-content:flex-start;width:68px;height:88px;padding:4px;border:1px solid #3a4656;border-radius:6px;background:#17202b;font-size:9px;cursor:pointer;overflow:hidden;transform-origin:center;transition:transform .12s ease,filter .12s ease}.mini-card b{line-height:1.15}.mini-card small{margin-top:3px;color:#aeb8c4}.mini-card em{font-style:normal;margin-top:auto;font-size:8px;background:#4b365f;border-radius:3px;padding:1px 3px;width:max-content}.mini-card.tap{transform:rotate(90deg) scale(.82)}.mini-card.back{background:repeating-linear-gradient(45deg,#202a37,#202a37 8px,#121821 8px,#121821 16px);color:transparent}.mini-card.selected{outline:2px solid #f0c674;outline-offset:1px}.target-slot{outline:2px dashed #d89b3c;border-radius:8px;animation:targetPulse .9s infinite alternate}@keyframes targetPulse{from{filter:brightness(1)}to{filter:brightness(1.35)}}.stack-badge,.faceup-badge{position:absolute;right:2px;bottom:2px;font-style:normal;background:#614619;color:#fff;border-radius:999px;padding:1px 4px;font-size:8px}.faceup-badge{right:auto;left:2px;background:#285b53}.effect-flash{animation:effectFlash .65s ease-in-out 3;box-shadow:0 0 0 3px #fff9,0 0 16px #fff7}@keyframes effectFlash{0%,100%{filter:brightness(1)}50%{filter:brightness(1.55)}}
.reveal-strip{min-height:102px;border:1px solid #665c3c;background:#18160f;border-radius:6px;padding:4px;margin-bottom:4px;overflow-x:auto;overflow-y:hidden;white-space:nowrap}.private-peek-strip{border-color:#536d8c;background:#101a25}.strip-head{position:sticky;left:0;display:flex;align-items:center;gap:6px;width:max-content;z-index:3;background:inherit;padding:1px 2px;font-size:10px}.strip-head button{font-size:9px;padding:3px 5px}
.move-menu{position:fixed;z-index:15000;right:14px;top:58px;width:205px;max-height:calc(100dvh - 72px);overflow-y:auto;background:#151b23;border:1px solid #49586b;border-radius:9px;padding:8px;box-shadow:0 10px 30px #0008}.move-menu b{display:block;margin-bottom:5px}.move-menu button{display:block;width:100%;margin:3px 0;text-align:left}
.break-overlay{position:fixed;inset:0;z-index:12000;background:#000a;display:flex;align-items:center;justify-content:center;padding:14px;overflow:hidden}.break-modal{width:min(760px,100%);max-height:calc(100dvh - 28px);display:flex;flex-direction:column;background:#151b23;border:1px solid #49586b;border-radius:12px;box-shadow:0 18px 60px #000c;overflow:hidden}.break-header{flex:0 0 auto;display:flex;justify-content:space-between;gap:10px;padding:12px 14px;border-bottom:1px solid #2a3442;background:#171e27}.break-header h3{margin:0 0 3px}.break-count{white-space:nowrap;border:1px solid #49586b;border-radius:999px;padding:4px 8px;font-size:12px}.break-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:10px}.break-card{border:1px solid #354153;border-radius:9px;background:#0f151d;padding:10px;margin-bottom:10px}.break-card-no{font-size:11px;color:#9aa7b6}.break-card-title{display:block;font-size:15px;margin-bottom:7px}.break-card-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;max-height:30vh;overflow-y:auto;padding:7px;background:#0b1016;border:1px solid #293442;border-radius:7px}.break-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:8px}.direct-footer{padding:9px 12px;border-top:1px solid #2a3442;text-align:right}.direct-hand{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:7px}.direct-card{border:1px solid #344152;border-radius:8px;padding:8px;background:#0e141c}.direct-card .row{margin-top:6px}.direct-card button{font-size:10px;padding:5px}
@media(max-width:1000px){.game-shell{grid-template-columns:230px minmax(0,1fr)}.admin-grid{grid-template-columns:1fr}.mini-slot{width:68px}.mini-card{width:61px}.player-side{min-width:680px}}
@media(max-width:700px){.game-shell{grid-template-columns:200px minmax(0,1fr)}.sidebar{padding:5px}.game-topbar{align-items:flex-start}.actions{max-width:70%}.player-side{min-width:640px}.zone-row{grid-template-columns:150px 300px 180px}.mini-slot{width:64px}.mini-card{width:58px;font-size:8px}}

/* v5.1 */
.mana-zone{scrollbar-gutter:stable both-edges}
.stack-view-overlay{position:fixed;inset:0;z-index:11800;background:#0008;display:flex;align-items:center;justify-content:center;padding:16px}
.stack-view-modal{width:min(760px,96vw);max-height:calc(100dvh - 32px);display:flex;flex-direction:column;background:#151b23;border:1px solid #49586b;border-radius:12px;box-shadow:0 18px 60px #000c;overflow:hidden}
.stack-view-scroll{overflow:auto;padding:10px;display:grid;gap:8px}
.stack-view-card{border:1px solid #354153;border-radius:9px;background:#0f151d;padding:10px}
.stack-index{font-size:11px;color:#9aa7b6;margin-bottom:3px}.stack-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}.stack-actions button{font-size:11px;padding:5px 7px}
.direct-float{position:fixed;z-index:12500;right:18px;top:78px;width:min(520px,calc(100vw - 24px));max-height:min(70vh,620px);display:flex;flex-direction:column;background:#151b23;border:1px solid #7b5151;border-radius:11px;box-shadow:0 16px 50px #000b;overflow:hidden}
.direct-drag-handle{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding:9px 11px;background:#29191b;border-bottom:1px solid #5b3337;cursor:move;user-select:none;touch-action:none}.direct-drag-handle b{font-size:13px}.drag-mark{font-size:18px;color:#d7a4a4}
.direct-float-body{padding:9px;overflow:auto;min-height:0}.direct-float .direct-hand{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}.direct-float .direct-footer{flex:0 0 auto;background:#151b23}
@media(max-width:700px){.direct-float{width:min(420px,calc(100vw - 12px));right:6px;top:60px;max-height:72vh}}

/* v6.0 card/deck management */
.name-list,.builder-name-list,.admin-card-list{margin-top:8px;border:1px solid #2a3442;border-radius:8px;overflow:hidden;background:#0e141c}.name-list{max-height:68vh;overflow-y:auto}.builder-name-list{max-height:55vh;overflow-y:auto}.admin-card-list{max-height:34vh;overflow-y:auto}.card-name-row,.builder-name-row{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:7px 9px;border-bottom:1px solid #26303c;min-height:34px}.card-name-row:last-child,.builder-name-row:last-child{border-bottom:none}.card-name-row:hover,.builder-name-row:hover{background:#151d27}.builder-name-row button{padding:4px 9px}.bulk-preview{max-height:180px;overflow:auto;border:1px solid #2a3442;border-radius:7px;padding:7px;margin:7px 0;background:#0b1016;font-size:12px}.bulk-preview>div{padding:2px 0}.admin-grid{grid-template-columns:minmax(360px,1.4fr) 1fr 1fr}#admin textarea{width:100%}

/* DMSIM v6 responsiveness */
button,.card,.zone-card,.builder-name-row{touch-action:manipulation}
button:active,.zone-card:active{transform:scale(.98)}
#cardSearch,#deckCardSearch,#adminCardSearch,#deckCodeInput{min-height:42px;font-size:16px}
.builder-name-list,.name-list,.admin-card-list{contain:content}

.sync-box{margin-top:12px;padding:14px;border:1px solid #334154;border-radius:10px;background:#0b1119}.sync-box h4{margin:0 0 6px;color:#f0f5fb}.sync-progress{margin-top:10px;padding:12px;min-height:80px;border-radius:8px;background:#111923;border:1px solid #2d3a4b;line-height:1.5;color:#dce6f2}.sync-box label{font-size:12px;color:#aebdce}.sync-box label input{width:90px;margin-left:4px}.sync-title{display:flex;justify-content:space-between;gap:10px;border-bottom:1px solid #273344;padding-bottom:8px;margin-bottom:8px}.sync-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:6px}.sync-stats span{background:#0b1119;border:1px solid #263344;border-radius:7px;padding:6px 8px}.sync-log{margin-top:10px;max-height:220px;overflow:auto;background:#080d13;border:1px solid #273344;border-radius:7px;padding:8px;font-size:12px}.sync-log>div{padding:3px 0;border-bottom:1px solid #17202b}.sync-error{margin-top:8px;padding:7px;background:#381820;border:1px solid #6c2c3c;border-radius:6px;color:#ffbdc8}.good{color:#7ee0a4}.bad{color:#ff8f9f}

.sync-log{overscroll-behavior:contain;scrollbar-gutter:stable;user-select:text;touch-action:pan-y}
.sync-log:hover{border-color:#526983}
.rebuild-box{border-color:#5d4650;background:#120e13}
.rebuild-box h4{color:#ffd7e0}
.rebuild-box .sync-progress{background:#100c11;border-color:#4b3740}

.mini-card.hyper-mode{box-shadow:0 0 0 2px #8f69ff,0 0 16px rgba(143,105,255,.45);border-color:#a98cff}
.hyper-badge{position:absolute;right:4px;bottom:4px;background:#7a52e8;color:#fff;border-radius:5px;padding:2px 5px;font-size:9px;font-style:normal;font-weight:800;letter-spacing:.4px}
.power-label{font-weight:800}

.admin-grid-two{grid-template-columns:minmax(520px,1.45fr) minmax(300px,.9fr)!important;gap:14px}
.admin-side-stack{display:flex;flex-direction:column;gap:14px;min-width:0}
.admin-side-stack>section{background:#10161e;border:1px solid #2a3442;border-radius:9px;padding:10px}
.admin-side-stack h3{margin-top:0}
.setting-line{display:flex;justify-content:space-between;align-items:center;gap:14px}
.setting-line p{margin:5px 0 0}
#registrationToggleBtn{min-width:145px}
@media(max-width:900px){.admin-grid-two{grid-template-columns:1fr!important}}

.opponent-side.mirror-side{border-bottom:2px solid #334252;padding-bottom:16px}
.opponent-side .hand-zone{margin-bottom:10px}
.opponent-side .shield-zone{margin-bottom:10px}
.opponent-zone-row{grid-template-columns:1fr 2fr 1fr}
.zone-title-row{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.zone-title-row h4{margin:0}
.zone-actions{display:flex;gap:5px;flex-wrap:wrap}
.zone-actions button{padding:4px 7px;font-size:11px}
.opponent-side .mini-card:not(.back){cursor:pointer}

/* ===== DMSIM v6.8 : deck slot / D&D / mobile game UI ===== */
.shield-deck-row{display:grid;grid-template-columns:minmax(0,1fr) 88px;gap:5px;margin-top:4px;align-items:stretch}
.shield-deck-row .shield-zone{margin-top:0}
.deck-slot-wrap{display:flex;align-items:stretch;justify-content:center}
.deck-slot{position:relative;width:84px;min-height:95px;border:1px dashed #596777;border-radius:8px;background:#0b1118;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;cursor:pointer;overflow:hidden;user-select:none}
.deck-card-back{width:48px;height:61px;border:1px solid #435164;border-radius:6px;background:repeating-linear-gradient(45deg,#263242,#263242 7px,#151d28 7px,#151d28 14px);box-shadow:3px 3px 0 #0d1219,6px 6px 0 #1a2430;margin-bottom:2px}
.deck-slot>b{font-size:10px}.deck-slot>span{font-size:10px;color:#aab5c2}
.deck-drop-part{position:absolute;left:0;right:0;height:24px;display:flex;align-items:center;justify-content:center;font-size:9px;color:transparent;pointer-events:auto;transition:.12s}
.deck-drop-top{top:0}.deck-drop-bottom{bottom:0}
.dragging-card .deck-drop-part{color:#9fb3ca;background:#172232cc}
.zone-card-strip{min-height:74px;white-space:nowrap}
.drop-ready{outline:1px dashed #637b98!important;outline-offset:-2px}
.drop-hover{outline:3px solid #d9a441!important;background:#1a2119!important;filter:brightness(1.12)}
.drag-ghost{position:fixed!important;z-index:30000!important;pointer-events:none!important;opacity:.88;transform:none!important;box-shadow:0 10px 28px #000c,0 0 0 2px #d9a441;left:0;top:0}
body.dragging-card{cursor:grabbing}
.mini-card[data-draggable-card="1"]{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.deck-menu-row{display:grid;grid-template-columns:60px 1fr;gap:5px;margin:5px 0}.deck-menu-row input{min-width:0}
.deck-menu-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:5px}.deck-menu-head button{width:auto!important;margin:0!important}
.mobile-sidebar-head,.mobile-game-nav,.mobile-drawer-backdrop{display:none}
.grave-actions button{font-size:9px!important;padding:3px 5px!important}

/* phone: game screen only becomes a dedicated layout */
@media(max-width:760px){
  body.in-game{overflow:hidden}
  body.in-game>header{display:none}
  body.in-game main{padding:0;max-width:none}
  body.in-game #app>nav{display:none}
  body.in-game #app{margin:0;padding:0}
  body.in-game #game{margin:0;padding:0;border:0;border-radius:0;max-width:none}
  .game-shell{height:100dvh;display:block;position:relative}
  .game-main{height:100dvh;width:100%;padding-bottom:58px}
  .game-topbar{min-height:46px;padding:5px 7px;gap:5px;align-items:flex-start}
  .game-topbar>b{font-size:12px;max-width:45%;line-height:1.25}
  .game-topbar .actions{gap:3px}
  .game-topbar .actions button{padding:5px 7px;font-size:10px}
  .game-topbar .actions>span{font-size:10px}
  .desktop-extra{display:none!important}
  .board-scroll{padding:4px 4px 12px;overflow-x:hidden;overflow-y:auto;scrollbar-gutter:auto}
  .player-side{min-width:0!important;width:100%;box-sizing:border-box;padding:4px;margin-bottom:5px}
  .side-head{align-items:flex-start;gap:4px}
  .side-head>b{font-size:12px;flex:0 0 auto}
  .counters{gap:3px;justify-content:flex-end}
  .counters>span{font-size:8px;padding:2px 4px}
  .zone-row,.opponent-zone-row{grid-template-columns:1fr!important;gap:4px}
  .zone{width:100%;box-sizing:border-box;min-width:0!important;min-height:88px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:thin}
  .battle-zone{min-height:96px}
  .hand-zone{min-height:100px;margin-top:4px}
  .shield-deck-row{grid-template-columns:minmax(0,1fr) 76px;gap:4px}
  .deck-slot{width:72px;min-height:92px}
  .deck-card-back{width:40px;height:52px}
  .mini-slot{width:66px;height:82px;margin:1px}
  .mini-card{width:59px;height:78px;font-size:8px;padding:3px}
  .mini-card small{font-size:7px}
  .mini-card[data-draggable-card="1"]{touch-action:pan-x}
  .reveal-strip{min-height:88px}
  .selection-bar{font-size:10px;padding:4px 6px;max-height:92px;overflow-y:auto}
  .selection-bar button{font-size:9px;padding:4px 6px}

  .sidebar{position:fixed;z-index:21000;left:0;right:0;bottom:0;top:auto;width:100%;height:min(72dvh,620px);box-sizing:border-box;border-right:0;border-top:1px solid #465469;border-radius:14px 14px 0 0;transform:translateY(105%);transition:transform .2s ease;padding:9px 9px calc(12px + env(safe-area-inset-bottom));box-shadow:0 -18px 50px #000b}
  .sidebar.mobile-open{transform:translateY(0)}
  .mobile-sidebar-head{display:flex;align-items:center;justify-content:space-between;position:sticky;top:-9px;z-index:3;background:#121820;padding:7px 2px;border-bottom:1px solid #2a3442}
  .sidebar .log{height:28dvh;min-height:150px}
  .shortcut-note{display:none}
  .mobile-drawer-backdrop{position:fixed;z-index:20500;inset:0;background:#0008}
  .mobile-drawer-backdrop.show{display:block}
  .mobile-game-nav{display:grid;grid-template-columns:1.1fr .9fr 1.1fr .8fr;gap:4px;position:fixed;z-index:20000;left:0;right:0;bottom:0;height:54px;padding:5px 6px calc(5px + env(safe-area-inset-bottom));background:#111821;border-top:1px solid #344153;box-sizing:content-box}
  .mobile-game-nav button{font-size:10px;padding:6px 4px}
  .move-menu,.deck-menu{right:8px;left:8px;top:auto;bottom:calc(62px + env(safe-area-inset-bottom));width:auto;max-height:65dvh;border-radius:12px}
  .break-overlay{padding:6px}.break-modal{max-height:96dvh}
  .direct-float{max-width:calc(100vw - 12px)!important}
}

/* ===== DMSIM v6.9 ===== */
.home-hero{display:flex;justify-content:space-between;gap:18px;align-items:center;margin-bottom:16px;padding:8px 2px}
.home-hero h2{font-size:28px;margin:0 0 6px}
.home-user{display:flex;flex-direction:column;align-items:flex-end;background:#111923;border:1px solid #2b3948;border-radius:10px;padding:10px 14px}
.home-user span{font-size:10px;color:#9aabbc}.home-user b{font-size:18px}
.home-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.home-card{background:#101720;border:1px solid #283646;border-radius:12px;padding:16px;min-height:130px}
.home-card h3{margin:0 0 8px}.home-card p{color:#a8b4c0}
.home-stats{grid-column:1/-1}
.home-stat-row{display:flex;justify-content:space-between;border-bottom:1px solid #24313f;padding:8px 0}
.modal-layer{position:fixed;z-index:35000;inset:0;background:#0009;display:flex;align-items:center;justify-content:center;padding:16px}
.solo-setup{width:min(520px,100%);margin:0}.solo-setup label{display:block;margin:12px 0}.solo-setup select{width:100%;margin-top:5px}
.between{justify-content:space-between}
.solo-badge{font-size:9px;background:#7257c9;color:#fff;border-radius:999px;padding:2px 6px}
.solo-control-switch{display:flex;gap:3px}
.admin-user-actions{display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end}

@media(max-width:760px){
  .home-grid{grid-template-columns:1fr}.home-stats{grid-column:auto}.home-hero{align-items:flex-start}.home-user{padding:7px 9px}
  body.in-game .game-main{height:100dvh;overflow:hidden}
  body.in-game .board-scroll{
    height:calc(100dvh - 106px);
    overflow:hidden!important;
    display:grid;
    grid-template-rows:1fr 1fr;
    gap:2px;
    padding:2px 3px 58px;
    box-sizing:border-box;
  }
  body.in-game .player-side{
    min-height:0!important;
    height:100%;
    overflow:hidden!important;
    display:grid;
    grid-template-rows:auto auto minmax(0,1fr);
    gap:2px;
    padding:2px 3px;
    margin:0;
  }
  body.in-game .side-head{min-height:20px}
  body.in-game .side-head>b{font-size:9px}
  body.in-game .counters>span{font-size:6px;padding:1px 3px}
  body.in-game .zone-row,
  body.in-game .opponent-zone-row{
    display:grid!important;
    grid-template-columns:.8fr 1.4fr .8fr!important;
    gap:2px;
    min-height:0;
    overflow:hidden;
  }
  body.in-game .zone{
    min-height:0!important;
    height:100%;
    padding:2px;
    overflow:hidden!important;
  }
  body.in-game .zone h4{font-size:7px;margin:0 0 1px}
  body.in-game .zone-card-strip{
    min-height:0;
    height:calc(100% - 10px);
    overflow:hidden;
    white-space:nowrap;
  }
  body.in-game .shield-deck-row{
    grid-template-columns:minmax(0,1fr) 50px;
    min-height:0;
    gap:2px;
  }
  body.in-game .shield-zone{height:100%}
  body.in-game .deck-slot{width:48px;min-height:0;height:100%}
  body.in-game .deck-card-back{width:25px;height:32px;box-shadow:2px 2px 0 #0d1219;margin:0}
  body.in-game .deck-slot>b,body.in-game .deck-slot>span{font-size:6px}
  body.in-game .mini-slot{width:34px;height:44px;margin:0}
  body.in-game .mini-card{width:30px;height:40px;font-size:5.5px;padding:1px;border-radius:3px}
  body.in-game .mini-card small{font-size:5px}
  body.in-game .stack-badge,body.in-game .faceup-badge,body.in-game .hyper-badge{font-size:5px;padding:1px 2px}
  body.in-game .hand-zone{min-height:0!important;height:42px;margin:0}
  body.in-game .shield-deck-row{height:44px}
  body.in-game .reveal-strip,body.in-game .private-peek-strip{position:absolute;z-index:8000;left:4px;right:4px;max-height:84px;overflow:auto}
  body.in-game .opponent-side .reveal-strip{top:44px}
  body.in-game .my-side .reveal-strip{bottom:62px}
  body.in-game .zone-actions{display:none}
  body.in-game .game-topbar{height:48px;overflow:hidden}
  body.in-game .game-topbar>b{font-size:9px;max-width:34%}
  body.in-game .game-topbar .actions{flex-wrap:nowrap;overflow:hidden}
  body.in-game .solo-control-switch button{font-size:7px;padding:3px 4px}
}

/* ===== DMSIM v6.9.2 ===== */
.turn-indicator{font-weight:800;border-radius:999px;padding:4px 8px;white-space:nowrap}
.turn-indicator.my-turn{background:#263a2b;border:1px solid #486b50}
.turn-indicator.opp-turn{background:#3b2929;border:1px solid #724848}
.opponent-hand-zone{cursor:pointer}
.handes-hint{font-size:8px;font-weight:400;margin-left:6px;color:#91a7bf}
.handes-open-note{padding:8px;line-height:1.5;border:1px solid #293849;border-radius:6px;margin:5px 0}

@media(max-width:760px){
  .mobile-hide{display:none!important}
  .mobile-game-nav{grid-template-columns:1.08fr .82fr 1.02fr .7fr .68fr}
  .turn-indicator{font-size:9px!important;padding:3px 5px}
  body.in-game .hand-zone{
    height:58px!important;
    min-height:58px!important;
  }
  body.in-game .hand-zone .zone-card-strip{
    height:47px!important;
  }
  body.in-game .hand-zone .mini-slot{
    width:44px!important;
    height:54px!important;
    margin:0 1px!important;
  }
  body.in-game .hand-zone .mini-card{
    width:40px!important;
    height:51px!important;
    font-size:6.5px!important;
    padding:2px!important;
  }
  body.in-game .hand-zone .mini-card small{font-size:5.5px!important}
  body.in-game .hand-zone h4{font-size:7.5px}
  body.in-game .handes-hint{font-size:5.5px;margin-left:3px}
}

/* ===== DMSIM v7.1.1.1 ===== */
.profile-panel{width:min(620px,100%);max-height:88vh;overflow:auto}
.profile-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0}
.profile-summary>div{background:#0d141c;border:1px solid #293746;border-radius:8px;padding:10px;display:flex;flex-direction:column;gap:4px}
.profile-summary span{font-size:10px;color:#93a4b6}
.profile-panel input{width:100%;box-sizing:border-box;margin:5px 0}
.home-user small{color:#8fa0b1;margin-top:3px}
@media(max-width:760px){
  .profile-summary{grid-template-columns:1fr}
  .profile-panel{max-height:82dvh}
}

/* ===== DMSIM v7.1.1 : battle row + mana list ===== */
.arena-layout{display:grid;grid-template-rows:minmax(112px,auto) minmax(104px,auto);gap:5px;margin-top:4px}
.opponent-arena{grid-template-rows:minmax(104px,auto) minmax(112px,auto)}
.aux-zone-row{display:grid;grid-template-columns:1fr 1.35fr;gap:5px;min-width:0}
.opponent-aux-row{grid-template-columns:1.35fr 1fr}
.battle-zone-full{width:100%;min-width:0!important;box-sizing:border-box}
.aux-zone-row .grave-zone,.aux-zone-row .mana-zone{min-width:0}
.mana-head-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.mana-list-btn{padding:3px 7px!important;font-size:10px!important}
.mana-list-layer{position:fixed;z-index:36000;inset:0;background:#000a;display:flex;align-items:center;justify-content:center;padding:14px}
.mana-list-sheet{width:min(820px,96vw);max-height:86dvh;background:#101720;border:1px solid #344356;border-radius:13px;box-shadow:0 20px 70px #000d;padding:12px;display:flex;flex-direction:column;gap:10px}
.mana-list-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.mana-list-head>div{display:flex;align-items:baseline;gap:8px}.mana-list-head span{font-size:11px;color:#9eacba}
.mana-list-cards{overflow:auto;display:flex;flex-wrap:wrap;align-content:flex-start;gap:4px;padding:4px;background:#0b1118;border:1px solid #273443;border-radius:8px;min-height:110px}
.mana-list-cards .mini-slot{flex:0 0 auto}
.mana-list-actions{display:flex;gap:6px;flex-wrap:wrap}

@media(max-width:760px){
  body.in-game .arena-layout{
    display:grid!important;
    grid-template-rows:minmax(0,1.35fr) minmax(0,.8fr)!important;
    gap:2px;
    min-height:0;
    overflow:hidden;
  }
  body.in-game .opponent-arena{
    grid-template-rows:minmax(0,.8fr) minmax(0,1.35fr)!important;
  }
  body.in-game .aux-zone-row,
  body.in-game .opponent-aux-row{
    display:grid!important;
    grid-template-columns:.72fr 1.28fr!important;
    gap:2px;
    min-height:0;
    overflow:hidden;
  }
  body.in-game .opponent-aux-row{grid-template-columns:1.28fr .72fr!important}
  body.in-game .battle-zone-full{min-height:0!important;height:100%;overflow:hidden!important}
  body.in-game .arena-layout .zone{height:100%;min-height:0!important}
  body.in-game .mana-head-actions .zone-actions{display:none}
  body.in-game .mana-list-btn{display:inline-flex!important;font-size:6.5px!important;padding:1px 4px!important}
  .mana-list-layer{align-items:flex-end;padding:0}
  .mana-list-sheet{width:100%;max-height:72dvh;border-radius:14px 14px 0 0;padding:9px;padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .mana-list-cards{min-height:180px;max-height:52dvh;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
  .mana-list-cards .mini-slot{width:100%!important;height:88px!important;margin:0!important}
  .mana-list-cards .mini-card{width:calc(100% - 6px)!important;height:82px!important;font-size:8px!important;padding:3px!important}
  .mana-list-cards .mini-card small{font-size:6.5px!important}
  .mana-list-actions button{flex:1}
}

/* ===== DMSIM v7.1.3 layout refinement ===== */

/* PC: use the available viewport instead of a narrow stacked page */
@media(min-width:761px){
  body.in-game{overflow:hidden}
  body.in-game main{max-width:none!important;width:100%!important;padding:8px!important;box-sizing:border-box}
  body.in-game #app{width:100%!important;max-width:none!important}
  body.in-game #game{width:100%!important;max-width:none!important;margin:0!important}
  body.in-game .game-shell{height:calc(100vh - 16px);min-height:0}
  body.in-game .game-main{height:100%;min-width:0;display:grid;grid-template-rows:auto auto minmax(0,1fr)}
  body.in-game .board-scroll{
    height:auto!important;
    min-height:0;
    overflow:hidden!important;
    display:grid;
    grid-template-rows:1fr 1fr;
    gap:5px;
    padding:4px;
  }
  body.in-game .player-side{
    min-height:0!important;
    height:100%;
    display:grid;
    grid-template-rows:auto minmax(0,1fr);
    overflow:hidden;
    padding:5px;
    margin:0;
  }
  body.in-game .player-side .side-head{min-height:26px}
  body.in-game .arena-layout{
    min-height:0;
    height:100%;
    grid-template-rows:minmax(0,1.35fr) minmax(0,.8fr)!important;
    gap:4px;
  }
  body.in-game .opponent-arena{
    grid-template-rows:minmax(0,.8fr) minmax(0,1.35fr)!important;
  }
  body.in-game .aux-zone-row{
    grid-template-columns:minmax(180px,.8fr) minmax(300px,1.7fr)!important;
  }
  body.in-game .opponent-aux-row{
    grid-template-columns:minmax(300px,1.7fr) minmax(180px,.8fr)!important;
  }
  body.in-game .zone{
    min-height:0!important;
    height:100%;
    box-sizing:border-box;
    overflow-x:auto;
    overflow-y:hidden;
  }
  body.in-game .battle-zone-full{min-height:0!important}
  body.in-game .shield-deck-row{min-height:88px;max-height:104px}
  body.in-game .hand-zone{min-height:88px!important;max-height:110px}
}

/* Keep hand / mana / grave horizontally scrollable on phones */
@media(max-width:760px){
  body.in-game .hand-zone,
  body.in-game .mana-zone,
  body.in-game .grave-zone{
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-x;
  }
  body.in-game .hand-zone .zone-card-strip,
  body.in-game .mana-zone .zone-card-strip,
  body.in-game .grave-zone .zone-card-strip{
    display:block!important;
    width:max-content!important;
    min-width:100%;
    white-space:nowrap!important;
    overflow:visible!important;
  }
  body.in-game .hand-zone .mini-slot,
  body.in-game .mana-zone .mini-slot,
  body.in-game .grave-zone .mini-slot{
    display:inline-flex!important;
    flex:0 0 auto!important;
  }
  .grave-list-btn{display:inline-flex!important;font-size:6.5px!important;padding:1px 4px!important}
}

/* Grave list modal mirrors mana list */
.grave-head-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.grave-list-btn{padding:3px 7px!important;font-size:10px!important}
.grave-list-layer{position:fixed;z-index:36000;inset:0;background:#000a;display:flex;align-items:center;justify-content:center;padding:14px}
.grave-list-sheet{width:min(820px,96vw);max-height:86dvh;background:#101720;border:1px solid #344356;border-radius:13px;box-shadow:0 20px 70px #000d;padding:12px;display:flex;flex-direction:column;gap:10px}
.grave-list-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.grave-list-head>div{display:flex;align-items:baseline;gap:8px}.grave-list-head span{font-size:11px;color:#9eacba}
.grave-list-cards{overflow:auto;display:flex;flex-wrap:wrap;align-content:flex-start;gap:4px;padding:4px;background:#0b1118;border:1px solid #273443;border-radius:8px;min-height:110px}
.grave-list-cards .mini-slot{flex:0 0 auto}
.grave-list-actions{display:flex;gap:6px;flex-wrap:wrap}

@media(max-width:760px){
  .grave-list-layer{align-items:flex-end;padding:0}
  .grave-list-sheet{width:100%;max-height:72dvh;border-radius:14px 14px 0 0;padding:9px;padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .grave-list-cards{min-height:180px;max-height:52dvh;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
  .grave-list-cards .mini-slot{width:100%!important;height:88px!important;margin:0!important}
  .grave-list-cards .mini-card{width:calc(100% - 6px)!important;height:82px!important;font-size:8px!important;padding:3px!important}
  .grave-list-cards .mini-card small{font-size:6.5px!important}
  .grave-list-actions button{flex:1}
}

/* ===== DMSIM v7.1.4 fixed board layout ===== */

/* Shared zone behavior: fixed boxes, cards scroll inside instead of resizing the board. */
body.in-game .player-side .zone{box-sizing:border-box;min-width:0}
body.in-game .battle-zone-full,
body.in-game .mana-zone,
body.in-game .hand-zone,
body.in-game .grave-zone,
body.in-game .shield-zone{
  overflow:hidden!important;
}
body.in-game .zone-card-strip{
  overflow-x:auto!important;
  overflow-y:hidden!important;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
  white-space:nowrap;
}
body.in-game .zone-card-strip .mini-slot{flex:0 0 auto}

/* Desired order:
   MY SIDE: battle / [shield deck grave] / mana / hand
   OPP SIDE is mirrored vertically.
*/
body.in-game .middle-zone-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) 92px minmax(150px,.34fr);
  gap:5px;
  min-width:0;
}
body.in-game .opponent-middle-row{
  grid-template-columns:minmax(150px,.34fr) 92px minmax(0,1fr);
}

/* PC: readable fixed-size board. Use width, not microscopic scaling. */
@media(min-width:761px){
  body.in-game{overflow:hidden}
  body.in-game main,
  body.in-game #app,
  body.in-game #game{width:100%!important;max-width:none!important;margin:0!important;box-sizing:border-box}
  body.in-game main{padding:5px!important}

  body.in-game .game-shell{
    height:calc(100vh - 10px)!important;
    min-height:620px;
    overflow:hidden;
  }
  body.in-game .game-main{height:100%;min-width:0;min-height:0}
  body.in-game .board-scroll{
    height:100%!important;
    min-height:0!important;
    overflow:hidden!important;
    display:grid!important;
    grid-template-rows:minmax(0,1fr) minmax(0,1fr)!important;
    gap:5px!important;
    padding:3px!important;
  }
  body.in-game .player-side{
    height:100%!important;
    min-height:0!important;
    overflow:hidden!important;
    display:grid!important;
    gap:3px!important;
    padding:4px!important;
    margin:0!important;
  }
  body.in-game .my-side{
    grid-template-rows:24px minmax(96px,1.35fr) 102px 92px 102px!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:24px 102px 92px 102px minmax(96px,1.35fr)!important;
  }

  body.in-game .battle-zone-full{height:100%!important;min-height:96px!important}
  body.in-game .middle-zone-row{height:102px!important;min-height:102px!important}
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{height:102px!important;min-height:102px!important}
  body.in-game .mana-zone{height:92px!important;min-height:92px!important}
  body.in-game .hand-zone{height:102px!important;min-height:102px!important}

  /* Restore readable card size. */
  body.in-game .mini-slot{width:72px!important;height:82px!important;margin-right:4px!important}
  body.in-game .mini-card{width:66px!important;height:76px!important;font-size:9px!important;padding:4px!important}
  body.in-game .mini-card small{font-size:7px!important}
  body.in-game .zone h4{font-size:11px!important;margin:2px 4px!important}
  body.in-game .zone-card-strip{height:calc(100% - 20px)!important}
  body.in-game .deck-card{transform:none!important}
}

/* Phone/tablet: same logical layout, with horizontal scrolling in hand/mana/grave. */
@media(max-width:760px){
  body.in-game .my-side{
    display:grid!important;
    grid-template-rows:auto 1.35fr .9fr .8fr 1fr!important;
    gap:2px!important;
  }
  body.in-game .opponent-side{
    display:grid!important;
    grid-template-rows:auto 1fr .8fr .9fr 1.35fr!important;
    gap:2px!important;
  }
  body.in-game .middle-zone-row,
  body.in-game .opponent-middle-row{
    grid-template-columns:minmax(0,1fr) 42px minmax(64px,.34fr)!important;
    gap:2px!important;
    min-height:0!important;
  }
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    min-height:0!important;
    height:100%!important;
  }
  body.in-game .battle-zone-full,
  body.in-game .mana-zone,
  body.in-game .hand-zone{
    height:100%!important;
    min-height:0!important;
  }
  body.in-game .hand-zone .zone-card-strip,
  body.in-game .mana-zone .zone-card-strip,
  body.in-game .grave-zone .zone-card-strip{
    display:flex!important;
    flex-wrap:nowrap!important;
    width:auto!important;
    min-width:100%;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    white-space:nowrap!important;
    touch-action:pan-x;
  }
}

/* ===== DMSIM v7.1.5 ===== */
.compact-grave-zone{min-width:120px!important;overflow:hidden!important}
.grave-pile-wrap{height:calc(100% - 22px);display:flex;align-items:center;justify-content:center;overflow:hidden}
.grave-pile{position:relative;width:70px;height:82px;cursor:pointer;flex:0 0 auto}
.grave-pile .mini-slot{position:absolute!important;left:0;top:0;margin:0!important;z-index:5}
.grave-stack-shadow{position:absolute;width:66px;height:76px;border:1px solid #465466;border-radius:6px;background:#111923}
.grave-shadow-1{left:3px;top:2px;z-index:4}.grave-shadow-2{left:6px;top:4px;z-index:3}.grave-shadow-3{left:9px;top:6px;z-index:2}
.grave-count-badge{position:absolute;right:-4px;bottom:-4px;z-index:8;min-width:20px;height:20px;border-radius:999px;background:#26374b;border:1px solid #657a94;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:700}
.grave-empty{border:1px dashed #3a4656;border-radius:7px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:#8998a8;gap:2px}
.grave-empty span{font-size:10px}.grave-empty small{font-size:8px}
.zone-card-strip[id]{scroll-behavior:auto!important;overscroll-behavior-inline:contain}

@media(min-width:761px){
  body.in-game .my-side{grid-template-rows:24px minmax(92px,1.15fr) 102px 86px 132px!important}
  body.in-game .opponent-side{grid-template-rows:24px 132px 86px 102px minmax(92px,1.15fr)!important}
  body.in-game .hand-zone{height:132px!important;min-height:132px!important}
  body.in-game .hand-zone .zone-card-strip{height:108px!important}
  body.in-game .hand-zone .mini-slot{width:88px!important;height:106px!important;margin-right:5px!important}
  body.in-game .hand-zone .mini-card{width:80px!important;height:98px!important;font-size:10px!important;padding:4px!important}
  body.in-game .hand-zone .mini-card small{font-size:8px!important}
  body.in-game .mana-zone{height:86px!important;min-height:86px!important}
}
@media(max-width:760px){
  body.in-game .my-side{grid-template-rows:auto 1.2fr .82fr .7fr 1.28fr!important}
  body.in-game .opponent-side{grid-template-rows:auto 1.28fr .7fr .82fr 1.2fr!important}
  body.in-game .hand-zone .zone-card-strip{height:100%!important;min-height:0!important}
  body.in-game .hand-zone .mini-slot{width:52px!important;height:64px!important;margin-right:2px!important}
  body.in-game .hand-zone .mini-card{width:47px!important;height:60px!important;font-size:7.5px!important;padding:2px!important}
  body.in-game .hand-zone .mini-card small{font-size:6px!important}
  .grave-pile{width:42px;height:52px}
  .grave-pile .mini-slot{width:40px!important;height:50px!important}
  .grave-pile .mini-card{width:36px!important;height:46px!important;font-size:6px!important}
  .grave-stack-shadow{width:36px;height:46px}
  .grave-count-badge{width:16px;height:16px;min-width:16px;font-size:7px}
}

/* ===== DMSIM v7.1.6 board visibility tuning ===== */

/*
  Goals:
  - reduce wasted upper/board whitespace
  - make hand cards properly readable
  - keep graveyard as a one-card pile immediately beside deck
  - leave the remaining horizontal area intentionally empty for a future extra deck / 超次元 zone
  - zone sizes do not change depending on whether they are empty
*/

@media(min-width:761px){

  /* Slightly tighter global game chrome to recover vertical room for cards. */
  body.in-game main{padding:2px!important}
  body.in-game .game-shell{
    height:calc(100vh - 4px)!important;
    min-height:620px!important;
  }
  body.in-game .board-scroll{
    gap:3px!important;
    padding:1px!important;
  }
  body.in-game .player-side{
    gap:2px!important;
    padding:2px!important;
  }
  body.in-game .side-head{
    min-height:20px!important;
    height:20px!important;
    padding:0 3px!important;
  }

  /*
    More vertical space goes to the hand.
    Battle/mana remain fixed and usable; empty zones do not collapse.
  */
  body.in-game .my-side{
    grid-template-rows:20px minmax(76px,1fr) 94px 72px 154px!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:20px 154px 72px 94px minmax(76px,1fr)!important;
  }

  body.in-game .battle-zone-full{
    min-height:76px!important;
  }
  body.in-game .mana-zone{
    height:72px!important;
    min-height:72px!important;
  }
  body.in-game .middle-zone-row{
    height:94px!important;
    min-height:94px!important;

    /*
      Shield receives the main width.
      Deck and grave are fixed compact slots.
      Remaining width stays unused to the right for a future 超次元 zone.
    */
    display:grid!important;
    grid-template-columns:minmax(420px,62%) 78px 92px 1fr!important;
    gap:3px!important;
    justify-content:start!important;
  }
  body.in-game .opponent-middle-row{
    /* mirrored side: intentional spare area first, then grave/deck/shields */
    grid-template-columns:1fr 92px 78px minmax(420px,62%)!important;
  }

  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    height:94px!important;
    min-height:94px!important;
  }

  /* Graveyard hugs the deck: no giant internal empty strip. */
  body.in-game .compact-grave-zone{
    width:92px!important;
    min-width:92px!important;
    max-width:92px!important;
    padding:2px!important;
  }
  body.in-game .compact-grave-zone .zone-title-row{
    gap:1px!important;
    min-width:0!important;
  }
  body.in-game .compact-grave-zone h4{
    white-space:nowrap!important;
    margin-right:auto!important;
  }
  body.in-game .compact-grave-zone .grave-head-actions{
    display:flex!important;
    gap:1px!important;
  }
  body.in-game .compact-grave-zone .grave-actions{
    display:none!important;
  }
  body.in-game .grave-pile-wrap{
    justify-content:center!important;
    height:68px!important;
  }
  body.in-game .grave-pile{
    width:58px!important;
    height:66px!important;
  }
  body.in-game .grave-pile .mini-slot{
    width:56px!important;
    height:64px!important;
  }
  body.in-game .grave-pile .mini-card{
    width:52px!important;
    height:60px!important;
    font-size:7px!important;
  }
  body.in-game .grave-stack-shadow{
    width:52px!important;
    height:60px!important;
  }

  /* Hand is now the most readable zone on the board. */
  body.in-game .hand-zone{
    height:154px!important;
    min-height:154px!important;
    padding-bottom:2px!important;
  }
  body.in-game .hand-zone .zone-card-strip{
    height:130px!important;
    min-height:130px!important;
    align-items:flex-start!important;
  }
  body.in-game .hand-zone .mini-slot{
    width:104px!important;
    height:126px!important;
    margin-right:6px!important;
  }
  body.in-game .hand-zone .mini-card{
    width:96px!important;
    height:118px!important;
    font-size:11px!important;
    line-height:1.15!important;
    padding:5px!important;
  }
  body.in-game .hand-zone .mini-card small{
    font-size:8px!important;
  }

  /* Keep normal zones smaller than hand so the full table still fits. */
  body.in-game .battle-zone-full .mini-slot,
  body.in-game .mana-zone .mini-slot,
  body.in-game .shield-zone .mini-slot{
    width:66px!important;
    height:76px!important;
  }
  body.in-game .battle-zone-full .mini-card,
  body.in-game .mana-zone .mini-card,
  body.in-game .shield-zone .mini-card{
    width:60px!important;
    height:70px!important;
  }
}

/* On narrower desktop windows, keep the same concept without overflowing. */
@media(min-width:761px) and (max-width:1250px){
  body.in-game .middle-zone-row{
    grid-template-columns:minmax(280px,1fr) 72px 86px minmax(80px,.3fr)!important;
  }
  body.in-game .opponent-middle-row{
    grid-template-columns:minmax(80px,.3fr) 86px 72px minmax(280px,1fr)!important;
  }
}

/* ===== DMSIM v7.1.7 =====
   Compact opponent hand + denser board + readable battle power
*/

/* Remove excess vertical whitespace without making empty zones collapse. */
@media(min-width:761px){
  body.in-game .board-scroll{
    gap:2px!important;
    padding-top:0!important;
    padding-bottom:0!important;
  }
  body.in-game .player-side{
    gap:1px!important;
    padding-top:1px!important;
    padding-bottom:1px!important;
  }

  /* Self: keep the large readable hand from v7.1.6. */
  body.in-game .my-side{
    grid-template-rows:18px minmax(88px,1.15fr) 92px 70px 154px!important;
  }

  /*
    Opponent: hand is deliberately smaller.
    This matters most in solo mode, where opponent hand is face-up.
  */
  body.in-game .opponent-side{
    grid-template-rows:18px 104px 70px 92px minmax(88px,1.15fr)!important;
  }

  body.in-game .opponent-side .hand-zone{
    height:104px!important;
    min-height:104px!important;
  }
  body.in-game .opponent-side .hand-zone .zone-card-strip{
    height:82px!important;
    min-height:82px!important;
  }
  body.in-game .opponent-side .hand-zone .mini-slot{
    width:70px!important;
    height:80px!important;
    margin-right:4px!important;
  }
  body.in-game .opponent-side .hand-zone .mini-card{
    width:64px!important;
    height:74px!important;
    padding:3px!important;
    font-size:8px!important;
    line-height:1.08!important;
  }
  body.in-game .opponent-side .hand-zone .mini-card small{
    font-size:6.5px!important;
  }

  /* Reduce dead space in battle while keeping its size fixed when empty. */
  body.in-game .battle-zone-full{
    min-height:88px!important;
    padding:2px!important;
  }
  body.in-game .battle-zone-full .zone-card-strip{
    height:calc(100% - 18px)!important;
    align-items:flex-start!important;
  }

  /*
    Battle cards get a dedicated readable footprint.
    Existing card text already includes Pxxxx/current power; this makes that line visible.
  */
  body.in-game .battle-zone-full .mini-slot{
    width:84px!important;
    height:94px!important;
    margin-right:5px!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:78px!important;
    height:88px!important;
    padding:4px!important;
    font-size:9px!important;
    line-height:1.08!important;
    overflow:hidden!important;
  }
  body.in-game .battle-zone-full .mini-card small{
    display:block!important;
    font-size:7px!important;
    line-height:1.05!important;
  }

  /* Make the bottom/status text inside cards visible instead of clipped. */
  body.in-game .battle-zone-full .mini-card .power,
  body.in-game .battle-zone-full .mini-card [class*="power"]{
    display:block!important;
    visibility:visible!important;
    opacity:1!important;
  }

  /* Keep middle/mana compact to donate height to battle + own hand. */
  body.in-game .middle-zone-row,
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    height:92px!important;
    min-height:92px!important;
  }
  body.in-game .mana-zone{
    height:70px!important;
    min-height:70px!important;
  }

  body.in-game .side-head{
    height:18px!important;
    min-height:18px!important;
    line-height:18px!important;
  }
  body.in-game .side-head .counters{
    line-height:16px!important;
  }
}

/* Solo mode: revealed opponent hand should stay compact on phones too. */
@media(max-width:760px){
  body.in-game .opponent-side .hand-zone .mini-slot{
    width:44px!important;
    height:54px!important;
    margin-right:2px!important;
  }
  body.in-game .opponent-side .hand-zone .mini-card{
    width:40px!important;
    height:50px!important;
    font-size:6.5px!important;
    padding:2px!important;
  }

  /* Battle cards get a little more room than mana/shield cards. */
  body.in-game .battle-zone-full .mini-slot{
    width:48px!important;
    height:58px!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:44px!important;
    height:54px!important;
    font-size:6.5px!important;
    padding:2px!important;
  }
  body.in-game .battle-zone-full .mini-card small{
    display:block!important;
    font-size:5.5px!important;
  }
}

/* ===== DMSIM v7.1.8 ===== */

/* Battle-zone tap state:
   the card still rotates, but the SLOT also shows a fixed badge/outline,
   so tapped vs untapped is unmistakable even on small screens. */
body.in-game .battle-zone-full .mini-slot{
  position:relative!important;
}
body.in-game .battle-zone-full .mini-slot.tap-slot{
  outline:2px solid #d99a3a!important;
  outline-offset:-1px!important;
  border-radius:7px;
  background:#4a331622;
}
body.in-game .battle-zone-full .mini-slot.tap-slot::after{
  content:"TAP";
  position:absolute;
  right:1px;
  top:1px;
  z-index:20;
  padding:1px 4px;
  border-radius:999px;
  background:#9a611d;
  border:1px solid #e1ab57;
  color:#fff;
  font-size:8px;
  font-weight:800;
  line-height:1.2;
  pointer-events:none;
  transform:none!important;
}
body.in-game .battle-zone-full .mini-slot:not(.tap-slot)::before{
  content:"";
  position:absolute;
  left:2px;
  top:2px;
  bottom:2px;
  width:2px;
  border-radius:2px;
  background:#4f8158;
  opacity:.7;
  z-index:10;
  pointer-events:none;
}

/* Smartphone board corrections */
@media(max-width:760px){

  /* Grave keeps the same one-card-footprint idea as PC. */
  body.in-game .middle-zone-row,
  body.in-game .opponent-middle-row{
    grid-template-columns:minmax(0,1fr) 46px 54px!important;
    gap:2px!important;
  }

  body.in-game .compact-grave-zone{
    width:54px!important;
    min-width:54px!important;
    max-width:54px!important;
    padding:1px!important;
    overflow:hidden!important;
  }
  body.in-game .compact-grave-zone .zone-title-row{
    display:flex!important;
    flex-wrap:nowrap!important;
    gap:0!important;
    overflow:hidden!important;
  }
  body.in-game .compact-grave-zone h4{
    font-size:6px!important;
    margin:0!important;
  }
  body.in-game .compact-grave-zone .grave-head-actions{
    margin-left:auto!important;
  }
  body.in-game .compact-grave-zone .grave-list-btn{
    font-size:5px!important;
    padding:1px 2px!important;
  }
  body.in-game .compact-grave-zone .grave-actions{
    display:none!important;
  }
  body.in-game .grave-pile-wrap{
    height:calc(100% - 12px)!important;
  }
  body.in-game .grave-pile{
    width:39px!important;
    height:47px!important;
  }
  body.in-game .grave-pile .mini-slot{
    width:38px!important;
    height:46px!important;
  }
  body.in-game .grave-pile .mini-card{
    width:34px!important;
    height:42px!important;
    padding:1px!important;
    font-size:5.5px!important;
  }
  body.in-game .grave-stack-shadow{
    width:34px!important;
    height:42px!important;
  }

  /* Shield zone gets the remaining width and scrolls horizontally.
     Cards are sized explicitly so all five are actually visible/scrollable. */
  body.in-game .shield-zone{
    min-width:0!important;
    width:100%!important;
    height:100%!important;
    overflow:hidden!important;
    padding:1px!important;
  }
  body.in-game .shield-zone .zone-card-strip{
    display:flex!important;
    flex-wrap:nowrap!important;
    align-items:flex-start!important;
    gap:2px!important;
    width:auto!important;
    min-width:100%!important;
    height:calc(100% - 12px)!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-x;
  }
  body.in-game .shield-zone .mini-slot{
    flex:0 0 42px!important;
    width:42px!important;
    height:52px!important;
    margin:0!important;
  }
  body.in-game .shield-zone .mini-card{
    width:38px!important;
    height:48px!important;
    padding:1px!important;
    font-size:5.5px!important;
  }

  /* Deck stays narrow, leaving maximum width to shields. */
  body.in-game .middle-zone-row>.deck-slot{
    width:46px!important;
    min-width:46px!important;
    max-width:46px!important;
  }
  body.in-game .deck-slot{
    width:46px!important;
    min-width:46px!important;
  }
  body.in-game .deck-card-back{
    width:26px!important;
    height:34px!important;
  }

  /* TAP badge stays legible without covering the card. */
  body.in-game .battle-zone-full .mini-slot.tap-slot::after{
    font-size:6px;
    padding:1px 3px;
  }
}

/* ===== DMSIM v7.1.9 =====
   Make tapped/untapped state obvious by orientation, not color.
*/

/* Remove v7.1.8 visual-color helpers from practical display. */
body.in-game .battle-zone-full .mini-slot.tap-slot{
  outline:none!important;
  background:transparent!important;
}
body.in-game .battle-zone-full .mini-slot.tap-slot::after,
body.in-game .battle-zone-full .mini-slot:not(.tap-slot)::before{
  content:none!important;
  display:none!important;
}

/*
  Tapped = clearly horizontal.
  Untapped = clearly vertical.
  Battle slots are made large enough that rotation is never clipped.
*/
body.in-game .battle-zone-full .mini-card.tap{
  transform:rotate(90deg) scale(.95)!important;
}
body.in-game .battle-zone-full .mini-card:not(.tap){
  transform:rotate(0deg) scale(1)!important;
}

/* PC: dedicate substantially more vertical room to battle zones. */
@media(min-width:761px){
  body.in-game .my-side{
    grid-template-rows:18px 132px 88px 64px 146px!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:18px 94px 64px 88px 132px!important;
  }

  body.in-game .battle-zone-full{
    height:132px!important;
    min-height:132px!important;
    padding:2px 4px!important;
    overflow:hidden!important;
  }
  body.in-game .battle-zone-full .zone-card-strip{
    height:110px!important;
    min-height:110px!important;
    display:flex!important;
    align-items:center!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding:0 4px!important;
  }
  body.in-game .battle-zone-full .mini-slot{
    flex:0 0 112px!important;
    width:112px!important;
    height:108px!important;
    margin-right:8px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:visible!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:76px!important;
    height:96px!important;
    font-size:9.5px!important;
    padding:4px!important;
    transform-origin:center center!important;
    overflow:hidden!important;
  }
  body.in-game .battle-zone-full .mini-card small{
    font-size:7px!important;
  }

  /* Recover the added battle height from less-important rows. */
  body.in-game .middle-zone-row,
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    height:88px!important;
    min-height:88px!important;
  }
  body.in-game .mana-zone{
    height:64px!important;
    min-height:64px!important;
  }
  body.in-game .my-side .hand-zone{
    height:146px!important;
    min-height:146px!important;
  }
  body.in-game .my-side .hand-zone .zone-card-strip{
    height:122px!important;
  }
  body.in-game .opponent-side .hand-zone{
    height:94px!important;
    min-height:94px!important;
  }
}

/* Smartphone: make the orientation readable there too. */
@media(max-width:760px){
  body.in-game .my-side{
    grid-template-rows:auto 1.55fr .78fr .62fr 1.2fr!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:auto 1fr .62fr .78fr 1.55fr!important;
  }

  body.in-game .battle-zone-full{
    min-height:72px!important;
  }
  body.in-game .battle-zone-full .zone-card-strip{
    min-height:60px!important;
    display:flex!important;
    align-items:center!important;
  }
  body.in-game .battle-zone-full .mini-slot{
    flex:0 0 66px!important;
    width:66px!important;
    height:62px!important;
    overflow:visible!important;
    align-items:center!important;
    justify-content:center!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:42px!important;
    height:54px!important;
    transform-origin:center center!important;
  }
  body.in-game .battle-zone-full .mini-card.tap{
    transform:rotate(90deg) scale(.92)!important;
  }
}

/* ===== DMSIM v7.2.0 =====
   Thin top bar + readable mana + readable hand
   Battle zone settings from v7.1.9 are intentionally preserved.
*/

@media(min-width:761px){

  /* ---------------------------------
     1) Top bar: remove wasted height
     --------------------------------- */
  body.in-game .game-topbar{
    min-height:30px!important;
    height:30px!important;
    padding:2px 5px!important;
    gap:4px!important;
    align-items:center!important;
    box-sizing:border-box!important;
  }
  body.in-game .game-topbar>b{
    font-size:12px!important;
    line-height:26px!important;
    margin:0!important;
    white-space:nowrap!important;
  }
  body.in-game .game-topbar .actions{
    gap:3px!important;
    align-items:center!important;
    flex-wrap:nowrap!important;
    margin-left:auto!important;
  }
  body.in-game .game-topbar .actions button{
    min-height:24px!important;
    height:24px!important;
    padding:2px 8px!important;
    font-size:10px!important;
    line-height:18px!important;
    margin:0!important;
  }
  body.in-game .game-topbar .actions>span{
    min-height:22px!important;
    height:22px!important;
    padding:1px 7px!important;
    font-size:10px!important;
    line-height:18px!important;
    margin:0!important;
  }

  /* Board should immediately follow the thin header. */
  body.in-game .game-main{
    grid-template-rows:30px minmax(0,1fr)!important;
    min-height:0!important;
  }
  body.in-game .board-scroll{
    min-height:0!important;
    height:auto!important;
    padding-top:0!important;
    margin-top:0!important;
  }

  /* ---------------------------------
     2) Preserve battle size from 7.1.9
     --------------------------------- */
  body.in-game .battle-zone-full{
    height:132px!important;
    min-height:132px!important;
  }
  body.in-game .battle-zone-full .zone-card-strip{
    height:110px!important;
    min-height:110px!important;
  }

  /* ---------------------------------
     3) Mana: enough height for 90° tap
     --------------------------------- */
  body.in-game .mana-zone{
    height:96px!important;
    min-height:96px!important;
    padding:2px!important;
  }
  body.in-game .mana-zone .zone-card-strip{
    height:74px!important;
    min-height:74px!important;
    display:flex!important;
    align-items:center!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
  }
  body.in-game .mana-zone .mini-slot{
    flex:0 0 76px!important;
    width:76px!important;
    height:70px!important;
    margin-right:5px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:visible!important;
  }
  body.in-game .mana-zone .mini-card{
    width:50px!important;
    height:64px!important;
    font-size:8px!important;
    padding:3px!important;
    transform-origin:center center!important;
  }
  body.in-game .mana-zone .mini-card.tap{
    transform:rotate(90deg) scale(.92)!important;
  }
  body.in-game .mana-zone .mini-card:not(.tap){
    transform:rotate(0deg) scale(1)!important;
  }
  body.in-game .mana-zone .mini-card small{
    font-size:6.5px!important;
  }

  /* ---------------------------------
     4) Hand: significantly more readable
     --------------------------------- */
  body.in-game .my-side .hand-zone{
    height:168px!important;
    min-height:168px!important;
  }
  body.in-game .my-side .hand-zone .zone-card-strip{
    height:144px!important;
    min-height:144px!important;
    display:flex!important;
    align-items:flex-start!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
  }
  body.in-game .my-side .hand-zone .mini-slot{
    flex:0 0 116px!important;
    width:116px!important;
    height:140px!important;
    margin-right:7px!important;
  }
  body.in-game .my-side .hand-zone .mini-card{
    width:106px!important;
    height:132px!important;
    font-size:11px!important;
    line-height:1.15!important;
    padding:5px!important;
  }
  body.in-game .my-side .hand-zone .mini-card small{
    font-size:8px!important;
  }

  /* Opponent hand stays compact from 7.1.9. */
  body.in-game .opponent-side .hand-zone{
    height:88px!important;
    min-height:88px!important;
  }
  body.in-game .opponent-side .hand-zone .zone-card-strip{
    height:66px!important;
    min-height:66px!important;
  }
  body.in-game .opponent-side .hand-zone .mini-slot{
    width:62px!important;
    height:64px!important;
  }
  body.in-game .opponent-side .hand-zone .mini-card{
    width:56px!important;
    height:58px!important;
    font-size:7px!important;
  }

  /* ---------------------------------
     5) Rebalance fixed rows
     --------------------------------- */
  body.in-game .my-side{
    grid-template-rows:18px 132px 84px 96px 168px!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:18px 88px 96px 84px 132px!important;
  }

  body.in-game .middle-zone-row,
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    height:84px!important;
    min-height:84px!important;
  }

  /* Avoid hidden padding eating the gained height. */
  body.in-game .zone h4{
    margin-top:0!important;
    margin-bottom:2px!important;
    line-height:14px!important;
  }
}

/* Smartphone: mana must also show tapped orientation clearly. */
@media(max-width:760px){
  body.in-game .mana-zone{
    min-height:64px!important;
  }
  body.in-game .mana-zone .zone-card-strip{
    min-height:52px!important;
    display:flex!important;
    align-items:center!important;
  }
  body.in-game .mana-zone .mini-slot{
    flex:0 0 58px!important;
    width:58px!important;
    height:54px!important;
    overflow:visible!important;
    align-items:center!important;
    justify-content:center!important;
  }
  body.in-game .mana-zone .mini-card{
    width:36px!important;
    height:48px!important;
    transform-origin:center center!important;
  }
  body.in-game .mana-zone .mini-card.tap{
    transform:rotate(90deg) scale(.9)!important;
  }

  /* Own hand: keep it as the most readable mobile zone. */
  body.in-game .my-side .hand-zone .mini-slot{
    width:58px!important;
    height:70px!important;
  }
  body.in-game .my-side .hand-zone .mini-card{
    width:52px!important;
    height:66px!important;
    font-size:7.5px!important;
  }
}

/* ===== DMSIM v7.2.1 ===== */

/* Main nav is moved to the bottom-left sidebar during games. */
body.in-game #app>nav{display:none!important}

.sidebar-game-footer{
  margin-top:auto;
  padding-top:8px;
  border-top:1px solid #2b3948;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.sidebar-tap-actions,
.sidebar-nav-buttons{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:5px;
}
.sidebar-game-footer button{
  width:100%;
  min-height:30px;
  font-size:11px;
  padding:5px 6px;
}

/* Sidebar must actually pin the footer to the bottom. */
body.in-game .sidebar{
  display:flex!important;
  flex-direction:column!important;
  min-height:0!important;
}

/* -------------------------------------------------
   Battle zone:
   smaller than v7.2.0 but still enough room to clearly rotate.
   ------------------------------------------------- */
@media(min-width:761px){
  body.in-game .battle-zone-full{
    height:118px!important;
    min-height:118px!important;
  }
  body.in-game .battle-zone-full .zone-card-strip{
    height:96px!important;
    min-height:96px!important;
    display:flex!important;
    align-items:center!important;
  }
  body.in-game .battle-zone-full .mini-slot{
    flex:0 0 96px!important;
    width:96px!important;
    height:94px!important;
    margin-right:6px!important;
    overflow:visible!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:68px!important;
    height:86px!important;
    padding:4px!important;
    font-size:9px!important;
    transform-origin:center center!important;
  }
  body.in-game .battle-zone-full .mini-card.tap{
    transform:rotate(90deg) scale(.94)!important;
  }
  body.in-game .battle-zone-full .mini-card:not(.tap){
    transform:rotate(0deg) scale(1)!important;
  }

  /* -------------------------------------------------
     Hand:
     prioritize readable card names over showing more cards at once.
     ------------------------------------------------- */
  body.in-game .my-side .hand-zone{
    height:176px!important;
    min-height:176px!important;
  }
  body.in-game .my-side .hand-zone .zone-card-strip{
    height:150px!important;
    min-height:150px!important;
    display:flex!important;
    align-items:flex-start!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding-top:2px!important;
  }
  body.in-game .my-side .hand-zone .mini-slot{
    flex:0 0 132px!important;
    width:132px!important;
    height:146px!important;
    margin-right:8px!important;
  }
  body.in-game .my-side .hand-zone .mini-card{
    width:120px!important;
    height:138px!important;
    padding:6px!important;
    font-size:12px!important;
    line-height:1.18!important;
    white-space:normal!important;
  }
  body.in-game .my-side .hand-zone .mini-card b{
    display:block!important;
    white-space:normal!important;
    overflow:visible!important;
    text-overflow:clip!important;
    line-height:1.15!important;
    max-height:42px!important;
  }
  body.in-game .my-side .hand-zone .mini-card small{
    font-size:8px!important;
  }

  /* Opponent hand remains compact. */
  body.in-game .opponent-side .hand-zone{
    height:84px!important;
    min-height:84px!important;
  }

  /* Rebalance row heights while keeping one-screen layout. */
  body.in-game .my-side{
    grid-template-rows:18px 118px 80px 90px 176px!important;
  }
  body.in-game .opponent-side{
    grid-template-rows:18px 84px 90px 80px 118px!important;
  }

  body.in-game .mana-zone{
    height:90px!important;
    min-height:90px!important;
  }
  body.in-game .middle-zone-row,
  body.in-game .middle-zone-row>.zone,
  body.in-game .middle-zone-row>.deck-slot{
    height:80px!important;
    min-height:80px!important;
  }
}

/* Smartphone:
   keep hand names readable with horizontal scrolling. */
@media(max-width:760px){
  body.in-game .my-side .hand-zone .mini-slot{
    flex:0 0 68px!important;
    width:68px!important;
    height:80px!important;
  }
  body.in-game .my-side .hand-zone .mini-card{
    width:62px!important;
    height:76px!important;
    font-size:8px!important;
    white-space:normal!important;
  }
  body.in-game .my-side .hand-zone .mini-card b{
    white-space:normal!important;
    overflow:visible!important;
    text-overflow:clip!important;
  }

  body.in-game .battle-zone-full .mini-slot{
    flex:0 0 62px!important;
    width:62px!important;
    height:60px!important;
  }
  body.in-game .battle-zone-full .mini-card{
    width:40px!important;
    height:52px!important;
  }
  body.in-game .battle-zone-full .mini-card.tap{
    transform:rotate(90deg) scale(.9)!important;
  }

  .sidebar-game-footer{
    display:none!important;
  }
}

/* ===== DMSIM v7.2.2 =====
   Mobile-only: opponent shield/deck/grave order matches self.
*/
@media(max-width:760px){
  body.in-game .middle-zone-row,
  body.in-game .opponent-middle-row{
    grid-template-columns:minmax(0,1fr) 46px 54px!important;
  }

  /* DOM for opponent is grave | deck | shield.
     Reorder it visually to shield | deck | grave on mobile. */
  body.in-game .opponent-middle-row .shield-zone{
    grid-column:1!important;
    grid-row:1!important;
  }
  body.in-game .opponent-middle-row .deck-slot{
    grid-column:2!important;
    grid-row:1!important;
  }
  body.in-game .opponent-middle-row .compact-grave-zone{
    grid-column:3!important;
    grid-row:1!important;
  }

  /* Self already uses shield | deck | grave; make placement explicit too. */
  body.in-game .middle-zone-row:not(.opponent-middle-row) .shield-zone{
    grid-column:1!important;
    grid-row:1!important;
  }
  body.in-game .middle-zone-row:not(.opponent-middle-row) .deck-slot{
    grid-column:2!important;
    grid-row:1!important;
  }
  body.in-game .middle-zone-row:not(.opponent-middle-row) .compact-grave-zone{
    grid-column:3!important;
    grid-row:1!important;
  }
}

/* ===== DMSIM v7.2.3 ===== */

/* Left sidebar footer now contains navigation only. */
.sidebar-game-footer .sidebar-tap-actions{display:none!important}

/* Selected-card tap controls in the upper-right toolbar. */
.selected-untap-btn,
.selected-tap-btn{
  white-space:nowrap;
}

/* PC opponent middle row:
   reserve the left spare column, then grave | deck | wide shield.
   This fixes opponent shields being squeezed/overlapped. */
@media(min-width:761px){
  body.in-game .opponent-middle-row .compact-grave-zone{
    grid-column:2!important;
    grid-row:1!important;
  }
  body.in-game .opponent-middle-row .deck-slot{
    grid-column:3!important;
    grid-row:1!important;
  }
  body.in-game .opponent-middle-row .shield-zone{
    grid-column:4!important;
    grid-row:1!important;
    min-width:0!important;
    width:100%!important;
  }

  /* Self stays wide shield | deck | grave | spare. */
  body.in-game .middle-zone-row:not(.opponent-middle-row) .shield-zone{
    grid-column:1!important;
    grid-row:1!important;
  }
  body.in-game .middle-zone-row:not(.opponent-middle-row) .deck-slot{
    grid-column:2!important;
    grid-row:1!important;
  }
  body.in-game .middle-zone-row:not(.opponent-middle-row) .compact-grave-zone{
    grid-column:3!important;
    grid-row:1!important;
  }

  /* Both PC shield zones spread cards horizontally with stable gaps. */
  body.in-game .shield-zone .zone-card-strip{
    display:flex!important;
    flex-wrap:nowrap!important;
    align-items:flex-start!important;
    gap:6px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    white-space:nowrap!important;
    width:auto!important;
    min-width:100%!important;
  }
  body.in-game .shield-zone .mini-slot{
    flex:0 0 66px!important;
    width:66px!important;
    height:76px!important;
    margin:0!important;
    position:relative!important;
    left:auto!important;
    right:auto!important;
    transform:none!important;
  }
  body.in-game .shield-zone .mini-card{
    width:60px!important;
    height:70px!important;
  }
}

/* ===== DMSIM v7.2.5 ===== */
.selected-card-viewer{
  margin-top:8px;
  min-height:120px;
  max-height:230px;
  border:1px solid #2e3c4c;
  border-radius:8px;
  background:#0c131b;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.selected-card-viewer.empty{opacity:.72}
.selected-card-viewer-head{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
  padding:7px 8px;
  border-bottom:1px solid #293644;
  background:#111a24;
  font-size:11px;
}
.selected-card-viewer-head b{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.viewer-hyper{
  flex:0 0 auto;
  font-size:8px;
  padding:2px 5px;
  border:1px solid #526171;
  border-radius:999px;
}
.viewer-hyper.on{font-weight:700}
.selected-card-viewer-meta{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  padding:5px 7px 0;
}
.selected-card-viewer-meta span{
  font-size:8px;
  padding:2px 5px;
  border:1px solid #2d3a49;
  border-radius:999px;
  background:#121a23;
}
.selected-card-viewer-body{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  padding:7px 8px;
  font-size:10px;
  line-height:1.45;
  white-space:normal;
  word-break:break-word;
}
.selected-card-viewer.empty .selected-card-viewer-body{
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:#7f8d9b;
  font-size:9px;
}
.sidebar-game-footer{flex:0 0 auto}
.selection-bar button{white-space:nowrap}
@media(max-width:760px){
  .selected-card-viewer{max-height:180px;min-height:100px}
}

/* ===== DMSIM v7.2.6 ===== */
.attack-response-panel{position:fixed;z-index:14500;right:14px;top:96px;width:min(390px,calc(100vw - 28px));background:#121a24;border:1px solid #53647a;border-radius:10px;padding:10px;box-shadow:0 12px 36px #000a;display:flex;flex-direction:column;gap:8px}
.attack-response-head{display:flex;flex-direction:column;gap:3px}.attack-response-head b{font-size:13px}.attack-response-head span{font-size:10px}.attack-response-body{font-size:10px;line-height:1.45}.attack-response-panel>button{width:100%}
@media(max-width:760px){.attack-response-panel{left:8px;right:8px;top:auto;bottom:92px;width:auto;padding:8px}}

/* ===== DMSIM v7.2.7 response UI ===== */
.attack-response-choice{display:flex;flex-direction:column;gap:2px;font-size:10px}
.response-hand-list{display:flex;gap:5px;overflow-x:auto;overflow-y:hidden;padding:4px 1px 6px;min-height:64px}
.response-hand-card{flex:0 0 104px;min-height:58px;text-align:left;display:flex;flex-direction:column;justify-content:flex-start;gap:3px;padding:6px;border:1px solid #425165;border-radius:7px;background:#111a24}
.response-hand-card b{font-size:9px;white-space:normal;line-height:1.15}.response-hand-card small{font-size:7px;opacity:.75}
.response-hand-card.selected{outline:2px solid currentColor;outline-offset:1px}
.attack-response-actions,.direct-response-actions{display:flex;gap:5px;flex-wrap:wrap}
.attack-response-actions button,.direct-response-actions button{flex:1;min-width:105px}
.direct-float .response-hand-list{max-width:100%;padding-top:2px}
@media(max-width:760px){
  .response-hand-card{flex:0 0 92px;min-height:54px;padding:5px}
  .attack-response-actions button,.direct-response-actions button{min-width:0;font-size:9px;padding:6px 5px}
}

/* ===== DMSIM v7.2.8 ===== */

/* Civilization coloring */
.civ-colored{
  background:var(--civ-bg)!important;
  border-color:var(--civ-border)!important;
}
.card-name-row.civ-colored,.builder-name-row.civ-colored,.deckline.civ-colored{
  border-left:4px solid var(--civ-border)!important;
}

/* Declare / attack target modal */
.declare-overlay{position:fixed;z-index:17000;inset:0;background:#0009;display:flex;align-items:center;justify-content:center;padding:12px}
.declare-modal{width:min(520px,100%);background:#121a24;border:1px solid #46586d;border-radius:11px;padding:12px;box-shadow:0 18px 60px #000c;display:flex;flex-direction:column;gap:9px}
.declare-modal h3{margin:0}.declare-modal label{display:flex;flex-direction:column;gap:4px;font-size:10px}.declare-modal input,.declare-modal select{width:100%;box-sizing:border-box}

/* Match history */
.home-stats{grid-column:1/-1!important}
.history-list{display:flex;flex-direction:column;gap:5px;max-height:250px;overflow:auto}
.history-row{border:1px solid #2b3948;border-radius:7px;padding:7px;background:#0d141c;font-size:10px}
.history-row>div:first-child{display:flex;justify-content:space-between;gap:8px;margin-bottom:3px}.history-row span{color:#8fa0b1;font-size:9px}

@media(max-width:760px){
  .declare-overlay{align-items:flex-end;padding:0}
  .declare-modal{border-radius:14px 14px 0 0;padding-bottom:calc(12px + env(safe-area-inset-bottom))}
}

/* ===== DMSIM v7.2.9 ===== */
.spectator-badge{
  margin-top:8px;
  border:1px solid #52647a;
  border-radius:7px;
  padding:7px;
  text-align:center;
  font-size:10px;
  opacity:.9;
}

/* ===== DMSIM v7.3.0 incoming attack visibility ===== */
.attack-response-panel.attack-response-alert{
  z-index:16050!important;
  box-shadow:0 0 0 2px #8a6b2f,0 18px 55px #000c!important;
}
.attack-response-panel.attack-response-alert .attack-response-head b{
  font-size:12px;
}
@media(max-width:760px){
  .attack-response-panel.attack-response-alert{
    z-index:16050!important;
  }
}

/* ===== DMSIM v7.3.1 mobile attack input fix ===== */
@media(max-width:760px){
  .declare-modal{
    max-height:82dvh;
    overflow:auto;
  }
  .declare-modal input{
    font-size:16px; /* iPhone Safari の入力時ズームを防止 */
  }
  .declare-modal>button:last-child{
    position:sticky;
    bottom:0;
  }
}

/* ===== DMSIM v7.3.2 attack UI ===== */
.attack-target-form{display:flex;flex-direction:column;gap:6px}
.attack-target-input-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:stretch}
.attack-target-input-row input{min-width:0}
.attack-submit-btn{min-width:96px;white-space:nowrap}
.attack-target-candidates{display:flex;flex-direction:column;gap:7px}
.attack-target-option-list{display:flex;flex-wrap:wrap;gap:6px;max-height:180px;overflow:auto}
.attack-target-option{font-size:11px;text-align:left}
.attack-target-option.selected{outline:2px solid currentColor}

@media(max-width:760px){
  .attack-declare-overlay{
    align-items:flex-start!important;
    padding:62px 8px 96px!important;
    overflow:auto;
  }
  .attack-declare-modal{
    width:100%!important;
    max-height:none!important;
    border-radius:12px!important;
    padding:12px!important;
    overflow:visible!important;
  }
  .attack-declare-head{position:relative}
  .attack-target-input-row{
    grid-template-columns:minmax(0,1fr) 104px;
    gap:6px;
  }
  .attack-target-input-row input{
    font-size:16px;
    height:46px;
  }
  .attack-submit-btn{
    min-width:0;
    height:46px;
    position:static!important;
  }
  .attack-target-candidates{
    margin-top:2px;
  }
  .attack-target-option-list{
    display:grid;
    grid-template-columns:1fr;
    gap:5px;
    max-height:210px;
    overflow:auto;
  }
  .attack-target-option{
    width:100%;
    min-height:42px;
    text-align:left;
    justify-content:flex-start;
  }
}

/* ===== DMSIM v7.3.3 multi attack targets ===== */
.attack-target-option.selected{
  border-width:2px!important;
  font-weight:700;
}
.attack-target-option-list .attack-target-option{
  transition:transform .08s ease;
}
@media(max-width:760px){
  .attack-target-option.selected{transform:scale(.99)}
}

/* ===== DMSIM v7.3.4 ===== */
.attack-effect-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.attack-effect-resolving{
  position:fixed;z-index:15500;left:50%;top:74px;transform:translateX(-50%);
  width:min(720px,calc(100% - 20px));background:#111a24;border:1px solid #596b80;
  border-radius:10px;padding:9px 11px;box-shadow:0 12px 40px #000a;
  display:flex;align-items:center;justify-content:space-between;gap:10px
}
.attack-effect-resolving>div:first-child{display:flex;flex-direction:column;gap:2px}
.attack-effect-resolving span{font-size:10px;opacity:.78}
.seal-badge{
  position:absolute;right:3px;bottom:3px;background:#181a1e;border:1px solid #858b93;
  border-radius:5px;padding:2px 4px;font-size:8px;z-index:4
}
.shield-peek-card{border:2px solid var(--civ-border,#596b80);border-radius:9px;padding:12px;background:var(--civ-bg,#17212d)}
.shield-peek-card b{display:block;font-size:14px;margin-bottom:4px}.shield-peek-card p{white-space:pre-wrap;font-size:11px}
@media(max-width:760px){
  .attack-effect-actions{grid-template-columns:1fr}
  .attack-effect-resolving{top:58px;align-items:stretch;flex-direction:column}
  .attack-effect-resolving .row{display:grid;grid-template-columns:1fr 1fr}
}

/* ===== DMSIM v7.4.0 room lobby ===== */
.room-create-panel{border:1px solid #334355;border-radius:12px;padding:12px;margin-bottom:14px;background:#101822}
.room-create-panel h3{margin:0 0 8px}
.room-create-grid{display:grid;grid-template-columns:minmax(160px,1fr) minmax(160px,1fr) auto;gap:8px}
.room-create-grid input{min-width:0}
.room-list-title{margin:14px 0 8px}
.lobby-room-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px;border:1px solid #2c3948;border-radius:10px;margin:6px 0}
.lobby-room-row>div:first-child{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}
.lobby-room-row span,.lobby-room-row small{opacity:.75}
.room-actions{display:flex;gap:6px;flex-shrink:0}
.room-lobby-card{border:1px solid #53677d;border-radius:14px;padding:14px;margin:12px 0;background:#111b26}
.room-lobby-head h3{margin:0}.room-lobby-head span{font-size:10px;opacity:.6}
.lobby-players{display:grid;grid-template-columns:1fr auto 1fr;align-items:stretch;gap:10px;margin:14px 0}
.lobby-player{border:1px solid #314255;border-radius:11px;padding:12px;display:flex;flex-direction:column;gap:4px;min-width:0}
.lobby-player.me{border-color:#71849a}
.lobby-player small{opacity:.65}.lobby-player span{font-size:11px;opacity:.78;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lobby-vs{align-self:center;font-weight:800;opacity:.6}
.lobby-settings{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.lobby-settings label{display:flex;flex-direction:column;gap:5px}.lobby-settings label>span{font-size:11px;opacity:.75}
.lobby-setting-readonly{min-height:40px;display:flex;align-items:center;padding:0 10px;border:1px solid #35485c;border-radius:7px}
.lobby-status{margin:12px 0;padding:8px 10px;background:#0d151e;border-radius:8px;font-size:11px}
.lobby-actions{display:flex;gap:8px;flex-wrap:wrap}
button.disabled,button:disabled{opacity:.42;cursor:not-allowed}
@media(max-width:760px){
  .room-create-grid{grid-template-columns:1fr}
  .lobby-room-row{align-items:flex-start;flex-direction:column}
  .room-actions{width:100%}.room-actions button{flex:1}
  .lobby-players{grid-template-columns:1fr}.lobby-vs{text-align:center}
  .lobby-settings{grid-template-columns:1fr}
  .room-lobby-head{align-items:flex-start}
  .lobby-actions{display:grid;grid-template-columns:1fr 1fr}
}

/* ===== DMSIM v7.4.1 attack response safety ===== */
.attack-response-actions{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:7px;
}
.direct-footer-two{
  display:grid!important;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
@media(max-width:760px){
  .attack-response-actions{grid-template-columns:1fr}
  .direct-footer-two{grid-template-columns:1fr}
}

/* ===== DMSIM v7.4.3 locked-room permissions ===== */
.admin-user-row,.admin-room-row{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 0;border-bottom:1px solid #293747}
.admin-user-row>div:first-child{display:flex;flex-direction:column;min-width:0}
.admin-user-row small{opacity:.65}
.admin-user-actions{display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end}
@media(max-width:760px){
  .admin-user-row,.admin-room-row{align-items:flex-start;flex-direction:column}
  .admin-user-actions{width:100%;display:grid;grid-template-columns:1fr 1fr}
}

/* ===== DMSIM v7.5.0 mobile attack-effect popup position ===== */
@media(max-width:760px){
  .attack-effect-overlay{
    align-items:center!important;
    justify-content:center!important;
    padding:12px!important;
  }
  .attack-effect-modal{
    width:min(94vw,420px)!important;
    max-height:78dvh!important;
    overflow:auto!important;
    margin:0!important;
    position:relative!important;
    top:auto!important;
    bottom:auto!important;
    left:auto!important;
    right:auto!important;
    transform:none!important;
  }
}

/* ===== DMSIM v7.5.1 shield controls ===== */
.shield-no-badge{
  position:absolute;
  left:4px;
  top:4px;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-style:normal;
  font-size:11px;
  font-weight:800;
  line-height:1;
  background:rgba(0,0,0,.78);
  border:1px solid rgba(255,255,255,.65);
  color:#fff;
  z-index:5;
}

/* ===== DMSIM v7.5.2 invite codes ===== */
#inviteCode{text-transform:uppercase;letter-spacing:.05em}
.invite-admin-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:8px 0}
.invite-admin-head p{margin:3px 0 0}
.invite-list{display:flex;flex-direction:column;gap:6px;margin-top:8px}
.invite-row{display:flex;align-items:center;justify-content:space-between;gap:10px;border:1px solid #2d3a49;border-radius:9px;padding:8px 10px;opacity:.7}
.invite-row.active{opacity:1;border-color:#4b6178}
.invite-row>div:first-child{display:flex;flex-direction:column;gap:3px;min-width:0}
.invite-row code{font-size:14px;font-weight:800;letter-spacing:.06em;user-select:all}
.invite-row small{opacity:.65}
.invite-actions{display:flex;gap:6px;flex-shrink:0}
@media(max-width:760px){
  .invite-admin-head,.invite-row{align-items:flex-start;flex-direction:column}
  .invite-admin-head button,.invite-actions{width:100%}
  .invite-actions{display:grid;grid-template-columns:1fr 1fr}
}


/* ===== DMSIM v7.5.4 ===== */
.deck-code-output{margin-top:8px;border:1px solid #34465a;border-radius:8px;padding:8px;background:#0e1620}.deck-code-output textarea{width:100%;box-sizing:border-box;margin-top:6px;word-break:break-all}
.attack-chain-modal{width:min(680px,100%);max-height:min(86vh,760px);overflow:auto}.attack-declare-kind-row{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}.attack-declare-composer{border:1px solid #35475b;border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:7px}.attack-declare-composer:empty{display:none}.attack-declare-compose-head{display:flex;justify-content:space-between;gap:8px}.attack-declare-history{display:flex;flex-direction:column;gap:5px}.attack-declare-item{display:flex;align-items:center;justify-content:space-between;gap:8px;border:1px solid #34465a;border-radius:7px;padding:6px 8px}.attack-declare-item span{font-size:10px}.attack-declare-hand-card{flex:0 0 104px}
@media(max-width:760px){.attack-declare-kind-row{grid-template-columns:1fr 1fr}.attack-chain-modal{max-height:88vh}.attack-declare-compose-head{flex-direction:column}.deck-code-output textarea{font-size:9px}}

/* DMSIM v7.6.0 usability pass */
.mini-card.selected{outline:4px solid #fff!important;outline-offset:2px!important;box-shadow:0 0 0 3px #111,0 0 18px 7px rgba(255,255,255,.78)!important;transform:translateY(-5px) scale(1.035);z-index:12;overflow:visible}
.mini-card.selected.tap{transform:rotate(90deg) translateX(-5px) scale(.86)}
.selected-check{position:absolute;top:-8px;right:-8px;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:#fff;color:#0b1118;border:3px solid #0b1118;font-size:14px;font-weight:1000;z-index:20;box-shadow:0 2px 8px #0009}
.turn-indicator{font-size:12px;padding:7px 11px;border-width:2px!important;box-shadow:0 0 0 1px #0006;letter-spacing:.02em}
.turn-indicator.my-turn{background:#174b2a;border-color:#72e496!important;box-shadow:0 0 14px rgba(114,228,150,.25)}
.turn-indicator.opp-turn{background:#4b2020;border-color:#d77a7a!important}
.actions .action-primary{font-weight:750;border-width:1px}.actions .action-secondary{opacity:.78}
.end-turn-btn{font-weight:900!important;font-size:12px!important;padding:8px 12px!important;border:2px solid transparent!important}
.end-turn-btn.ready,.mobile-end-turn.ready{box-shadow:0 0 14px rgba(240,198,116,.38);border-color:#f0c674!important}
.end-turn-btn.waiting,.mobile-end-turn.waiting{opacity:.4;cursor:not-allowed;filter:saturate(.4)}
.danger-action{background:#4b2020!important;border-color:#9a4b4b!important;color:#ffdede!important;margin-left:5px}
.game-toast{position:fixed;left:50%;top:72px;transform:translate(-50%,-10px);z-index:99999;background:#101923;color:#fff;border:1px solid #6f8298;border-radius:999px;padding:9px 16px;font-weight:800;box-shadow:0 8px 30px #0009;opacity:0;transition:.18s ease;pointer-events:none}.game-toast.show{opacity:1;transform:translate(-50%,0)}
.attack-effect-dock{flex:0 0 auto;padding:7px 9px;background:#111923;border-bottom:2px solid #596f88;max-height:38vh;overflow:auto}.attack-effect-panel{width:100%;max-width:none!important;margin:0!important;background:#17212d;border:1px solid #40546a;border-radius:9px;padding:9px;box-shadow:0 4px 14px #0006}.attack-effect-panel .attack-declare-history{max-height:92px;overflow:auto}
.opponent-card-detail{display:flex;flex-direction:column;gap:7px;max-width:360px}.opponent-card-detail>b{font-size:14px}.opponent-card-text{max-height:180px;overflow:auto;white-space:normal;line-height:1.55;padding:8px;background:#0d141c;border:1px solid #344253;border-radius:6px}.opponent-card-actions{display:flex;flex-direction:column;gap:4px;margin-top:8px;padding-top:7px;border-top:1px solid #354150}.opponent-card-actions small{opacity:.7}
@media(max-width:760px){.selected-check{width:19px;height:19px;font-size:12px}.turn-indicator{font-size:10px!important;padding:5px 7px!important}.attack-effect-dock{max-height:44vh;padding:5px}.game-toast{top:58px}.end-turn-btn{font-size:10px!important;padding:6px 8px!important}}

/* ===== DMSIM v7.6.1 attack flow / scroll / responsive selection bar ===== */
.selection-bar{
  display:flex!important;
  flex-wrap:wrap!important;
  align-items:center!important;
  gap:6px!important;
  max-width:100%!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  white-space:normal!important;
  box-sizing:border-box!important;
}
.selection-bar>b{flex:0 0 auto}.selection-bar button{flex:0 0 auto;max-width:100%}
.attack-choice-list{display:flex;flex-direction:column;gap:6px;margin:7px 0}
.attack-choice-row{display:grid;grid-template-columns:minmax(90px,130px) auto minmax(110px,1fr);gap:8px;align-items:center;border:1px solid #34465a;border-radius:8px;padding:7px 8px;background:#101923}
.attack-choice-buttons{display:flex;flex-wrap:wrap;gap:5px}.attack-choice-buttons button{padding:5px 9px}.selected-no{background:#3a4654!important;border-color:#8492a3!important;font-weight:800}
.attack-final-panel{position:fixed;z-index:16100;left:50%;top:82px;transform:translateX(-50%);width:min(620px,calc(100vw - 24px));background:#121a24;border:2px solid #d0a75e;border-radius:11px;padding:11px;box-shadow:0 16px 48px #000c;display:flex;flex-direction:column;gap:8px}.attack-final-panel>div:first-child{display:flex;flex-direction:column;gap:3px}.attack-final-panel>div:first-child span{font-size:10px}.attack-final-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.selected-card-viewer-body{overscroll-behavior:contain;scrollbar-gutter:stable;touch-action:pan-y;-webkit-overflow-scrolling:touch}
@media(max-width:1100px) and (min-width:761px){.selection-bar{max-height:132px!important;padding:6px 8px!important}.selection-bar button{font-size:10px!important;padding:6px 8px!important}}
@media(max-width:760px){.attack-choice-row{grid-template-columns:1fr}.attack-choice-buttons{width:100%}.attack-choice-buttons button{flex:1 1 auto}.attack-final-panel{top:auto;bottom:86px}.attack-final-actions{grid-template-columns:1fr}.selection-bar{max-height:126px!important}}


/* ===== DMSIM v7.6.2 generic declarations / mobile scroll / card count ===== */
.card-total-badge{font-size:12px;padding:6px 10px;border-radius:999px;background:#17212d;border:1px solid #40546a;color:#dbe7f3}
.attack-public-zone{margin:7px 0;padding:8px;border:1px solid #52677e;border-radius:9px;background:#0e1721;display:flex;flex-direction:column;gap:6px}.attack-public-group{display:flex;flex-direction:column;gap:4px}.attack-public-group>small{opacity:.72}.attack-public-cards{display:flex;gap:6px;flex-wrap:wrap}.attack-public-card{display:flex;flex-direction:column;gap:2px;min-width:100px;max-width:190px;padding:6px 8px;border-radius:7px;border:1px solid #4a6076;background:#17212d}.attack-public-card small{opacity:.7}.attack-declaration-picker{display:flex;gap:6px;overflow-x:auto;padding:6px 1px;-webkit-overflow-scrolling:touch}.attack-declaration-picker .response-hand-card{flex:0 0 112px}.selection-bar .warn{visibility:visible!important;display:inline-flex!important}.game-main,.game-topbar,.game-topbar .actions{min-width:0}.game-topbar .actions{flex-wrap:wrap!important;overflow:visible!important}.game-topbar{height:auto!important;min-height:48px!important;overflow:visible!important}
@media(max-width:760px){html,body{overscroll-behavior-y:none}body.in-game{position:relative!important}.attack-public-card{min-width:92px}.attack-declaration-picker .response-hand-card{flex-basis:104px}}


/* ===== DMSIM v7.6.3 attack visibility / centered declaration UI ===== */
.attack-center-layer{position:fixed;inset:0;z-index:19000;display:flex;align-items:center;justify-content:center;padding:18px;box-sizing:border-box}
.attack-center-blocking{background:#0007;backdrop-filter:blur(1.5px)}
.attack-center-modal{width:min(520px,calc(100vw - 36px));max-height:min(78vh,620px);overflow:auto;background:#17212d;border:1px solid #52677e;border-radius:12px;padding:14px;box-shadow:0 20px 60px #000d;display:flex;flex-direction:column;gap:11px}
.attack-center-modal h3{margin:0;font-size:17px}.attack-center-modal .attack-response-choice{font-size:13px;padding:5px 0}
.attack-center-modal .attack-response-actions button{min-height:38px;font-size:13px}
.attack-process-panel{position:fixed;z-index:17000;left:50%;top:50%;transform:translate(-50%,-50%);width:min(680px,calc(100vw - 32px));max-height:min(58vh,520px);overflow:auto;background:#17212d;border:1px solid #52677e;border-radius:11px;padding:11px;box-shadow:0 16px 48px #000c;display:flex;flex-direction:column;gap:8px;pointer-events:auto}
.attack-quick-action{position:fixed;z-index:16500;right:22px;bottom:22px;min-width:112px;min-height:42px;padding:9px 18px!important;font-size:14px!important;font-weight:900!important;border-radius:10px!important;box-shadow:0 10px 30px #000b!important}
@media(max-width:1100px) and (min-width:761px){.selection-bar{max-height:none!important;overflow:visible!important}.attack-quick-action{right:18px;bottom:18px}}
@media(max-width:760px){.attack-center-layer{padding:10px}.attack-center-modal{width:calc(100vw - 20px);max-height:70vh}.attack-process-panel{top:auto;bottom:78px;transform:translateX(-50%);width:calc(100vw - 16px);max-height:46vh}.attack-quick-action{right:10px;bottom:78px;min-width:96px;min-height:40px}}

/* ===== DMSIM v7.6.4 declaration commit + sidebar card actions ===== */
.selected-card-viewer{max-height:none;min-height:260px;flex:1 1 auto}
.selected-card-viewer-body{flex:0 1 230px;min-height:90px}
.selected-card-sidebar-actions{margin-top:auto;border-top:1px solid #293644;padding:8px;background:#101821;display:flex;flex-direction:column;gap:6px}
.selected-card-sidebar-actions>b{font-size:10px;color:#aebac8}.selected-card-sidebar-actions>div{display:grid;grid-template-columns:1fr 1fr;gap:5px}.selected-card-sidebar-actions button{font-size:10px;padding:6px 5px;min-width:0}
.attack-declaration-picker .response-hand-card.selected{outline:2px solid #e7edf5;box-shadow:0 0 0 2px #0b0f14,0 0 14px #fff5;transform:translateY(-2px)}
.attack-process-nonblocking{left:auto;right:18px;top:78px;transform:none;width:min(520px,calc(100vw - 330px));max-height:42vh}
@media(max-width:1100px) and (min-width:761px){.attack-process-nonblocking{right:12px;width:min(460px,calc(100vw - 250px))}.selected-card-sidebar-actions>div{grid-template-columns:1fr}}
@media(max-width:760px){.selected-card-viewer{max-height:none;min-height:260px}.selected-card-sidebar-actions>div{grid-template-columns:1fr 1fr}.attack-process-nonblocking{left:8px;right:8px;top:auto;bottom:82px;transform:none;width:auto;max-height:44vh}}

/* v7.6.5 attack-source recovery + stable internal scrolling */
.attack-attacker-reselect{display:flex;gap:7px;overflow:auto;padding:6px 1px;max-height:38vh;flex-wrap:wrap}.attack-attacker-reselect .response-hand-card{min-width:130px;max-width:210px}.attack-declaration-picker,.attack-public-zone,.attack-process-panel,.selected-card-viewer{overscroll-behavior:contain;scrollbar-gutter:stable}.attack-quick-action{display:none!important}

/* v7.6.6 stack interaction */
.stack-badge-action{cursor:pointer;pointer-events:auto;user-select:none;z-index:5}
.stack-badge-action:hover{transform:translateY(-1px);filter:brightness(1.15)}
.stack-member-facedown{border-style:dashed}

/* ===== v7.7.0: Discord-inspired app shell ===== */
:root{--ui-bg:#0b1020;--ui-rail:#0d1425;--ui-panel:#111a2e;--ui-panel2:#16213a;--ui-hover:#1d2a46;--ui-line:rgba(255,255,255,.07);--ui-text:#eef3ff;--ui-muted:#8f9bb5;--ui-accent:#5865f2;--ui-accent2:#7289da}
body{background:var(--ui-bg);color:var(--ui-text)}
body>header{height:52px;box-sizing:border-box;position:sticky;top:0;z-index:1200;background:#0a0f1c;border-bottom:1px solid var(--ui-line);display:flex;align-items:center;padding:0 18px;gap:12px;box-shadow:none}
body>header b{font-size:16px;letter-spacing:.3px} body>header #me{margin-left:auto;color:var(--ui-muted);font-size:13px}
main{max-width:none;margin:0;padding:0}
#app{min-height:calc(100vh - 52px);padding-left:210px;box-sizing:border-box}
#app>nav{position:fixed;z-index:1100;left:0;top:52px;bottom:0;width:210px;box-sizing:border-box;background:var(--ui-rail);border-right:1px solid var(--ui-line);padding:18px 12px;display:flex;flex-direction:column;gap:5px;margin:0}
#app>nav:before{content:'DMSIM';display:block;color:#fff;font-weight:800;font-size:13px;letter-spacing:1.5px;padding:5px 10px 13px;opacity:.7}
#app>nav button{width:100%;min-height:40px;text-align:left;border:0;background:transparent;color:#aeb8ce;border-radius:7px;padding:0 12px;font-weight:650;box-shadow:none}
#app>nav button:hover{background:var(--ui-hover);color:#fff;transform:none}
#app>nav button.active{background:var(--ui-panel2);color:#fff}
#app>.tab.panel{margin:0;border:0;border-radius:0;box-shadow:none;background:transparent;min-height:calc(100vh - 52px);padding:28px 34px;box-sizing:border-box}
#home{max-width:1180px}
.home-hero{border:0!important;background:linear-gradient(135deg,#131e36,#10182b)!important;border-radius:12px!important;padding:28px!important;margin-bottom:18px!important;box-shadow:0 8px 28px rgba(0,0,0,.16)}
.home-hero h2{font-size:27px;margin:0 0 5px}.home-user{background:rgba(0,0,0,.16)!important;border:1px solid var(--ui-line)!important;border-radius:9px!important}
.home-grid{gap:14px!important}.home-card{background:var(--ui-panel)!important;border:1px solid var(--ui-line)!important;border-radius:10px!important;padding:20px!important;box-shadow:none!important;transition:.15s ease}
.home-card:hover{background:#142039!important;border-color:rgba(255,255,255,.12)!important;transform:translateY(-1px)}
.home-card h3{font-size:16px}.home-card p,.muted{color:var(--ui-muted)!important}
button{border-radius:7px;border:0;box-shadow:none;transition:background .12s ease,transform .08s ease}button:hover{transform:none}button:not(.ghost):not(.danger):not(.warn){background:var(--ui-accent)}button:not(.ghost):not(.danger):not(.warn):hover{background:#6875f5}.ghost{background:#202b42!important;border:0!important;color:#dce4f5!important}.ghost:hover{background:#293751!important}
.panel{border-color:var(--ui-line);box-shadow:none}.deckline,.history-row,.room-card,.admin-card-item{border-color:var(--ui-line)!important;background:var(--ui-panel)!important;border-radius:9px!important}
input,select,textarea{background:#0c1426!important;border:1px solid rgba(255,255,255,.1)!important;border-radius:7px!important;color:var(--ui-text)!important;box-shadow:none!important}input:focus,select:focus,textarea:focus{border-color:#6572ef!important;outline:2px solid rgba(88,101,242,.16)!important}
/* game: tool-like 3-panel feel while preserving current DOM/logic */
#game{background:#090f1d!important;min-height:calc(100vh - 52px);padding:12px!important;box-sizing:border-box}
#game .game-layout,#game .board-layout{gap:10px!important}
#game .card-detail,#game .game-sidebar,#game .side-panel{background:#0e1729!important;border:1px solid var(--ui-line)!important;border-radius:10px!important;box-shadow:none!important}
#game .zone,#game .battle-zone,#game .mana-zone,#game .shield-zone{border-color:rgba(255,255,255,.07)!important}
#game .selection-bar{background:#121d33!important;border:1px solid var(--ui-line)!important;border-radius:9px!important;box-shadow:none!important}
#game .turn-indicator{border-radius:7px!important}
.modal-layer{background:rgba(2,6,15,.68)!important;backdrop-filter:blur(3px)}.modal-layer>.panel,.attack-prompt-modal{background:#111a2e!important;border:1px solid rgba(255,255,255,.09)!important;border-radius:12px!important;box-shadow:0 20px 70px rgba(0,0,0,.42)!important}
@media(max-width:850px){#app{padding-left:0}#app>nav{position:fixed;top:auto;left:0;right:0;bottom:0;width:auto;height:60px;z-index:1600;display:flex;flex-direction:row;align-items:center;justify-content:space-around;padding:6px 8px;border-right:0;border-top:1px solid var(--ui-line)}#app>nav:before{display:none}#app>nav button{width:auto;flex:1;text-align:center;padding:0 5px;font-size:12px}#app>.tab.panel{padding:18px 12px 76px}.home-hero{padding:20px!important}#game{padding-bottom:72px!important}}


/* ===== DMSIM v7.7.1: compact battle sidebar + stable scroll UX ===== */
@media(min-width:1001px){
  body.in-game .game-shell{grid-template-columns:230px minmax(0,1fr)!important}
}
@media(min-width:761px) and (max-width:1000px){
  body.in-game .game-shell{grid-template-columns:210px minmax(0,1fr)!important}
}
body.in-game .sidebar{scrollbar-gutter:stable;overflow-y:auto;overflow-x:hidden}
body.in-game .sidebar-block{flex:0 0 auto}
body.in-game .sidebar .log{height:26vh;min-height:135px;scrollbar-gutter:stable}
body.in-game .sidebar-tools{padding:0;overflow:hidden}
body.in-game .sidebar-tools summary{cursor:pointer;list-style:none;padding:8px 9px;font-size:11px;font-weight:800;color:#b8c5d8;background:#101925;user-select:none}
body.in-game .sidebar-tools summary::-webkit-details-marker{display:none}
body.in-game .sidebar-tools summary:after{content:'＋';float:right;color:#8191a7}
body.in-game .sidebar-tools[open] summary:after{content:'−'}
body.in-game .sidebar-tools>button,body.in-game .sidebar-tools>.muted,body.in-game .sidebar-tools>.shortcut-note{margin:6px 7px;width:calc(100% - 14px)}
body.in-game .selected-card-viewer{min-height:170px;flex:1 1 auto}
body.in-game .attack-declaration-picker,body.in-game .attack-public-zone,body.in-game .attack-process-panel,body.in-game .log{overscroll-behavior:contain;scrollbar-gutter:stable}


/* ===== DMSIM v7.7.2: wider sidebar + persistent declaration X scroll + mobile nonblocking attack sheet ===== */
@media(min-width:1001px){
  body.in-game .game-shell{grid-template-columns:340px minmax(0,1fr)!important}
}
@media(min-width:761px) and (max-width:1000px){
  body.in-game .game-shell{grid-template-columns:300px minmax(0,1fr)!important}
}
body.in-game .sidebar-tools{padding:7px!important;overflow:visible!important}
body.in-game .sidebar-tools h3{margin:2px 0 6px!important;padding:0!important;background:none!important}
body.in-game .sidebar-tools>button{margin:5px 0 0!important;width:100%!important}
body.in-game .sidebar-tools>.muted,body.in-game .sidebar-tools>.shortcut-note{margin:6px 0 0!important;width:auto!important}
body.in-game .attack-declaration-picker{overflow-x:auto!important;overflow-y:hidden!important;scroll-behavior:auto!important;touch-action:pan-x!important}
@media(max-width:760px){
  body.in-game .attack-process-nonblocking{
    left:8px!important;right:8px!important;top:auto!important;
    bottom:calc(76px + env(safe-area-inset-bottom))!important;
    width:auto!important;max-height:28dvh!important;min-height:0!important;
    padding:9px!important;gap:6px!important;border-radius:12px!important;
    overflow-y:auto!important;transform:none!important;
  }
  body.in-game .attack-process-nonblocking h3{font-size:17px!important;margin:0!important}
  body.in-game .attack-process-nonblocking>.muted{font-size:11px!important;line-height:1.35!important;margin:0!important}
  body.in-game .attack-process-nonblocking .attack-public-zone{margin:2px 0!important;padding:6px!important;max-height:82px!important;overflow:auto!important}
  body.in-game .attack-process-nonblocking .attack-public-cards{flex-wrap:nowrap!important;overflow-x:auto!important}
  body.in-game .attack-process-nonblocking .attack-public-card{flex:0 0 auto!important;min-width:92px!important;max-width:145px!important;padding:5px 7px!important}
  body.in-game .attack-process-nonblocking .attack-response-actions{position:sticky!important;bottom:-9px!important;background:#17212d!important;padding-top:5px!important;z-index:2!important}
  body.in-game .attack-process-nonblocking .attack-response-actions button{min-height:38px!important}
  body.in-game .attack-process-nonblocking .attack-declaration-picker{min-height:82px!important;flex:0 0 auto!important}
}


/* ===== DMSIM v7.7.3: mobile card-action bottom sheet ===== */
.mobile-card-action-sheet{display:none}
@media(max-width:760px){
  body.in-game .mobile-card-action-sheet{
    display:block;position:fixed;z-index:19850;left:7px;right:7px;
    bottom:calc(64px + env(safe-area-inset-bottom));
    background:#151f2e;border:1px solid #536277;border-radius:13px;
    box-shadow:0 -10px 32px #0009;padding:8px;max-height:178px;
    box-sizing:border-box;overflow:hidden;pointer-events:auto;
  }
  body.in-game .mobile-card-action-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
  body.in-game .mobile-card-action-head>div{min-width:0;display:flex;flex-direction:column;gap:1px}
  body.in-game .mobile-card-action-head small{font-size:9px;color:#8fa0b8}
  body.in-game .mobile-card-action-head b{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  body.in-game .mobile-card-action-head>button{flex:0 0 auto;min-width:34px;padding:5px 8px}
  body.in-game .mobile-card-action-buttons{display:grid;grid-auto-flow:column;grid-template-rows:repeat(2,38px);grid-auto-columns:minmax(92px,1fr);gap:5px;overflow-x:auto;overflow-y:hidden;padding-bottom:3px;overscroll-behavior:contain;scrollbar-width:thin;-webkit-overflow-scrolling:touch}
  body.in-game .mobile-card-action-buttons button{font-size:10px;padding:5px 7px;white-space:nowrap;min-width:0}
  body.in-game .sidebar .selected-card-sidebar-actions{display:none!important}
  body.in-game .sidebar .selected-card-viewer{min-height:150px}
  /* Follow-up card menus stay above the bottom nav and use phone width. */
  body.in-game .move-menu,body.in-game .deck-menu{z-index:22050;bottom:calc(64px + env(safe-area-inset-bottom))!important;max-height:58dvh!important}
  body.in-game .stack-viewer-layer .stack-viewer-sheet,body.in-game .grave-list-layer .grave-list-sheet{max-height:72dvh}
  /* Attack/declaration follow-ups use bottom-sheet placement instead of covering the board center. */
  body.in-game .attack-declare-overlay{align-items:flex-end!important;padding:7px 7px calc(64px + env(safe-area-inset-bottom))!important;pointer-events:none!important;background:transparent!important;backdrop-filter:none!important}
  body.in-game .attack-declare-overlay .attack-declare-modal{pointer-events:auto!important;width:100%!important;max-width:none!important;max-height:42dvh!important;overflow:auto!important;border-radius:13px!important;box-shadow:0 -12px 36px #000a!important}
}


/* ===== DMSIM v7.7.4: mobile card-ops nav + surrender relocation + scroll regression guard ===== */
.mobile-sidebar-concede{display:none!important}
@media(max-width:760px){
  body.in-game .mobile-sidebar-concede{display:block!important;width:100%;margin-top:9px}
  body.in-game .mobile-card-ops-nav{font-weight:800}
  body.in-game .mobile-card-action-buttons,
  body.in-game .attack-declaration-picker,
  body.in-game .attack-public-zone,
  body.in-game .attack-process-panel,
  body.in-game .selected-card-viewer-body,
  body.in-game .log{scroll-behavior:auto!important;overscroll-behavior:contain}
}


/* ===== DMSIM v7.7.6: collapsible mobile attack flow ===== */
.mobile-attack-panel-toggle{display:none}
@media(max-width:760px){
  body.in-game .mobile-attack-panel-toggle{
    display:flex;position:fixed;z-index:23050;align-items:center;justify-content:center;gap:8px;
    border:1px solid #61738a;box-shadow:0 8px 24px #0009;font-weight:800;
  }
  body.in-game .mobile-attack-panel-toggle.expanded{
    top:58px;right:8px;width:auto;min-height:32px;padding:5px 10px;font-size:10px;background:#202c3d;
  }
  body.in-game .mobile-attack-panel-toggle.collapsed{
    /* Keep the collapsed attack control by the top turn area so it never covers the hand/bottom nav. */
    top:96px;right:8px;left:auto;bottom:auto;width:auto;max-width:calc(100vw - 16px);min-height:34px;
    padding:6px 10px;font-size:11px;background:#17212d;border-color:#d0a75e;
  }
  body.in-game .mobile-attack-panel-toggle.collapsed b{margin-left:auto;color:#fff}
  /* Collapsing hides only attack-flow UI. The board, hand and normal card controls remain interactive. */
  body.in-game.mobile-attack-collapsed .attack-center-layer,
  body.in-game.mobile-attack-collapsed .attack-process-panel,
  body.in-game.mobile-attack-collapsed .attack-response-panel,
  body.in-game.mobile-attack-collapsed .attack-final-panel,
  body.in-game.mobile-attack-collapsed .attack-declare-overlay,
  body.in-game.mobile-attack-collapsed .attack-public-zone{display:none!important}
}

/* ===== DMSIM v7.8.0 auth / scroll stability ===== */
.auth-back{margin-bottom:14px}.auth-back a{color:var(--muted,#9aa7bd);text-decoration:none}.id-input-wrap{display:flex;align-items:center;gap:8px;border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:0 12px;background:rgba(255,255,255,.035)}.id-input-wrap span{font-weight:800;opacity:.7}.id-input-wrap input{border:0!important;background:transparent!important;margin:0!important;padding-left:0!important;box-shadow:none!important}.auth-id-label{display:block;font-size:.82rem;color:var(--muted,#9aa7bd);margin:12px 0 5px}.auth-primary{box-shadow:0 0 0 2px rgba(120,150,255,.22)}
