:root{--ws-card-back-url:url("/lobby/card-back.svg");font-family:system-ui,sans-serif;color:#e7eef5;background:#101b28;color-scheme:dark}*{box-sizing:border-box}body{margin:0}header{padding:16px 24px;display:flex;align-items:center;gap:18px;flex-wrap:wrap;background:#18283a}h1{font-size:22px;margin:0}main{max-width:1450px;margin:auto;padding:20px}button,input,select,textarea{font:inherit;padding:10px;border-radius:7px;border:1px solid #587188}button{cursor:pointer;background:#294761;color:white}button:hover{background:#396789}button:disabled{opacity:.45;cursor:default}a{color:#92cfff}section,form,.panel{background:#1c2c3d;border:1px solid #40566a;border-radius:12px;padding:16px;margin-bottom:16px}.tables{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px}.table h3{margin-top:0}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}textarea{width:100%;height:150px}#error{color:#ffd5c9;background:#542b28;margin:0;padding:0 20px;white-space:pre-wrap}#error:not(:empty){padding:12px 20px}.board{display:grid;grid-template-columns:1fr 1fr;gap:14px}.stage{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:10px 0}.slot{padding:4px;border:1px dashed #526c83;min-height:100px;text-align:center}.slot small{display:block}.slot .card{max-width:120px}.cards{display:flex;gap:8px;flex-wrap:wrap}.card{display:flex;flex-direction:column;width:115px;font-size:11px;padding:4px;background:#263c51;text-align:left}.card img{width:100%;height:145px;object-fit:contain;background:#122233}.card.selected{outline:4px solid #ffcd54}.card.Reverse{border:3px solid #f19b9b}.card.Rest{border:3px solid #f4d77b}.counts{font-size:14px}.choice{position:sticky;top:0;z-index:2;background:#304c64;border:2px solid #f4d77b;box-shadow:0 5px 20px #0008}.choice h3{margin-top:0}.choice .hint{white-space:pre-wrap}.order{background:#705a20;font-size:14px}.actions{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0}.muted{color:#b4c4d2}.name{font-weight:bold}.log{max-height:160px;overflow:auto;font-size:13px}.zone{margin:8px 0}.status{font-size:19px;color:#f8d67e}dialog{width:min(650px,95vw);max-height:90vh;background:#1b2b3c;border:1px solid #8ca8be;border-radius:12px}dialog::backdrop{background:#0009}#detail-content{white-space:pre-wrap}#detail-content img{float:left;width:180px;margin:10px 18px 10px 0}label{display:block;margin:8px 0}@media(max-width:700px){.board{grid-template-columns:1fr}main{padding:10px}.card{width:94px}.card img{height:120px}.choice{position:relative}.row{align-items:flex-start}}

.table{padding:18px;background:#162637;border:1px solid #3c536a;border-radius:10px}.table button{margin:8px 6px 0 0}.tables{margin-top:16px}.badge{display:inline-block;padding:4px 8px;background:#29445b;border-radius:20px;font-size:13px}.empty{padding:24px;color:#bdd1df}.validation{color:#ffcb9e;margin:4px 0}.deck-totals{font-size:18px;color:#a9e1c5}.deck-card{width:142px;border:1px solid #3f5a70;border-radius:8px;padding:8px;font-size:11px}.deck-card .card{width:100%}.deck-card button:not(.card){padding:5px 10px;margin:6px 3px 0 0}.deck-card strong{display:block;overflow-wrap:anywhere}.deck-preview{margin:16px 0;max-height:520px;overflow:auto}.chat{padding:12px}.chat-log{max-height:130px;overflow:auto;font-size:14px}.chat-log p{margin:6px 0;overflow-wrap:anywhere}.chat form{padding:0;border:0;background:none;margin:8px 0 0}.chat input{flex:1;min-width:180px}form>input{display:block;margin:10px 0;width:min(100%,600px)}form>input[type=file]{font-size:14px}.stage .slot:nth-child(4){grid-column:1 / 2;margin-left:20%}.stage .slot:nth-child(5){grid-column:2 / 4;margin-right:25%}.board>section:first-child{border-color:#5e9c97}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #7ad6ce;outline-offset:2px}#detail-close{position:sticky;top:0;z-index:3;float:right}#detail-content{clear:both}#connection{font-size:13px;color:#b3e4cb}header a{margin-left:auto}details>summary{cursor:pointer;padding:8px 0}.chat-log:empty:before{content:'尚無訊息';color:#9db2c5}.zone[open]{border-top:1px solid #3c536a;padding-top:4px}input,select,textarea{background:#112334;color:#e5f0fa}@media(max-width:700px){header{padding:12px}.deck-card{width:120px}.board{gap:8px}.stage .slot{min-height:100px}.chat{order:3}}

.sort-list{padding-left:22px}.sort-list li{margin:8px 0;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.sort-list li span{flex:1;min-width:150px}.choice-message{color:#c9e8ff;font-weight:600}
/* Complete catalog and deck construction workspace */
.workspace-nav{display:flex;gap:8px;margin-bottom:16px}.workspace-nav button{border-radius:20px}main.builder-workspace{max-width:1900px}.builder-shell{--paper:#f5f8f9;--ink:#223d45;--line:#d9e4e5;color:var(--ink);background:var(--paper);border-radius:18px;padding:18px}.builder-shell section,.builder-shell aside{background:white;border:1px solid var(--line);border-radius:12px;padding:14px;margin:0}.builder-shell input,.builder-shell select,.builder-shell textarea{color:var(--ink);background:#f8fafb;border:1px solid #c5d5d8;max-width:100%;padding:8px}.builder-shell button{background:#fff;color:#245e61;border:1px solid #bdd4d5}.builder-shell button:hover{background:#e7f5f1}.builder-shell .muted{color:#657c85}.builder-head{margin-bottom:14px!important}.builder-head h2{margin:5px 0;font-size:26px}.builder-head p{margin:5px 0;font-size:13px}.eyebrow{font-size:11px;letter-spacing:2px;color:#21877d;font-weight:700}.builder-layout{display:grid;grid-template-columns:240px minmax(400px,1fr) 340px;gap:14px;align-items:start}.builder-preview{position:sticky;top:12px;max-height:calc(100vh - 30px);overflow:auto}.builder-preview>img{width:100%;border-radius:8px}.builder-preview h3{font-size:17px}.builder-preview p{font-size:12px;line-height:1.65}.builder-effect{white-space:pre-wrap}.catalog-filters{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.catalog-filters label{font-size:11px;margin:0;color:#657b83}.catalog-filters input,.catalog-filters select{width:100%;display:block;margin-top:4px;font-size:12px}.catalog-toolbar,.catalog-pagination{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:12px 0}.catalog-toolbar strong{margin-right:auto;font-size:13px}.catalog-toolbar button,.catalog-pagination button{padding:6px 10px;font-size:12px}.catalog-pagination{justify-content:center}.catalog-results.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(105px,1fr));gap:10px}.catalog-results{max-height:70vh;overflow:auto;padding:3px}.catalog-card{border:1px solid #d7e3e7;border-top:3px solid #5c8e8a;border-radius:8px;overflow:hidden;display:flex;flex-direction:column;min-width:0}.catalog-image{padding:0;border:0!important;border-radius:0;background:#f4f6f8!important}.catalog-image img{width:100%;height:160px;object-fit:contain;display:block}.catalog-info{padding:6px;display:flex;flex-direction:column;gap:4px;flex:1}.catalog-info strong{font-size:11px;line-height:1.45}.catalog-info small{font-size:10px;color:#627780}.catalog-card>button:last-child{border:0;border-top:1px solid #e0e9e9;border-radius:0;padding:7px 4px;font-size:11px}.catalog-card.color-Yellow{border-top-color:#dfb542}.catalog-card.color-Green{border-top-color:#4a9a6b}.catalog-card.color-Red{border-top-color:#ce6870}.catalog-card.color-Blue{border-top-color:#588cc7}.catalog-results.list .catalog-card{display:grid;grid-template-columns:65px 1fr 95px;margin-bottom:6px;align-items:center}.catalog-results.list .catalog-image img{height:85px}.catalog-results.list .catalog-info strong{font-size:13px}.builder-deck{position:sticky;top:12px}.builder-deck h3{margin:0 0 8px}.builder-deck>input{width:100%;margin-bottom:10px}.builder-total{display:block;padding:12px 0;color:#147b70;font-size:20px}.deck-bars{display:flex;gap:6px}.color-pill{padding:5px 9px;border-radius:12px;font-size:11px;color:white}.color-pill.color-Yellow{background:#a78616}.color-pill.color-Green{background:#338153}.color-pill.color-Red{background:#b74b59}.color-pill.color-Blue{background:#3d75a6}.builder-levels{font-size:11px;color:#667e88}.builder-save{display:flex;gap:5px;flex-wrap:wrap;margin:10px 0}.builder-save button{font-size:11px;padding:7px}.builder-save button:first-child{background:#167e75;color:white}.builder-deck-list{max-height:50vh;overflow:auto}.builder-deck-list h4{font-size:12px;background:#edf4f3;padding:7px;margin:10px 0 3px}.builder-deck-row{display:flex;align-items:center;border-bottom:1px solid #edf1f2;gap:4px;padding:5px 0}.builder-deck-row b{font-size:12px;min-width:26px;color:#148175}.builder-deck-row button{font-size:11px;padding:5px;border:0}.builder-deck-row button:first-of-type{flex:1;text-align:left;line-height:1.5}.builder-deck textarea{min-height:200px;font-size:11px}.builder-deck details{font-size:12px}.room-layout{display:grid;grid-template-columns:270px minmax(0,1fr);gap:16px;align-items:start}.room-inspector{position:sticky;top:10px;background:#1c2c3d;border:1px solid #40566a;border-radius:12px;padding:14px;max-height:90vh;overflow:auto}.room-inspector>img{width:100%;border-radius:8px}.room-inspector p{font-size:12px;line-height:1.6;white-space:pre-wrap}.room-inspector h2{font-size:17px}.room-inspector .actions{flex-direction:column}.room-inspector .actions button{text-align:left}.duel-mat{display:flex;flex-direction:column;gap:14px}.duel-mat>section{margin:0;position:relative}.player-mat{background:linear-gradient(135deg,#1c3c45,#18303b);border-color:#417778}.own-mat{box-shadow:inset 0 3px #61c9b7}.opponent-mat{box-shadow:inset 0 3px #768eb6}.player-mat h3{font-size:15px;margin:0 0 7px}.player-mat .stage{max-width:650px;margin:12px auto;gap:10px}.player-mat .slot{min-height:155px;background:#0d233044;border-radius:10px}.player-mat .slot small{font-size:11px;opacity:.7}.player-mat .slot:nth-child(4){grid-column:1 / 2;margin-left:30%}.player-mat .slot:nth-child(5){grid-column:2 / 4;margin-right:30%}.opponent-mat .stage{direction:rtl}.opponent-mat .slot{direction:ltr}.player-mat .cards{gap:6px}.player-mat .card{width:100px;border-radius:7px}.player-mat .card img{height:132px}.phase-track{display:flex;gap:5px;flex-wrap:wrap;margin-bottom:10px}.phase-track span{border:1px solid #526c83;border-radius:20px;padding:5px 10px;font-size:11px;color:#b7c8d7}.phase-track .active{background:#5fc3ae;color:#102d32;border-color:#5fc3ae;font-weight:bold}.room-status{position:sticky;top:0;z-index:2;padding:12px}.room-status .status{font-size:16px;margin:5px 0}.turn-hint{font-size:12px;color:#a8d9d2}.room-header h2{margin:0 0 7px}.room-header p{font-size:13px}.choice{top:5px}.room-workspace{max-width:1600px}.room-workspace .chat{margin-top:16px}.room-workspace .zone>summary{font-size:12px}.room-workspace .opponent-mat .zone:has(summary:first-child){margin-top:8px}@media(max-width:1250px){.builder-layout{grid-template-columns:200px minmax(300px,1fr) 290px}.catalog-filters{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:1000px){.builder-layout{grid-template-columns:minmax(0,1fr) 300px}.builder-preview{grid-column:1 / -1;position:static;max-height:240px}.builder-preview>img{width:120px;float:left;margin-right:12px}.catalog-filters{grid-template-columns:repeat(3,minmax(0,1fr))}.room-layout{grid-template-columns:220px minmax(0,1fr)}}@media(max-width:700px){.builder-shell{padding:8px}.builder-layout{display:flex;flex-direction:column}.builder-catalog,.builder-deck{width:100%;position:static}.builder-deck{order:-1}.builder-deck-list{max-height:200px}.catalog-filters{grid-template-columns:repeat(2,minmax(0,1fr))}.catalog-results.grid{grid-template-columns:repeat(3,minmax(0,1fr))}.catalog-image img{height:140px}.room-layout{display:flex;flex-direction:column}.room-inspector{position:static;max-height:360px;width:100%;order:1}.room-inspector>img{width:120px;float:left;margin-right:12px}.duel-mat{width:100%}.player-mat .card{width:80px;font-size:10px}.player-mat .card img{height:110px}.player-mat .slot{min-height:135px}.player-mat .stage{gap:4px}.room-status{position:static}}

#notice{margin:0;background:#174e43;color:#b5f1d9;padding:0 20px}#notice:not(:empty){padding:12px 20px}
/* Keep large deck-search choices usable without pushing Confirm outside the viewport. */
.choice{max-height:85vh;overflow:auto;scroll-margin-top:12px}.choice .cards{max-height:38vh;overflow:auto}.choice .hint{max-height:105px;overflow:auto;font-size:12px;line-height:1.6}.choice h3{font-size:16px}.choice-message{font-size:13px}
/* Drag targets keep their size and do not alter stage geometry. */
.card[draggable=true]{cursor:grab;touch-action:pan-y}.card.dragging{opacity:.4}.slot.drop-target{outline:2px dashed #58d6ac;outline-offset:-3px;position:relative}.slot.drop-target:after{content:attr(data-drop-label);position:absolute;bottom:3px;left:3px;background:#12392ee8;color:#d6ffef;padding:3px 7px;border-radius:5px;pointer-events:none;font-size:12px}.slot.drag-over{background:#245b48;box-shadow:inset 0 0 0 3px #91f5cf}.is-dragging .card{user-select:none}

.player-mat .stage{grid-template-columns:repeat(6,minmax(0,1fr))}.player-mat .slot{grid-column:span 2;display:flex;flex-direction:column;align-items:center}.player-mat .slot:nth-child(4){grid-column:2 / 4;margin:0}.player-mat .slot:nth-child(5){grid-column:4 / 6;margin:0}
/* Viewport table, matching the single-player board's split-panel composition. */
.card-back {
  background-image: var(--ws-card-back-url) !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-radius: 4px;
}
.header-btn {
  background: #254432;
  border: 1px solid #4a755d;
  color: #c9e8d5;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.header-btn:hover {
  background: #366349;
  color: #fff;
}
.ws-card-back-dialog {
  width: min(520px, 92vw);
  background: #182c23;
  color: #eaf3ee;
  border: 2px solid #5a876e;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7);
}
.ws-card-back-dialog::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #112019;
  border-bottom: 1px solid #3d6350;
}
.dialog-header h2 {
  font-size: 16px;
  margin: 0;
  color: #fff;
}
.dialog-close-btn {
  background: transparent;
  border: 0;
  color: #a8cfbc;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.dialog-close-btn:hover {
  color: #fff;
}
.dialog-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dialog-desc {
  font-size: 12.5px;
  color: #b7d6c6;
  margin: 0;
  line-height: 1.5;
}
.preset-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.preset-btn {
  background: #254434;
  color: #e2f2ea;
  border: 1px solid #4d7a61;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.preset-btn:hover {
  background: #37644d;
}
.custom-url-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}
.custom-url-row input[type="text"] {
  flex: 1;
  background: #112019;
  color: #eaf3ee;
  border: 1px solid #4a755d;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.file-upload-btn {
  background: #2f5440;
  color: #fff;
  border: 1px solid #5a8a6e;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.file-upload-btn:hover {
  background: #407357;
}
.preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  background: #101c16;
  border-radius: 8px;
  border: 1px solid #2f4d3c;
  margin-top: 6px;
}
.card-back-preview-card {
  width: 90px;
  height: 128px;
  border-radius: 5px;
  background-image: var(--ws-card-back-url);
  background-size: cover;
  background-position: center;
  border: 1.5px solid #d4af37;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  background: #112019;
  border-top: 1px solid #3d6350;
}
.btn-dialog-primary {
  background: #3b7558;
  color: #fff;
  border: 1px solid #63a884;
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.btn-dialog-primary:hover {
  background: #4c9671;
}
.btn-dialog-secondary {
  background: #45332f;
  color: #ffd8d2;
  border: 1px solid #7a5047;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-dialog-secondary:hover {
  background: #5c413b;
}

/* Battle View Viewport Layout */
body.battle-view {
  height: 100dvh;
  overflow: hidden;
  background: #93b7a3;
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: dark;
}
.battle-view > header {
  height: 32px;
  min-height: 32px;
  padding: 2px 14px;
  gap: 12px;
  background: #16291f;
  border-bottom: 1px solid #2f523f;
  display: flex;
  align-items: center;
}
.battle-view > header h1 {
  font-size: 13.5px;
  margin: 0;
  color: #ecf7f1;
}
.battle-view > header a, .battle-view #identity, .battle-view #connection {
  font-size: 11px;
}
.battle-view .workspace-nav {
  display: none;
}

.battle-view #app {
  width: 100%;
  max-width: none;
  height: calc(100dvh - 32px);
  padding: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: 32px 42px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}

/* Critical: room-layout must be display: contents so its children (inspector and duel-mat) become direct grid items of #app */
.battle-view .room-layout {
  display: contents !important;
}

/* Left Inspector (Art box top + Light gray details bottom + Drawers) */
.battle-view .room-inspector {
  grid-column: 1;
  grid-row: 1 / 4;
  height: 100%;
  max-height: none;
  position: static;
  border: 0;
  border-radius: 0;
  border-right: 2px solid #4a5d52;
  background: #1f2723;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  z-index: 30;
}
.battle-view .room-art-box {
  flex: 0 0 48%;
  background: #121815;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 2px solid #8a948e;
  position: relative;
}
.battle-view #room-art-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0e1412;
}
.battle-view .room-art-placeholder {
  color: #8fa398;
  font-size: 13px;
  padding: 16px;
  text-align: center;
}
.battle-view .room-card-detail {
  flex: 1 1 auto;
  background: #d2d4d3;
  color: #111;
  padding: 10px 12px;
  overflow-y: auto;
  user-select: text;
  font-size: 12px;
  line-height: 1.5;
  border-top: 1px solid #fff;
}
.battle-view .room-card-detail h3 {
  margin: 0 0 4px;
  padding: 4px 8px;
  background: #b8bcba;
  border: 1px solid #8d9290;
  font-size: 13.5px;
  color: #0b0f0d;
  border-radius: 2px;
  font-weight: 700;
}
.battle-view .room-card-detail small {
  display: block;
  color: #2b3b33;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 11px;
}
.battle-view .room-card-detail .card-traits {
  color: #314b3d;
  font-weight: 600;
  font-size: 11px;
  margin: 3px 0;
}
.battle-view .room-card-detail .card-effect {
  white-space: pre-wrap;
  margin: 6px 0;
  color: #141816;
  font-size: 11.5px;
  line-height: 1.55;
}
.battle-view .room-card-detail .actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  position: sticky;
  bottom: 0;
  background: #d2d4d3;
  padding: 6px 0;
}
.battle-view .room-card-detail .actions button {
  background: #2d5a43;
  color: #fff;
  border: 1px solid #1b3b2b;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 2px #0004;
  width: 100%;
  text-align: center;
  transition: background .15s;
}
.battle-view .room-card-detail .actions button:hover:not(:disabled) {
  background: #3b7558;
}
.battle-view .room-drawer {
  background: #242e29;
  color: #dce8e1;
  border-top: 2px solid #4f6358;
  flex-shrink: 0;
  max-height: 26vh;
  overflow-y: auto;
}
.battle-view .room-drawer summary {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  background: #2d3a34;
  color: #dfece4;
  list-style: none;
}
.battle-view .room-drawer .chat {
  padding: 6px;
  margin: 0;
}
.battle-view .room-drawer .chat-log {
  max-height: 90px;
}
.battle-view .chat input {
  min-width: 80px;
  width: 100%;
  padding: 5px;
  font-size: 11px;
}

