/* v38: three-column battle stage with isolated log and overflow-safe rows. */
body:has(#gameScreen:not(.hidden)) { overflow: hidden; }
#gameScreen.game-screen {
  width: min(1840px, 100%);
  height: 100dvh;
  min-height: 0;
  grid-template-columns: 220px minmax(0, 1fr) 330px;
  grid-template-rows: minmax(0, 1fr) 282px;
  align-items: stretch;
  gap: 16px 18px;
  padding: 10px 18px 12px;
  overflow: hidden;
}

#gameScreen .game-main { grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); align-self: stretch; overflow: hidden; }
#gameScreen .game-header { margin: 0; align-self: start; }
#gameScreen .game-main .board-shell { align-self: center; justify-self: center; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; overflow: hidden; }
#gameScreen .battle-hud { grid-column: 3; grid-row: 1; align-self: center; display: grid; justify-items: stretch; gap: 9px; min-width: 0; max-height: 100%; }
#gameScreen .round-status { display: block; padding: 10px 12px; border: 1px solid #304b5a; background: #0b1822d9; color: #bdd0d8; text-align: center; font-size: 14px; line-height: 1.5; }
#gameScreen .sidebar { display: flex; grid-template-columns: none; gap: 9px; min-height: 0; }
#gameScreen > .side-activity { grid-column: 1; grid-row: 1; align-self: center; width: 100%; max-height: calc(100% - 20px); padding: 0; overflow: hidden; display: grid; grid-template-rows: minmax(54px,auto) minmax(0,1fr); }
#gameScreen > .side-activity.hidden { display: none !important; }
#gameScreen .side-activity .battle-log { border: 0; border-radius: 0; max-height: min(34vh,300px); overflow: hidden; }
#gameScreen .side-activity .battle-log[open] ol { max-height: min(25vh,220px); overflow: auto; }
#gameScreen .side-activity .room-chat { min-height: 0; padding: 14px; border: 0; border-top: 1px solid #30495a; background: transparent; overflow: hidden; display: grid; grid-template-rows: auto minmax(80px,1fr) auto; }
#gameScreen .side-activity .room-chat.hidden { display: none; }
#gameScreen .side-activity .chat-messages { min-height: 0; max-height: none; overflow-y: auto; }
#gameScreen .side-activity .room-chat form { grid-template-columns: minmax(0,1fr) auto; }
#gameScreen > .hand-dock { position: relative; z-index: 12; grid-column: 1 / -1; grid-row: 2; min-height: 0; margin-top: 0; padding: 12px 16px 10px; overflow: hidden; background: linear-gradient(180deg,#101f2bfa,#08131c); }
#gameScreen .board-shell { padding: 12px; }
#gameScreen .board { --cell: var(--board-cell, 68px); }
#gameScreen, #gameScreen * { scrollbar-width: none; }
#gameScreen::-webkit-scrollbar, #gameScreen *::-webkit-scrollbar { display: none; }

#gameScreen .hand-dock .hand {
  display: flex !important;
  flex-flow: row nowrap !important;
  justify-content: center !important;
  align-items: flex-end !important;
  gap: 10px !important;
  min-height: 228px !important;
  padding: 10px 0 0 !important;
  overflow: hidden !important;
}

#gameScreen .hand-dock .hand > button.game-card,
#gameScreen .hand-dock .hand > button.game-card:first-of-type {
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 164px !important;
  height: auto !important;
  aspect-ratio: 5 / 7 !important;
  margin: 0 !important;
  padding: 52px 12px 12px !important;
  transform: none !important;
  translate: none !important;
  align-self: flex-end !important;
  grid-row: auto !important;
  grid-column: auto !important;
}

#gameScreen .hand-dock .game-card .card-art { width: 46px; height: 36px; font-size: 24px; }
#gameScreen .hand-dock .game-card .card-type { top: 39px; font-size: 10px !important; }
#gameScreen .hand-dock .game-card b { font-size: 18px; margin-bottom: 8px; padding-bottom: 7px; }
#gameScreen .hand-dock .game-card .card-rule { font-size: 12px !important; line-height: 1.45 !important; }
#gameScreen .hand-dock .game-card .mana { width: 32px; height: 32px; font-size: 17px !important; }

#gameScreen .hand-dock .hand > button.game-card:hover:not(:disabled) {
  transform: translateY(-7px) !important;
  margin: 0 !important;
}

.energy-panel {
  display: grid;
  place-items: center;
  padding: 13px;
  overflow: visible;
}