/* Room Header */
.battle-view .room-header {
  grid-column: 2;
  grid-row: 1;
  background: #172920;
  border-bottom: 1px solid #335442;
  padding: 2px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: auto;
}
.battle-view .room-header h2 {
  font-size: 13px;
  margin: 0;
  color: #e5f2eb;
}
.battle-view .room-header p {
  font-size: 11px;
  margin: 0;
  color: #a4ceb9;
  margin-right: auto;
}
.battle-view .room-header button {
  font-size: 11px;
  padding: 3px 8px;
  background: #254434;
  border: 1px solid #4d7a61;
  border-radius: 4px;
}

/* Room Status & Phase Bar */
.battle-view .room-status {
  grid-column: 2;
  grid-row: 2;
  position: static;
  margin: 0;
  border: 0;
  border-bottom: 2px solid #3c6350;
  background: #15241d;
  padding: 3px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.battle-view .phase-track {
  display: flex;
  gap: 4px;
  margin: 0;
}
.battle-view .phase-track span {
  padding: 2px 8px;
  font-size: 10.5px;
  border-radius: 12px;
  background: #0f1c16;
  color: #8dafa0;
  border: 1px solid #2d4c3c;
}
.battle-view .phase-track span.active {
  background: #dfc98b;
  color: #17261f;
  font-weight: 700;
  border-color: #f2e3af;
}
.battle-view .room-status .status {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
  color: #f0f7f3;
  letter-spacing: .3px;
}
.battle-view .room-status .turn-hint {
  font-size: 11.5px;
  font-weight: 700;
  margin: 0;
  color: #c4ebd4;
  background: #1c3829cc;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #3d6350;
  white-space: nowrap;
}
.battle-view .ws-done-btn, .battle-view .room-status > button {
  min-width: 140px;
  padding: 6px 20px;
  font-size: 13.5px;
  font-weight: 700;
  color: #1b1f1d;
  background: linear-gradient(180deg, #ffffff 0%, #d8dcdb 100%);
  border: 1.5px solid #5a625e;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform .12s, background .12s;
  flex-shrink: 0;
}
.battle-view .ws-done-btn:hover:not(:disabled), .battle-view .room-status > button:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}
.battle-view .ws-done-btn:disabled, .battle-view .room-status > button:disabled {
  opacity: .45;
  cursor: default;
  transform: none;
}
.battle-view .ws-cancel-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #ffd8d2;
  background: #4a2c28;
  border: 1px solid #75443e;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  flex-shrink: 0;
}
.battle-view .ws-cancel-btn:hover:not(:disabled) {
  background: #613832;
  color: #fff;
}
.battle-view .waiting-hint {
  font-size: 11.5px;
  color: #eedda4;
  margin: 0;
}

/* Playmat Area: Sage Green #93b7a3 */
.battle-view .duel-mat {
  grid-column: 2;
  grid-row: 3;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 2px;
  background: #93b7a3;
  padding: 6px 14px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* Center Prompt between Opponent Mat and Own Mat */
.battle-view .ws-center-prompt {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  margin: 0 auto;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000, 0 2px 5px #000a;
  letter-spacing: .3px;
  pointer-events: none;
  padding: 0 12px;
  z-index: 8;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 980px;
}

/* Opponent Mat */
.battle-view .opponent-mat {
  min-height: 0;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  padding: 0 105px 4px;
  position: relative;
  background: transparent;
  box-shadow: none;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
  border-bottom: 2px solid #54775d;
}
.battle-view .player-mat h3 {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #c4ebd4;
  background: #1c3829cc;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #3d6350;
  margin: 0;
  z-index: 6;
  white-space: nowrap;
}
.battle-view .opponent-mat .counts {
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  margin: 1px 0;
  color: #163825;
}
.battle-view .opponent-mat .hand-strip {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.battle-view .opponent-mat .hand-strip summary {
  display: inline-block;
  background: #213c2c;
  color: #c4ebd4;
  font-size: 10.5px !important;
  font-weight: 700;
  padding: 1px 10px !important;
  border-radius: 10px;
  border: 1px solid #436e53;
  margin-bottom: 2px;
  list-style: none;
}
.battle-view .opponent-mat .hand-strip .cards {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 2px;
}
.battle-view .opponent-mat .hand-strip .card-back {
  width: 38px;
  height: 53px;
  min-width: 38px;
  border-radius: 3px;
  border: 1px solid #d4af3777;
  box-shadow: 0 2px 4px #0006;
  transition: transform .15s;
  flex-shrink: 0;
}
.battle-view .opponent-mat .hand-strip .card-back:hover {
  transform: translateY(-4px);
}

/* Stage Cluster: Dedicated CX Zone + 5 Rectangular Stage Slots */
.battle-view .stage-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin: 2px auto;
}
.battle-view .stage {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 6px !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
}
.battle-view .stage-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* Card-Proportioned Rectangular Stage Slots (74px x 102px) */
.battle-view .slot {
  position: relative;
  width: 74px !important;
  height: 102px !important;
  min-width: 74px !important;
  max-width: 74px !important;
  min-height: 102px !important;
  max-height: 102px !important;
  background: #5d826d;
  border: 1.5px solid #486957;
  box-shadow: inset 0 0 0 1px #72998344, 0 1px 3px rgba(0,0,0,0.18);
  border-radius: 4px;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2px;
  transition: box-shadow .15s, border-color .15s, transform .15s, background .15s;
}
.battle-view .slot small {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px !important;
  color: #b8d1c2;
  text-shadow: 0 1px 1px #0008;
  pointer-events: none;
}
.battle-view .slot.drop-target {
  border: 2px dashed #fff59d !important;
  cursor: pointer;
  box-shadow: 0 0 14px #ffe875cc !important;
  background: #68947b !important;
}
.battle-view .slot.drag-over {
  border: 2px solid #fff !important;
  background: #79ad8f !important;
  transform: scale(1.05);
  box-shadow: 0 0 18px #ffffffdd !important;
}
.battle-view .slot:has(.card.selected), .battle-view .slot.in-battle {
  border: 2px solid #ffe066 !important;
  box-shadow: 0 0 14px #ffe066cc !important;
}

/* Dedicated Horizontal Climax Slot (102px x 74px) */
.battle-view .climax-slot {
  position: relative;
  width: 102px !important;
  height: 74px !important;
  min-width: 102px !important;
  max-width: 102px !important;
  min-height: 74px !important;
  max-height: 74px !important;
  background: #5d826d;
  border: 1.5px dashed #7aa48c;
  box-shadow: inset 0 0 0 1px #72998344, 0 1px 3px rgba(0,0,0,0.18);
  border-radius: 4px;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2px;
  transition: box-shadow .15s, border-color .15s, transform .15s, background .15s;
}
.battle-view .climax-slot .cx-label {
  font-size: 11px;
  font-weight: 700;
  color: #c4ebd4;
  letter-spacing: .5px;
  pointer-events: none;
  text-shadow: 0 1px 2px #0008;
}
.battle-view .climax-slot .card {
  width: 96px !important;
  height: 68px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  min-height: 68px !important;
  max-height: 68px !important;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 2px 5px #0008;
  padding: 0;
}
.battle-view .climax-slot .card img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.battle-view .climax-slot.drop-target {
  border: 2px dashed #fff59d !important;
  cursor: pointer;
  box-shadow: 0 0 14px #ffe875cc !important;
  background: #68947b !important;
}
.battle-view .climax-slot.drag-over {
  border: 2px solid #fff !important;
  background: #79ad8f !important;
  transform: scale(1.05);
  box-shadow: 0 0 18px #ffffffdd !important;
}

/* Prominent Bottom Action Bar directly above Hand Tray */
.battle-view .ws-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 2px;
  z-index: 18;
  width: 100%;
}
.battle-view .ws-action-bar .ws-done-btn {
  min-width: 160px;
  padding: 6px 28px;
  font-size: 15px;
  font-weight: 700;
  color: #1a241f;
  background: linear-gradient(180deg, #ffffff 0%, #d8dedb 100%);
  border: 1.5px solid #576960;
  border-radius: 8px;
  box-shadow: 0 2px 6px #0006;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.battle-view .ws-action-bar .ws-done-btn:hover:not(:disabled) {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px #0007;
}
.battle-view .ws-action-bar .ws-done-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #aab5af;
  border-color: #72827a;
  color: #2b3b33;
  transform: none;
  box-shadow: none;
}
.battle-view .ws-action-bar .ws-done-btn.primary-action {
  background: linear-gradient(180deg, #fffae0 0%, #ffd859 100%);
  border-color: #997814;
  color: #2b1f00;
  box-shadow: 0 0 14px #ffe65988, 0 2px 6px #0006;
}
.battle-view .ws-action-bar .ws-done-btn.primary-action:hover:not(:disabled) {
  background: #fffdf0;
  box-shadow: 0 0 20px #ffe659cc, 0 4px 12px #0007;
  transform: translateY(-2px);
}
.battle-view .ws-action-bar .ws-cancel-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #ffd2cd;
  background: #5c1e19;
  border: 1px solid #c25950;
  border-radius: 7px;
  cursor: pointer;
}
.battle-view .ws-action-bar .ws-cancel-btn:hover:not(:disabled) {
  background: #732720;
}