.battle-hud .energy-panel { width: 100%; padding: 12px 8px 28px; background: #0b1822cc; overflow: visible; }

/* v40: energy and roster are one contained turn-status card. */
#gameScreen .battle-hud { overflow: hidden; }
#gameScreen .energy-roster { padding: 0 14px 14px; overflow: hidden; }
#gameScreen .energy-roster .energy-panel { width: 100%; min-height: 172px; padding: 12px 8px 54px; background: transparent; overflow: visible; }
#gameScreen .energy-roster .players { display: grid; grid-template-columns: 1fr; gap: 8px; }
#gameScreen .energy-roster .players > div { position: relative; transition: border-color .2s, background .2s, box-shadow .2s, transform .2s; }
#gameScreen .energy-roster .players > div.active-turn { transform: translateX(-2px); }
#gameScreen .energy-roster .players > div:first-child.active-turn { border-color: #58e6d2; background: linear-gradient(90deg,#123d3d,#09141d 76%); box-shadow: inset 4px 0 #58e6d2,0 0 18px #58e6d238; animation: blue-turn-glow 1.6s ease-in-out infinite; }
#gameScreen .energy-roster .players > div:last-child.active-turn { border-color: #ff756c; background: linear-gradient(90deg,#431f25,#09141d 76%); box-shadow: inset 4px 0 #ff756c,0 0 18px #ff756c38; animation: red-turn-glow 1.6s ease-in-out infinite; }
#gameScreen .energy-roster .players > div.active-turn::after { content: "行动中"; position: absolute; right: 9px; bottom: 7px; color: #f4f1e8; font-size: 10px; letter-spacing: .08em; }
@keyframes blue-turn-glow { 0%,100% { box-shadow: inset 4px 0 #58e6d2,0 0 10px #58e6d225; } 50% { box-shadow: inset 4px 0 #58e6d2,0 0 22px #58e6d255; } }
@keyframes red-turn-glow { 0%,100% { box-shadow: inset 4px 0 #ff756c,0 0 10px #ff756c25; } 50% { box-shadow: inset 4px 0 #ff756c,0 0 22px #ff756c55; } }

/* v41: target selection only shows its relevant cancel control. */
.phase-actions:has(#cancelItem:not(.hidden)) #endMove { display: none !important; }

/* v45: recoverable end-of-match controls and synchronized result display. */
#gameScreen .match-exit{position:fixed;left:18px;top:16px;z-index:26;padding:10px 15px;border-color:#466776;background:#0b1922e8;box-shadow:0 8px 24px #0007;backdrop-filter:blur(8px)}
.result-card{position:relative}.result-close{position:absolute;right:13px;top:10px;width:38px;height:38px;border:0;background:transparent;color:#a9bec7;font-size:30px;line-height:1;cursor:pointer}.result-close:hover,.result-close:focus-visible{color:#f1ca68}.result-close:focus-visible{outline:2px solid #69d7c7;outline-offset:2px}
@media(max-width:700px){#gameScreen .match-exit{left:10px;top:10px;padding:8px 11px;font-size:13px}}

/* v43: unified administrator console. */
.admin-screen{min-height:100vh;overflow:auto}.admin-screen main{max-width:1320px;margin:28px auto 70px;padding:0 24px;display:grid;gap:24px}.admin-section{padding:24px;border:1px solid #2d4a58;background:linear-gradient(145deg,#0c1d28,#08131c);box-shadow:0 18px 50px #0005}.admin-section>header{margin-bottom:18px}.admin-section>header small{color:#65d7c7;letter-spacing:.18em}.admin-section h2{margin:4px 0;font:700 27px Georgia,"Songti SC",serif}.admin-section>header p{margin:6px 0 0;color:#87a1ac}.admin-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.admin-summary article{padding:18px;border:1px solid #31515e;background:#07151e}.admin-summary small,.admin-summary span{display:block;color:#86a0aa}.admin-summary strong{display:block;margin:8px 0;color:#f0ca6d;font:800 38px/1 Georgia,serif}.admin-table-wrap{overflow-x:auto}.card-stats-table{width:100%;border-collapse:collapse;min-width:720px}.card-stats-table th,.card-stats-table td{padding:12px 14px;border-bottom:1px solid #243e49;text-align:right}.card-stats-table th{color:#88a4ae;font-weight:500}.card-stats-table th:first-child,.card-stats-table td:first-child{text-align:left}.card-stats-table td:first-child{display:flex;align-items:center;gap:10px}.card-stats-table td i{width:30px;height:30px;display:grid;place-items:center;border:1px solid #3f6b73;background:#07141d;color:#69dfcf;font-style:normal}.card-stats-table tbody tr:hover{background:#102630}.admin-section .account-table article{background:#07151e}@media(max-width:900px){.admin-summary{grid-template-columns:repeat(2,1fr)}}@media(max-width:560px){.admin-summary{grid-template-columns:1fr}.admin-screen main{padding:0 12px}.admin-section{padding:16px}}

.energy-panel #moveCount {
  position: relative;
  width: 108px;
  height: 108px;
  border: 2px solid #efc45d;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #f4d784, #b87e24 68%, #5e3612);
  color: #071019;
  display: grid;
  place-content: center;
  text-align: center;
  box-shadow: 0 0 0 6px #e9bd5430, 0 10px 28px #0008;
}

.energy-panel #moveCount > span { font: 800 45px/1 Georgia, serif; }
.energy-panel #moveCount > small { margin-top: 3px; color: #15130f; font-size: 11px; letter-spacing: .04em; }
.energy-panel #moveCount em { position: absolute; left: 50%; top: calc(100% + 13px); transform: translateX(-50%); min-width: 126px; padding: 7px 12px; border: 1px solid #50dfcb; border-radius: 999px; background: #0a2f32; color: #c8fff6; display: flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; box-shadow: 0 0 18px #43dcca42; font-style: normal; animation: free-move-glow 1.4s ease-in-out infinite; }
.energy-panel #moveCount em b { color: #69f0dd; font: 800 24px/1 Georgia, serif; }
.energy-panel #moveCount em i { color: #d8fffa; font-style: normal; font-size: 12px; font-weight: 700; }
@keyframes free-move-glow { 0%,100% { box-shadow: 0 0 12px #43dcca28; } 50% { box-shadow: 0 0 25px #43dcca80; } }
.energy-panel #moveCount.cost-preview { animation: energy-cost-preview .8s ease-in-out infinite; }
.energy-panel #moveCount.cost-preview::after {
  content: var(--preview-cost);
  position: absolute;
  right: -15px;
  top: -9px;
  min-width: 31px;
  height: 31px;
  padding: 0 5px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #7c2828;
  color: #ffe1c3;
  border: 1px solid #ff997a;
  font: 800 15px Georgia, serif;
  box-shadow: 0 0 18px #ff6a4f;
}

@keyframes energy-cost-preview {
  0%, 100% { box-shadow: 0 0 0 6px #e9bd5430, 0 10px 28px #0008; }
  50% { box-shadow: 0 0 0 10px #ff79584d, 0 0 28px #ff765c, 0 10px 28px #0008; }
}

.status .phase-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.status .phase-actions #endMove {
  order: 1;
  width: min(230px, 100%);
  min-height: 52px;
  font-size: 18px;
}

.status .phase-actions #cancelItem { order: 2; width: min(230px, 100%); }

@media (max-width: 1200px) {
  #gameScreen.game-screen { grid-template-columns: 170px minmax(0, 1fr) 285px; grid-template-rows: minmax(0,1fr) 242px; gap: 7px; }
  #gameScreen .board { --cell: var(--board-cell, 58px); }
  #gameScreen .hand-dock .hand { gap: 6px !important; min-height: 198px !important; }
  #gameScreen .hand-dock .hand > button.game-card,
  #gameScreen .hand-dock .hand > button.game-card:first-of-type {
    max-width: 138px !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
  .energy-panel #moveCount { width: 96px; height: 96px; }
  .energy-panel #moveCount > span { font-size: 40px; }
}

@media (max-width: 900px) {
  body:has(#gameScreen:not(.hidden)) { overflow: auto; }
  #gameScreen.game-screen { height: auto; min-height: 100vh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; overflow: visible; }
  #gameScreen .game-main { grid-column: 1; grid-row: 1; }
  #gameScreen .battle-hud { grid-column: 1; grid-row: 2; width: 100%; }
  #gameScreen > .side-activity { grid-column: 1; grid-row: 3; }
  #gameScreen > .hand-dock { grid-column: 1; grid-row: 4; }
}

/* v46: private board information and the new prediction/terrain interactions. */
.cell .hazard.mist{position:absolute;inset:13%;z-index:2;border:1px solid #93aeb8aa;border-radius:50%;background:radial-gradient(circle,#d6eef055 0 18%,#9ab5bd36 42%,transparent 72%);filter:blur(.4px);box-shadow:0 0 18px #d9f6ff42;pointer-events:none;animation:mist-drift 2.4s ease-in-out infinite}
.cell .hazard.trap{position:absolute;left:50%;top:50%;z-index:3;width:48%;height:48%;transform:translate(-50%,-50%) rotate(45deg);border:2px dashed #c483ff;border-radius:8px;background:#7a3aae36;pointer-events:none}
.cell .owned-secret,.cell .concealed-wall,.cell .token.concealed-self{opacity:.52;filter:blur(.45px) saturate(.75);animation:secret-ghost 1.8s ease-in-out infinite}
.cell.prophesied{box-shadow:inset 0 0 0 2px #55bfff,inset 0 0 18px #3aaaff66,0 0 12px #3aaaff55;animation:prophecy-cell-pulse 1.4s ease-in-out infinite}
.cell.target.occupied-target:hover{transform:none}.cell.target.occupied-target:after{position:absolute;left:50%;top:50%;right:auto;bottom:auto;width:8px;height:8px;z-index:8;transform:translate(-50%,-50%);pointer-events:none}

/* v50: private pile inspection and log-free battle activity. */
#gameScreen .side-activity{grid-template-rows:minmax(0,1fr)}
#gameScreen .side-activity .room-chat{border-top:0}
#gameScreen .pile-stats button{padding:3px 8px;border:1px solid #365363;border-radius:999px;background:#0a1923;color:#9db6c1;font:inherit;cursor:pointer;transition:.15s}
#gameScreen .pile-stats button:hover,#gameScreen .pile-stats button:focus-visible{border-color:#58d9c7;color:#d7fff8;background:#12303a}
.pile-viewer{position:fixed;inset:0;z-index:90;display:grid;place-items:center;padding:20px;background:#02070bd9;backdrop-filter:blur(9px)}
.pile-viewer>article{position:relative;width:min(680px,100%);max-height:min(78vh,720px);padding:28px;border:1px solid #466675;background:linear-gradient(145deg,#102431,#08131c);box-shadow:0 28px 90px #000;overflow:auto}
.pile-viewer>article>small{color:#67d9c9;letter-spacing:.16em}.pile-viewer h2{margin:6px 0;font:700 28px Georgia,"Songti SC",serif}.pile-viewer>article>p{margin:0 0 18px;color:#8fa8b3}
.pile-viewer-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.pile-entry{--card-emblem:#58d9c7;display:grid;grid-template-columns:44px 1fr auto;align-items:center;gap:11px;padding:11px;border:1px solid color-mix(in srgb,var(--card-emblem) 38%,#2a4351);background:linear-gradient(var(--card-angle,145deg),color-mix(in srgb,var(--card-emblem) 12%,transparent),transparent 55%),#091720}.pile-entry>i{width:42px;height:42px;display:grid;place-items:center;border:1px solid color-mix(in srgb,var(--card-emblem) 55%,transparent);color:var(--card-emblem);font:700 23px Georgia;font-style:normal}.pile-entry b,.pile-entry small{display:block}.pile-entry small{margin-top:3px;color:#87a1ad}.pile-entry strong{color:#f1ca70;font-size:18px}.pile-empty{grid-column:1/-1;padding:34px;text-align:center;color:#839ba6;border:1px dashed #35505e}
@media(max-width:600px){.pile-viewer-grid{grid-template-columns:1fr}.pile-viewer>article{padding:22px 16px}}
.cell .wall.concealed-wall{background:linear-gradient(90deg,#7de9db66,#f6df8a88,#7de9db66);border-style:dashed;box-shadow:0 0 12px #65dac69c}
.cell .wall.destroy-target{z-index:12;cursor:pointer;background:#ff745f!important;box-shadow:0 0 13px #ff4c38,0 0 24px #ff4c3877!important;pointer-events:auto;animation:destroy-wall-pulse 1s ease-in-out infinite}
@keyframes secret-ghost{0%,100%{opacity:.42}50%{opacity:.68}}
@keyframes prophecy-cell-pulse{0%,100%{filter:brightness(.95)}50%{filter:brightness(1.18)}}
@keyframes mist-drift{0%,100%{transform:translate(-2%,1%) scale(.94)}50%{transform:translate(2%,-1%) scale(1.04)}}
@keyframes destroy-wall-pulse{0%,100%{filter:brightness(.9)}50%{filter:brightness(1.4)}}