/* Card display across stage, hand and choices */
.battle-view .card {
  position: relative;
  overflow: visible;
  display: inline-flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #1e332b;
  border: 1.5px solid #2b4238;
  border-radius: 4px;
  padding: 0;
}
.battle-view .card img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 3px;
  pointer-events: none;
}
.battle-view .card .card-name {
  position: relative;
  z-index: 2;
  width: 100%;
  background: #000000ba;
  font-size: 8.5px;
  line-height: 1.15;
  padding: 1px 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  margin-top: auto;
}
.battle-view .card .card-stats {
  position: relative;
  z-index: 2;
  width: 100%;
  background: #0d1f18ea;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 2px;
  text-align: center;
  color: #ffec9e;
  pointer-events: none;
}
.battle-view .card .order {
  position: absolute;
  top: -8px;
  right: -6px;
  z-index: 5;
  background: #ffd84d;
  color: #111;
  font-weight: 800;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 99px;
  border: 1px solid #000;
  box-shadow: 0 1px 3px #0008;
}
.battle-view .card.Rest img {
  transform: rotate(-90deg) scale(.88);
}
.battle-view .card.Reverse img {
  transform: rotate(180deg);
  filter: saturate(.65) brightness(.85);
}

/* Stage Card Sizing */
.battle-view .player-mat .stage .card {
  width: 68px !important;
  height: 96px !important;
  min-width: 68px !important;
  max-width: 68px !important;
  min-height: 96px !important;
  max-height: 96px !important;
  padding: 0;
  margin: 0;
  box-shadow: 0 1px 3px #0006;
}
.battle-view .player-mat .stage .card img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Player Own Mat */
.battle-view .own-mat {
  min-height: 0;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  padding: 0 105px 4px;
  position: relative;
  background: transparent;
  box-shadow: none;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
}
.battle-view .own-mat .counts {
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  margin: 1px 0;
  color: #163825;
}

/* Player's Own Hand Tray: Prominent Large Cards inside Cyan-Framed Mat */
.battle-view .own-mat .hand-strip {
  width: 100%;
  max-width: 820px;
  height: 140px;
  min-height: 140px;
  background: #5d826d;
  border: 2px solid #2ee6d6 !important;
  box-shadow: 0 0 10px #2ee6d655, inset 0 0 10px #0005;
  border-radius: 6px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 15;
  margin: 0 !important;
}
.battle-view .own-mat .hand-strip > summary {
  display: none !important;
}
.battle-view .own-mat .hand-strip .cards {
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 6px;
  max-width: 100%;
}
.battle-view .own-mat .hand-strip .card {
  width: 82px !important;
  height: 116px !important;
  min-width: 82px !important;
  max-width: 82px !important;
  cursor: grab;
  box-shadow: 0 2px 5px #0008;
  transition: transform .16s cubic-bezier(0.2,0,0.2,1), box-shadow .16s, border-color .16s;
}
.battle-view .own-mat .hand-strip .card:hover {
  transform: translateY(-9px);
  border-color: #fff380;
  box-shadow: 0 0 16px 4px #ffe659cc, 0 12px 16px #0008;
  z-index: 25;
}
.battle-view .own-mat .hand-strip .card.inline-selectable {
  cursor: pointer;
  border-color: #8af5cc;
}
.battle-view .own-mat .hand-strip .card.inline-selected,
.battle-view .own-mat .hand-strip .card.selected {
  border: 2px solid #fff380 !important;
  transform: translateY(-9px) !important;
  box-shadow: 0 0 18px 5px #ffe659ee, 0 14px 18px #0009 !important;
  z-index: 26;
}
.battle-view .own-mat .hand-strip .card.dragging {
  opacity: .4;
  transform: scale(.92);
}

/* Zone Dock (Waiting Room, Memory, Level, Clock) */
.battle-view .zone-dock {
  position: absolute;
  left: 6px;
  top: 26px;
  width: 95px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.battle-view .zone-dock .zone {
  margin: 0;
  border: 0;
  background: transparent;
}
.battle-view .zone-dock .zone summary {
  background: linear-gradient(180deg, #e4e6e5 0%, #c5cac7 100%);
  color: #151917;
  border: 1px solid #6c7470;
  border-radius: 4px;
  padding: 4px 6px !important;
  font-size: 11px !important;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 1px 2px #0004;
  list-style: none;
  cursor: pointer;
}
.battle-view .zone-dock .zone summary:hover {
  background: #f2f4f3;
}
.battle-view .zone-dock .zone[open] {
  position: fixed;
  left: calc(280px + 4vw);
  right: 4vw;
  top: 14vh;
  max-height: 72vh;
  overflow: auto;
  z-index: 45;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,0.65);
  padding: 14px;
  background: #193026;
  border: 2px solid #5a8a6e;
  border-radius: 10px;
}
.battle-view .zone-dock .zone[open] > summary {
  font-size: 14px !important;
  font-weight: 700;
  background: #254738;
  color: #fff;
  border-color: #639c7c;
  padding: 6px 12px !important;
}
.battle-view .zone-dock .zone[open] > summary:after {
  content: '　（點此關閉）';
  font-size: 11px;
  opacity: .8;
}
.battle-view .zone-dock .cards {
  max-height: 56vh;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}
.battle-view .zone-dock .card {
  width: 82px;
  height: 116px;
}

/* Pile Dock (Deck with Card Back + Stock Stack) */
.battle-view .pile-dock {
  position: absolute;
  right: 8px;
  top: 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.battle-view .hidden-pile {
  width: 66px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.battle-view .pile-deck {
  height: 88px;
  background: linear-gradient(rgba(10,25,18,0.35), rgba(10,25,18,0.65)), var(--ws-card-back-url) center / cover no-repeat, #15241b;
  border: 1.5px solid #d4af37bb;
  box-shadow: -4px 4px 0 #283a2e, -7px 7px 0 #1b2820, -9px 9px 6px #0007;
  transform: rotate(-3deg);
  color: #fff;
}
.battle-view .pile-deck span {
  font-size: 9.5px;
  font-weight: 700;
  color: #f2e3af;
  text-shadow: 0 1px 2px #000;
}
.battle-view .pile-deck strong {
  font-size: 22px;
  font-weight: 800;
  color: #ffe66d;
  text-shadow: 0 1px 3px #000;
}
.battle-view .pile-deck small {
  font-size: 7.5px;
  color: #d6e8dd;
  text-shadow: 0 1px 1px #000;
}
.battle-view .pile-stock {
  height: 64px;
  background: linear-gradient(135deg, #1f372a, #13241b);
  border: 1.5px solid #5a806c;
  box-shadow: 2px 2px 4px #0006;
  color: #eaf5ee;
}
.battle-view .pile-stock span {
  font-size: 9.5px;
  font-weight: 700;
  color: #a9cfbc;
}
.battle-view .pile-stock strong {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}
.battle-view .pile-stock small {
  font-size: 7.5px;
  color: #8dafa0;
}

/* Choice Dialog Overlay for non-hand choices (e.g. deck search, salvage) */
.battle-view .choice {
  position: fixed;
  left: 300px;
  right: 20px;
  top: 70px;
  max-width: 760px;
  margin: 0 auto;
  z-index: 50;
  max-height: calc(100dvh - 90px);
  padding: 14px 18px;
  background: #183329f8;
  border: 2px solid #8ec4a8;
  border-radius: 10px;
  box-shadow: 0 12px 42px rgba(0,0,0,0.7), 0 0 0 100vmax rgba(0,0,0,0.35);
  overflow-y: auto;
}
.battle-view .choice h3 {
  font-size: 15px;
  margin: 0 0 6px;
  color: #fff;
}
.battle-view .choice .choice-message {
  font-size: 12.5px;
  color: #c9e8d5;
  margin: 4px 0;
}
.battle-view .choice .hint {
  font-size: 11.5px;
  color: #a4ceb8;
  white-space: pre-wrap;
  margin: 4px 0;
}
.battle-view .choice .cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 48vh;
  overflow: auto;
  padding: 8px;
  background: #10241c;
  border-radius: 6px;
  border: 1px solid #325e49;
  margin: 8px 0;
}
.battle-view .choice .card {
  width: 82px !important;
  height: 116px !important;
  min-width: 82px !important;
  max-width: 82px !important;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.6);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.battle-view .choice .card:hover {
  transform: translateY(-6px);
  border-color: #fff380;
  box-shadow: 0 0 14px 3px #ffe659cc;
  z-index: 5;
}
.battle-view .choice .card.selected {
  border: 2px solid #fff380 !important;
  transform: translateY(-6px) !important;
  box-shadow: 0 0 16px 4px #ffe659ee !important;
  z-index: 6;
}
.battle-view .choice button:not(.card) {
  background: #2a4d40;
  color: #fff;
  border: 1px solid #699984;
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin: 4px 4px 0 0;
}
.battle-view .choice button:not(.card):hover:not(:disabled) {
  background: #3c6e5c;
}

/* Floating Alerts in Battle View */
.battle-view #error:not(:empty), .battle-view #notice:not(:empty) {
  position: fixed;
  top: 32px;
  left: 285px;
  right: 5px;
  z-index: 55;
  font-size: 12px;
}

/* Responsive adjustments */
@media(max-width: 960px) {
  .battle-view #app {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .battle-view .own-mat .hand-strip .card {
    width: 68px !important;
    height: 96px !important;
    min-width: 68px !important;
  }
  .battle-view .own-mat {
    grid-template-rows: 108px 20px 118px;
    padding: 0 80px 4px;
  }
  .battle-view .opponent-mat {
    padding: 0 80px;
  }
  .battle-view .choice {
    left: 230px;
  }
}
@media(max-width: 700px) {
  .battle-view #app {
    grid-template-columns: 140px minmax(0, 1fr);
    grid-template-rows: 32px 58px minmax(0, 1fr);
  }
  .battle-view .own-mat {
    padding: 0 50px 4px;
  }
  .battle-view .opponent-mat {
    padding: 0 50px;
  }
  .battle-view .choice {
    left: 150px;
  }
}
/* Final table alignment: one header and a viewport-sized, proportionate playmat. */
body.battle-view{--battle-header-h:40px;height:100dvh;min-height:0;overflow:hidden}.battle-view>header{height:var(--battle-header-h);min-height:var(--battle-header-h);padding:3px 10px;flex-wrap:nowrap;gap:8px;overflow:hidden}.battle-view>header h1{flex-shrink:0;font-size:12px}.battle-view>header>a,.battle-view>header>#identity{display:none}.battle-view #connection{font-size:10px;white-space:nowrap}.battle-view #btn-card-back{font-size:10px;flex-shrink:0;padding:4px}.battle-room-tools{display:flex;align-items:center;gap:6px;flex:1;min-width:0}.battle-room-info{flex:1;min-width:0;display:flex;align-items:center;gap:8px;overflow:hidden}.battle-room-info h2{font-size:12px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.battle-room-info p{font-size:10px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.battle-room-tools>button{font-size:10px;padding:4px 8px;flex-shrink:0;white-space:nowrap}.battle-view #app{height:calc(100dvh - var(--battle-header-h));grid-template-columns:clamp(200px,20vw,280px) minmax(0,1fr);grid-template-rows:46px minmax(0,1fr);overflow:hidden}.battle-view .room-inspector{grid-row:1 / 3;min-height:0}.battle-view .room-status{grid-row:1;min-width:0;padding:3px 8px;gap:6px;overflow:hidden}.battle-view .room-status .status{font-size:11px;white-space:nowrap}.battle-view .phase-track{flex-shrink:1;min-width:0;gap:2px}.battle-view .phase-track span{font-size:9px;padding:2px 5px}.battle-view .room-status .turn-hint{font-size:9px;padding:3px 5px}.battle-view .room-status>button{min-width:0;font-size:11px;padding:5px 8px}.battle-view .duel-mat{grid-row:2;container-type:size;--slot-h:min(14cqh,calc((100cqw - 140px)/5),140px);--slot-w:calc(var(--slot-h)*.72);--hand-h:clamp(35px,17cqh,125px);--opp-hand-h:clamp(18px,6cqh,48px);display:grid!important;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) clamp(12px,3cqh,24px) minmax(0,1.25fr);align-items:stretch!important;justify-content:stretch!important;gap:0;padding:3px 6px;overflow:hidden}.battle-view :is(.own-mat,.opponent-mat){max-width:none;width:100%;height:100%;min-height:0;display:flex!important;justify-content:center!important;padding:0 64px!important;gap:2px!important;overflow:visible}.battle-view .ws-center-prompt{height:auto;min-height:0;max-width:none;padding:0 4px;font-size:clamp(8px,2cqh,14px);line-height:1.1;grid-row:auto!important}.battle-view .stage-cluster{position:relative;flex:0 0 auto;gap:0;margin:0;justify-content:center}.battle-view .stage{gap:3px!important;direction:ltr!important}.battle-view .stage-row{gap:4px}.battle-view .slot{width:var(--slot-w)!important;min-width:var(--slot-w)!important;max-width:var(--slot-w)!important;height:var(--slot-h)!important;min-height:var(--slot-h)!important;max-height:var(--slot-h)!important;grid-column:auto!important;margin:0!important}.battle-view .slot small{font-size:clamp(5px,1.2cqh,9px)!important;top:auto;bottom:1px;right:2px;left:auto}.battle-view .player-mat .stage .card{width:100%!important;min-width:0!important;max-width:100%!important;height:100%!important;min-height:0!important;max-height:100%!important;aspect-ratio:auto;padding:0}.battle-view .stage .card img{height:100%!important;width:100%!important;object-fit:contain!important}.battle-view .climax-slot{position:absolute;top:50%;transform:translateY(-50%);width:var(--slot-h)!important;min-width:var(--slot-h)!important;max-width:var(--slot-h)!important;height:var(--slot-w)!important;min-height:var(--slot-w)!important;max-height:var(--slot-w)!important}.battle-view .own-mat .climax-slot{right:calc(50% + var(--slot-w)*1.5 + 12px)}.battle-view .opponent-mat .climax-slot{left:calc(50% + var(--slot-w)*1.5 + 12px)}.battle-view .climax-slot .card{width:100%!important;min-width:0!important;max-width:100%!important;height:100%!important;min-height:0!important;max-height:100%!important}.battle-view .climax-slot .cx-label{font-size:clamp(6px,1.3cqh,11px)}.battle-view .player-mat h3{font-size:clamp(7px,1.4cqh,11px);max-width:100px;white-space:normal;left:2px;top:1px;padding:1px 3px}.battle-view .player-mat .counts{font-size:clamp(6px,1.4cqh,11px);line-height:1.1;margin:0;flex-shrink:0}.battle-view .opponent-mat .hand-strip{height:var(--opp-hand-h);min-height:0;flex-shrink:0;width:100%}.battle-view .opponent-mat .hand-strip summary{display:none!important}.battle-view .opponent-mat .hand-strip .cards{height:100%;width:100%;overflow:hidden;display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);max-width:280px;gap:2px}.battle-view .opponent-mat .hand-strip .card-back{height:100%;width:auto;min-width:0;max-width:36px;aspect-ratio:.72;justify-self:center}.battle-view .own-mat .hand-strip{height:var(--hand-h);min-height:0!important;max-height:var(--hand-h);max-width:none;width:calc(100% + 80px);padding:2px!important;flex-shrink:0;overflow:hidden}.battle-view .own-mat .hand-strip .cards{height:100%;width:100%;overflow:hidden;display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px;padding:1px;align-items:center}.battle-view .own-mat .hand-strip .card{height:100%!important;min-height:0!important;max-height:100%!important;width:100%!important;min-width:0!important;max-width:calc(var(--hand-h)*.72)!important;justify-self:center;margin:0!important}.battle-view .own-mat .hand-strip .card img{width:100%;height:100%;object-fit:contain}.battle-view .hand-strip .card .card-name{font-size:clamp(5px,1.3cqh,10px);line-height:1.1}.battle-view .card .card-stats{font-size:clamp(5px,1.2cqh,9px);line-height:1.1}.battle-view .ws-action-bar{margin:1px 0;gap:4px;min-height:0;flex-shrink:0;flex-wrap:nowrap}.battle-view .ws-action-bar :is(.ws-done-btn,.ws-cancel-btn){min-width:0;padding:3px 9px;font-size:clamp(8px,1.9cqh,14px);line-height:1.2;max-width:100%;white-space:normal}.battle-view .zone-dock{left:2px;top:20px;width:58px;gap:2px}.battle-view .zone-dock .zone summary{font-size:clamp(6px,1.4cqh,10px)!important;padding:2px!important;min-height:0;line-height:1.3}.battle-view .pile-dock{right:3px;top:18px;gap:5px}.battle-view .hidden-pile{width:50px;height:clamp(28px,10cqh,80px);min-height:0;padding:2px}.battle-view .hidden-pile span{font-size:8px}.battle-view .hidden-pile strong{font-size:clamp(12px,3cqh,23px)}.battle-view .hidden-pile small{display:none}.battle-view .choice{max-height:calc(100dvh - 90px);overflow:auto}.mobile-inspector-close{display:none}
@media(max-width:900px){.battle-view #app{grid-template-columns:minmax(0,1fr)}.battle-view .room-status,.battle-view .duel-mat{grid-column:1}.battle-view .room-inspector{display:none}.battle-view.battle-inspector-open .room-inspector{display:flex;position:fixed;left:8px;right:8px;top:var(--battle-header-h);bottom:8px;width:auto;height:auto;z-index:60;box-shadow:0 0 0 100vmax #0008}.battle-view .mobile-inspector-close{display:block;min-height:40px}.battle-view .choice{left:8px;right:8px;top:calc(var(--battle-header-h) + 50px)}.battle-view .zone-dock .zone[open]{left:8px;right:8px;top:calc(var(--battle-header-h) + 50px);max-height:calc(100dvh - var(--battle-header-h) - 65px)}.battle-view .room-card-detail .actions button{min-height:40px}}
@media(max-width:600px){body.battle-view{--battle-header-h:64px}.battle-view>header{flex-wrap:wrap;gap:2px 5px;padding:2px 6px;align-content:center}.battle-view>header h1{font-size:10px}.battle-view #connection{font-size:9px}.battle-view #btn-card-back{font-size:9px}.battle-room-tools{flex-basis:100%;gap:4px;height:28px}.battle-room-info{gap:4px}.battle-room-info h2{font-size:10px}.battle-room-info p{font-size:8px}.battle-room-tools>button{font-size:9px;padding:4px;min-height:26px}.battle-view #app{grid-template-rows:60px minmax(0,1fr)}.battle-view .room-status{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px;padding:2px 5px}.battle-view .phase-track{grid-column:1 / -1;justify-content:space-between}.battle-view .phase-track span{font-size:8px;padding:1px 3px}.battle-view .room-status .status{font-size:9px;overflow:hidden;text-overflow:ellipsis}.battle-view .room-status .turn-hint{display:none}.battle-view .room-status>button{font-size:9px;padding:4px}.battle-view :is(.own-mat,.opponent-mat){padding:0 47px!important}.battle-view .zone-dock{width:40px;top:18px}.battle-view .hidden-pile{width:36px}.battle-view .player-mat h3{max-width:90px}.battle-view .pile-dock{display:flex}.battle-view .own-mat .hand-strip{width:calc(100% + 78px)}}
/* details elements have an anonymous content box: use explicit tray dimensions. */
.battle-view .own-mat .hand-strip{display:block}.battle-view .own-mat .hand-strip .cards{height:calc(var(--hand-h) - 8px)!important;grid-template-rows:minmax(0,1fr);width:100%!important}.battle-view .own-mat .hand-strip .card{height:calc(var(--hand-h) - 12px)!important}.battle-view .opponent-mat .hand-strip{display:block}.battle-view .opponent-mat .hand-strip .cards{height:var(--opp-hand-h)!important;width:min(100%,280px)!important;margin:auto;grid-template-rows:minmax(0,1fr)}
@media(max-height:500px){.battle-view .duel-mat{--slot-h:min(12cqh,calc((100cqw - 140px)/5),140px)}}
