/* Approved v7 board composition. Only gameplay surfaces are scoped here;
   deck builder, collection, dialogs and history event cards keep their own styles. */
.game-container {
  --board-card-width: 194px;
  --board-card-height: clamp(185px, calc((100dvh - 238px) / 3), 264px);
  --board-copy: 13px;
  --board-title: 14px;
  --board-stat: 16px;
  --board-art: 56%;
  font-family: system-ui, sans-serif;
  color: #e4eeea;
  background: radial-gradient(ellipse at 45% 45%, #24464b, #0b2029 85%);
  padding: calc(48px + env(safe-area-inset-top, 0px)) 18px env(safe-area-inset-bottom, 0px) 24px;
}
.game-container .top-bar {
  display: none;
}
.game-container .page.active {
  transform: none;
}
.game-container .pages-container {
  padding: 0;
  min-height: 0;
}
.game-container .battlefield-layout-two-column {
  grid-template-columns: minmax(0, 1fr) clamp(290px, 23vw, 360px);
  gap: 18px;
  min-height: 0;
}
.game-container .battlefield-center-column {
  overflow: auto;
  gap: 0;
}
.game-container .battlefield-layout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: space-between;
  overflow: visible;
  min-height: 770px;
}
.game-container .top-utilities {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(48px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 110px 0 24px;
  gap: 24px;
  align-items: center;
  justify-content: flex-end;
  background: #0c2029;
  border-bottom: 1px solid #81978a33;
  z-index: 20;
}
.board-brand {
  margin-right: auto;
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #b8ccc2;
}
.game-container .util-history-btn {
  display: block;
  width: auto;
  height: 44px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: #e4eeea;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.game-container .scoreboard-row {
  margin: 0;
  padding: 0;
  min-height: 44px;
  background: none;
  border: 0;
}
.game-container .player-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: none;
  min-height: 44px;
  padding: 0 8px;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  flex: 1;
}
.game-container .player-name {
  font:
    650 14px/1.2 system-ui,
    sans-serif;
  text-transform: none;
  color: #e4eeea;
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-container .scoreboard-stats {
  display: contents;
}
.game-container [id$='-deck'] {
  order: 1;
  color: #adbfbb;
  font-size: 12px;
}
.game-container [id$='-hp'] {
  order: 4;
  margin-left: auto;
  color: #ecc2bc;
  font-size: 24px;
  font-weight: 700;
}
.game-container .opponent-hand-cards {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  flex: none;
  gap: 3px;
  height: 28px;
  justify-content: center;
}
.game-container .opponent-hand-cards .card-back {
  width: 20px;
  height: 28px;
  margin: 0;
  font-size: 0;
  border: 1px solid #81998c;
  background: repeating-linear-gradient(55deg, #28434b, #28434b 4px, #344d52 5px, #344d52 6px);
  border-radius: 3px;
  box-shadow: none;
}
.game-container .opponent-hand-cards .card-back > * {
  opacity: 0;
}
.game-container .emote-toggle {
  order: 5;
}
.game-container .battlefield-region {
  flex: none;
}
.game-container .battlefield {
  gap: 6px;
}
.game-container .field-row {
  flex: none;
  height: var(--board-card-height);
  gap: 22px;
  padding: 0 12px;
}
.game-container .field-slot {
  padding: 0;
  border: 1px solid #81998c30;
  background: #28494b22;
  border-radius: 16px;
}
.game-container .empty-field-slot {
  font-size: 0;
}
.game-container .empty-field-slot::after {
  content: '◇';
  font-size: 38px;
  color: #78938740;
}
.game-container .field-divider {
  min-height: 32px;
  height: 32px;
  padding: 0;
  border-block: 1px solid #81998c33;
  justify-content: center;
}
.game-container .field-divider-text {
  display: none;
}
.game-container .field-controls {
  position: static;
  transform: none;
  gap: 10px;
}
.game-container .field-turn-btn {
  border: 1px solid #a9b790;
  background: #63776088;
  border-radius: 7px;
  padding: 5px 14px;
  height: 30px;
  font:
    500 12px system-ui,
    sans-serif;
  box-shadow: none;
  color: #edf1e7;
}
.game-container .field-turn-number,
.game-container .field-phase-label {
  font: inherit;
}
.game-container .field-resync-btn,
.game-container .field-surrender-btn {
  width: 28px;
  height: 28px;
  font-size: 15px;
}
.game-container .own-control-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 0;
  flex-wrap: nowrap;
  position: relative;
}
.game-container .own-control-row .piles-section {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
  width: auto;
  margin: 0;
  min-height: 0;
}
.game-container .piles-grid {
  display: flex;
  gap: 4px;
}
.game-container .own-control-row .pile-item {
  min-width: 0;
  padding: 6px;
  gap: 4px;
  font:
    11px system-ui,
    sans-serif;
  background: #18343b;
  border: 1px solid #81998c55;
  border-radius: 7px;
}
.game-container .own-control-row .piles-grid {
  display: flex;
  width: auto;
}
.game-container .own-control-row .pile-item {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.game-container .pile-item > span {
  font: inherit;
}
.game-container .pile-item strong {
  font-size: 12px;
}
.board-diagnostics {
  position: relative;
}
.board-diagnostics summary {
  list-style: none;
  cursor: pointer;
  padding: 8px;
}
.game-container .board-diagnostics .advantage-display {
  display: flex;
  position: absolute;
  z-index: 30;
  bottom: 35px;
  right: 0;
  width: 190px;
  min-height: 70px;
  background: #16313a;
  border: 1px solid #81998c;
  padding: 12px;
}
.game-container .board-diagnostics .advantage-graph-container {
  position: absolute;
  bottom: 105px;
  right: 0;
  z-index: 30;
  background: #16313a;
}
.game-container .hand-panel {
  flex: none;
  height: calc(var(--board-card-height) + 30px);
  min-height: 0;
  padding: 8px 20px 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}
.game-container .hand-container {
  min-height: 0;
}
.game-container .hand-grid {
  align-items: flex-start;
  padding: 0;
  gap: 4px;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card {
  width: var(--board-card-width);
  height: var(--board-card-height);
  min-height: var(--board-card-height);
  max-height: none;
  max-width: 100%;
  aspect-ratio: auto;
  border: 2px solid #82968a;
  border-radius: 10px;
  background: #28434d;
  box-shadow: 0 4px 9px #0005;
  animation: none;
}
.game-container .hand-grid .card {
  transform: translateY(var(--card-offset-y, 0px)) rotate(var(--card-rotation, 0deg));
}
.game-container .hand-grid .card.hand-focus {
  transform: translateY(-35px) scale(1.15) rotate(0deg);
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card::before {
  display: block;
  z-index: 3;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-inner {
  display: flex;
  height: 100%;
  padding: 0;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-name {
  flex: 0 0 auto;
  padding: 4px 2px;
  min-height: 23px;
  background: #193640;
  color: #e4eeea;
  text-shadow: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-name-text {
  font:
    650 var(--board-title)/1.1 system-ui,
    sans-serif;
  max-height: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-image-container {
  flex: 0 0 var(--board-art);
  min-height: 38px;
  background: #102b33;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-image {
  object-fit: contain;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-content-area {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-stats-row {
  flex: 0 0 23px;
  min-height: 23px;
  max-height: none;
  background: #19343e;
  border-block: 1px solid #8ca69b22;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-stats-text {
  font:
    700 var(--board-stat)/1.2 system-ui,
    sans-serif;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .stat-atk {
  color: #e4d8ad;
  order: 0;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .stat-nut {
  color: #bdd4a4;
  order: 1;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .stat-hp {
  color: #e7c5c4;
  order: 2;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .hp-buffed {
  color: #7ee89d;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .hp-damaged {
  color: #ff8884;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-keywords:empty {
  display: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-keywords-text {
  font:
    650 var(--board-copy)/1.2 system-ui,
    sans-serif;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-effect {
  flex: 1 1 auto;
  height: auto;
  align-items: flex-start;
  padding: 4px 5px;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-effect-text {
  font:
    400 var(--board-copy)/1.2 system-ui,
    sans-serif;
  max-height: 100%;
  width: 100%;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-status {
  font-size: 14px;
}
.game-container .game-log-panel {
  background: #102730;
  border: 1px solid #73877455;
  box-shadow: none;
  border-radius: 10px;
  padding: 12px;
}
.game-container .log-header h3 {
  font:
    500 14px system-ui,
    sans-serif;
  color: #bbccc3;
}
.game-container .log-entry {
  background: #27414a66;
  border-color: #82968a;
}
.game-container .mobile-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-container .battlefield-right-column {
  padding-top: 8px;
}
.game-container .battlefield-layout-two-column.history-hidden {
  grid-template-columns: minmax(0, 1fr);
}
.game-container .history-hidden .battlefield-right-column {
  display: none;
}
/* The existing settings menu now occupies the approved top utility position. */
.settings-button-container {
  top: env(safe-area-inset-top, 0px);
  right: 18px;
  bottom: auto;
  flex-direction: column-reverse;
}
.settings-fab {
  width: auto;
  height: 46px;
  gap: 7px;
  padding: 0 10px;
  font:
    13px system-ui,
    sans-serif;
  color: #e4eeea;
  background: none;
  box-shadow: none;
  border-radius: 4px;
}
.settings-fab-icon {
  font-size: 18px;
}
.settings-fab.active,
.settings-fab:hover {
  transform: none;
  box-shadow: none;
  background: #34534b;
}
.settings-menu {
  padding: 8px;
  background: #102730;
  border: 1px solid #73877455;
  border-radius: 8px;
}
@media (min-width: 768px) {
  .game-container .own-control-row .piles-section {
    position: fixed;
    left: auto;
    right: 130px;
    top: env(safe-area-inset-top, 0px);
    height: 48px;
    transform: none;
    z-index: 25;
  }
  .game-container .top-utilities {
    padding-right: 365px;
  }
  .game-container .board-diagnostics .advantage-display {
    top: 45px;
    bottom: auto;
  }
  .game-container .board-diagnostics .advantage-graph-container {
    top: 115px;
    bottom: auto;
  }
}
@media (max-width: 767px) and (orientation: portrait) {
  .game-container {
    --board-card-width: calc((100vw - 36px) / 3);
    --board-card-height: 185px;
    --board-copy: 10.5px;
    --board-title: 10.5px;
    --board-stat: 14px;
    --board-art: 45%;
    padding: calc(44px + env(safe-area-inset-top, 0px)) 9px
      max(8px, env(safe-area-inset-bottom, 0px));
  }
  .game-container .battlefield-layout-two-column {
    display: block;
    overflow: visible;
  }
  .game-container .battlefield-layout {
    min-height: 704px;
    height: 100%;
    gap: 6px;
    justify-content: space-between;
  }
  .game-container .battlefield-center-column {
    height: 100%;
    overflow: auto;
  }
  .game-container .top-utilities {
    height: calc(44px + env(safe-area-inset-top, 0px));
    padding-inline: 9px 105px;
    justify-content: flex-start;
  }
  .board-brand {
    display: none;
  }
  .game-container .util-history-btn {
    font-size: 14px;
  }
  .game-container .player-badge {
    padding: 0 3px;
    gap: 4px;
  }
  .game-container .player-name {
    font-size: 12px;
    max-width: 29%;
  }
  .game-container [id$='-deck'] {
    font-size: 10px;
  }
  .game-container [id$='-hp'] {
    font-size: 20px;
  }
  .game-container .opponent-hand-cards {
    gap: 2px;
  }
  .game-container .opponent-hand-cards .card-back {
    width: 12px;
    height: 19px;
  }
  .game-container .field-row {
    gap: 8px;
    padding: 0;
  }
  .game-container .field-slot {
    border-radius: 10px;
  }
  .game-container .field-divider {
    margin-block: 12px;
    justify-content: flex-end;
  }
  .game-container .field-controls {
    gap: 4px;
  }
  .game-container .own-control-row .pile-item {
    padding: 6px 4px;
    font-size: 10px;
  }
  .game-container .hand-panel {
    height: calc(var(--board-card-height) + 28px);
    padding: 2px 0 10px;
  }
  .game-container .hand-grid {
    flex: none;
    height: 100%;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    /* Room for the rotated outer corners, not a clipped horizontal carousel. */
    padding: 6px 10px 12px;
    overflow: visible;
  }
  .game-container .hand-grid .card {
    margin: 0 0 0 calc(-1 * var(--hand-overlap, 10px));
    flex: 0 0 var(--board-card-width);
    transform: translateY(var(--card-offset-y, 0px)) rotate(calc(var(--card-rotation, 0deg) * 0.5));
  }
  .game-container .hand-grid .card:first-child {
    margin-left: 0;
  }
  .game-container .hand-grid .card:hover:not(.hand-focus) {
    transform: translateY(var(--card-offset-y, 0px)) rotate(calc(var(--card-rotation, 0deg) * 0.5));
  }
  .game-container .hand-grid .card.hand-focus:not(.dragging) {
    position: fixed;
    margin: 0;
    left: 50%;
    top: 50%;
    width: min(72vw, 280px);
    height: 430px;
    max-width: none;
    transform: translate(-50%, -50%);
    z-index: 2000;
    --board-copy: 16px;
    --board-title: 17px;
    --board-stat: 20px;
    box-shadow: 0 15px 80px #000b;
  }
  .game-container .battlefield-right-column {
    display: none;
    position: fixed;
    left: auto;
    right: 0;
    top: calc(44px + env(safe-area-inset-top, 0px));
    width: min(324px, calc(100vw - 32px));
    height: calc(100dvh - 44px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    background: #102730;
    padding: 0;
    z-index: 3000;
  }
  .game-container .show-history .battlefield-right-column {
    display: flex;
  }
  .game-container .game-log-panel {
    border-radius: 8px 0 0 8px;
  }
  .settings-button-container {
    right: 8px;
  }
  .settings-fab {
    height: 44px;
    font-size: 14px;
  }
}

/* Readable state decoration, without the legacy all-over yellow wash. */
.game-container .player-badge.is-active {
  box-shadow: none;
  animation: none;
}
.game-container .player-badge.is-active .player-name {
  animation: none;
}
.game-container .field-turn-btn {
  animation: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .barrier-overlay {
  border: 2px solid #efd48c;
  border-radius: 9px;
  background: radial-gradient(ellipse at 30% 5%, #fff6c730, transparent 40%);
  box-shadow: inset 0 0 13px #f6d37788;
  animation: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .barrier-overlay::before,
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .barrier-overlay::after {
  display: none;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .card-status {
  top: 26px;
  right: 3px;
}
.card-stat-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.game-container .field-divider-text {
  display: block;
  color: #c4d6c7;
  font:
    12px system-ui,
    sans-serif;
}
.game-container .field-divider {
  gap: 24px;
}
.game-container .field-controls {
  right: auto;
  top: auto;
}
@media (max-width: 767px) and (orientation: portrait) {
  .game-container .field-divider {
    justify-content: space-between;
    gap: 8px;
  }
  .game-container .field-divider-text {
    font-size: 11px;
  }
}

.game-container .field-divider-text {
  flex: 0 1 auto;
  width: auto;
  margin: 0;
}
.game-container .field-controls {
  flex: 0 0 auto;
}
.game-container .field-turn-btn {
  white-space: nowrap;
}
.game-container .hand-panel:has(.hand-focus) {
  position: relative;
  z-index: 100;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .long-copy .card-image-container {
  flex-shrink: 1;
}
:is(.game-container .field-slot, .game-container .hand-grid, .modern-inspector) .long-copy .card-content-area {
  min-height: calc(var(--board-copy) * 8.5);
}

/* Structured history: art-led list and aligned event-time snapshots. */
.game-container .battlefield-right-column {
  min-height: 0;
}
.game-container .game-log-panel {
  position: relative;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: #102730;
  border: 1px solid #73877466;
  border-radius: 8px;
}
.game-container .game-log-panel .log-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 42px;
  padding: 5px 12px;
  background: #102730;
}
.game-container .game-log-panel .log-header h3 {
  font: 12px system-ui;
  color: #b6c8be;
}
.game-container #close-history {
  display: block;
  width: 30px;
  height: 30px;
  border: 1px solid #788a7a;
  border-radius: 6px;
  background: #233c42;
  color: #e3ece8;
}
.game-container #game-history-log.visual-history {
  display: grid;
  grid-template-rows: 46% 54%;
  height: 100%;
  overflow: hidden;
  padding: 0;
}
.history-events {
  overflow-y: auto;
  min-height: 0;
  padding: 44px 12px 10px;
  overscroll-behavior: contain;
}
.history-event {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 62px;
  margin: 0 0 3px;
  padding: 7px;
  border: 0;
  border-bottom: 1px solid #8c9d8622;
  border-radius: 7px;
  background: none;
  color: #d6c6a7;
  cursor: pointer;
}
.history-event[aria-pressed='true'] {
  background: #405c5688;
  box-shadow: inset 3px 0 #c0cca2;
}
.history-event:focus-visible,
.history-detail:focus-visible {
  outline: 2px solid #c0cca2;
  outline-offset: -2px;
}
.history-portrait {
  position: relative;
  overflow: hidden;
  min-width: 0;
  background: #18343e;
}
.history-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-event .history-portrait {
  flex: 1;
  max-width: 105px;
  height: 43px;
  border: 1px solid #637e70;
  border-radius: 4px;
}
.history-action {
  font-size: 21px;
  flex: 0 0 20px;
  text-align: center;
}
.history-turn {
  position: absolute;
  right: 7px;
  bottom: 7px;
  background: #10242dcf;
  color: #bdc9bc;
  font: 10px system-ui;
}
.history-placeholder,
.history-missing-art::after {
  display: grid;
  place-items: center;
  height: 100%;
  color: #8ea69d;
  font: 30px system-ui;
}
.history-missing-art::after {
  content: '◇';
}
.history-detail {
  overflow-y: auto;
  min-height: 0;
  padding: 12px 14px 16px;
  border-top: 1px solid #899b7e66;
  background: #1a333b;
  color: #dbe8e1;
  overscroll-behavior: contain;
  font: 12px/1.4 system-ui;
}
.history-moment {
  margin: 0 0 5px;
  color: #afc0b6;
}
.history-time-label {
  margin: 6px 0 4px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font: 10px system-ui;
  color: #afc0b6;
}
.history-duel {
  display: grid;
  grid-template-columns: repeat(var(--entities), minmax(0, 1fr));
  gap: 16px;
}
.history-tile {
  position: relative;
  min-width: 0;
  height: 106px;
  border: 1px solid #82998b;
  border-radius: 20px 20px 8px 8px;
  overflow: hidden;
  background: #142e36;
}
.history-tile .history-portrait {
  height: calc(100% - 25px);
}
.history-name {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  border-radius: 12px;
  background: #10242ed9;
  padding: 2px 3px;
  text-align: center;
  font: 600 9px/1.2 system-ui;
  overflow-wrap: anywhere;
}
.history-stats {
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
  padding: 0 3px;
  white-space: nowrap;
  font: 600 12px system-ui;
}
.history-stats > span {
  display: flex;
  align-items: center;
  gap: 2px;
}
.history-stats small {
  font-size: 9px;
}
.history-stat-icon {
  font-size: 11px;
}
.history-stats .gain {
  color: #8aefb3;
}
.history-stats .loss {
  color: #f39c95;
}
.history-terminal {
  position: absolute;
  bottom: 25px;
  left: 0;
  right: 0;
  background: #122d35df;
  color: #eac990;
  font: 9px/1.25 system-ui;
  text-transform: uppercase;
  text-align: center;
  padding: 2px;
}
.history-skull {
  position: absolute;
  top: 40%;
  left: 40%;
  font-size: 24px;
  color: #eee6d4;
  text-shadow: 0 1px 5px #000;
}
.history-barrier {
  border-color: #ddc987;
  box-shadow: inset 0 0 8px #efd87966;
}
.history-headline {
  text-align: center;
  margin: 10px 0 5px;
  font-weight: 600;
}
.history-description {
  text-align: center;
  color: #b9cdc0;
  font: 11px/1.4 system-ui;
}
.history-description p {
  margin: 3px 0;
}
.history-legacy,
.history-empty {
  font: 12px/1.5 system-ui;
  color: #afc0b6;
  padding: 8px;
}
.history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2990;
  border: 0;
  background: #06171e66;
}
.history-backdrop[hidden] {
  display: none;
}
@media (max-width: 767px) {
  .game-container #game-history-log.visual-history {
    grid-template-rows: 49% 51%;
  }
  .game-container .game-log-panel {
    width: 100%;
    border-radius: 0;
  }
  .history-duel {
    gap: 18px;
  }
  .history-tile {
    height: 106px;
  }
  .history-events {
    padding-left: 18px;
    padding-right: 18px;
  }
  .history-detail {
    padding: 12px 15px 16px;
  }
}
.history-stat-icon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.history-event > svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
}
.history-name {
  font-size: 10px;
}
.history-stats {
  font-size: 13px;
}
.history-description {
  font-size: 12px;
}

.history-duel.history-multi {
  grid-template-columns: repeat(var(--entities), minmax(130px, 1fr));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 5px;
}
.history-more {
  font: 11px system-ui;
  color: #c3d4c7;
}
@media (prefers-reduced-motion: reduce) {
  .game-container .battlefield-right-column {
    transition: none;
    animation: none;
  }
}

.game-container #game-history-log.visual-history {
  gap: 0;
  min-height: 0;
  box-sizing: border-box;
}
.history-barrier::after {
  content: '🛡';
  position: absolute;
  right: 5px;
  top: 30px;
  color: #edd897;
}

/* Two-digit values/deltas wrap as complete stat groups, never clip or shrink type. */
.history-dense .history-tile { height:124px; }
.history-dense .history-tile .history-portrait { height:calc(100% - 43px); }
.history-dense .history-stats { height:43px; flex-wrap:wrap; column-gap:8px; align-content:center; }
.history-dense .history-terminal { bottom:43px; }

/* Browser-content height is the budget, including visible Safari bars (dvh).
   Only card text, inspector details and history panes scroll, never the arena. */
.game-container {
  --board-card-height: clamp(90px, calc((100dvh - 202px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) / 3), 264px);
}
.game-container .battlefield-center-column { overflow: visible; }
.game-container .battlefield-layout { min-height: 0; height: 100%; gap: 4px; }
.game-container .scoreboard-row, .game-container .own-control-row { min-height: 36px; height: 36px; flex: 0 0 36px; }
.game-container .player-badge { min-height: 36px; }
.game-container .battlefield-region { flex: 1 1 0; min-height: 0; }
.game-container .battlefield { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 30px minmax(0, 1fr); gap: 4px; }
.game-container .field-row { height: 100%; min-height: 0; }
.game-container .field-slot { min-height: 0; }
.game-container .field-slot .card { height: 100%; min-height: 0; max-height: 100%; }
.game-container .field-divider { margin: 0; height: 30px; min-height: 30px; }
.game-container .hand-panel { height: calc(var(--board-card-height) + 18px); min-height: 0; flex: 0 0 calc(var(--board-card-height) + 18px); padding: 0; }
.game-container .hand-container { height: 100%; min-height: 0; }
.game-container .hand-grid { padding-top: 5px; padding-bottom: 8px; min-height: 0; }
.game-container .field-slot .card-name { padding-top: 6px; }
/* Explicit scrolling tracks avoid Safari min-content grid expansion. */
.game-container #game-history-log.visual-history { grid-template-rows: minmax(0, 46fr) minmax(0, 54fr); flex: 1 1 0; }
.game-container .game-log-panel { min-height: 0; max-height: 100%; }
.history-events, .history-detail { min-height: 0; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.history-event { flex-shrink: 0; touch-action: pan-y; }
@media (max-width: 767px) and (orientation: portrait) {
  .game-container .hand-grid .card.hand-focus:not(.dragging) {
    position: relative; left: auto; top: auto;
    margin: 0 0 0 calc(-1 * var(--hand-overlap, 10px));
    width: var(--board-card-width); height: var(--board-card-height);
    transform: translate(var(--focus-shift-x, 0px), -38px) scale(1.9);
    transform-origin: center bottom;
    --board-copy: 10.5px; --board-title: 10.5px; --board-stat: 14px;
    transition: transform 90ms ease-out;
  }
  .game-container .hand-grid .card.hand-focus:first-child { margin-left: 0; }
  .game-container #active-hand { touch-action: none; }
  .game-container #game-history-log.visual-history { grid-template-rows: minmax(0, 49fr) minmax(0, 51fr); }
}
/* One modern card preview plus a separate scrollable explanation column. */
.modern-inspector {
  --board-card-width: 260px; --board-card-height: min(430px, 75dvh);
  --board-art: 45%; --board-copy: 14px; --board-title: 16px; --board-stat: 18px;
  font-family: system-ui, sans-serif; gap: 10px; max-height: calc(100dvh - 32px);
}
.modern-inspector .tooltip-card-preview { width: var(--board-card-width); }
.modern-inspector .tooltip-card-preview .card { aspect-ratio: auto; height: var(--board-card-height); pointer-events: none; }
.modern-inspector .tooltip-info-boxes { width: 190px; min-width: 0; max-width: none; max-height: var(--board-card-height); flex-flow: column nowrap; justify-content: flex-start; touch-action: pan-y; }
.modern-inspector .tooltip-info-box { min-width: 0; max-width: none; width: 100%; padding: 9px; background: #18343b; border: 1px solid #82968a; border-left: 3px solid #b3c69b; border-radius: 7px; box-shadow: none; }
.modern-inspector .tooltip-info-box-title, .modern-inspector .tooltip-token-header { font: 650 12px/1.3 system-ui; color: #dce8d6; }
.modern-inspector .tooltip-info-box-description { font: 12px/1.4 system-ui; color: #d0dfda; }
.modern-inspector .tooltip-token-preview { margin: 0; transform: none; padding: 0; }
.modern-inspector .tooltip-token-preview .card { width: 100%; height: 220px; min-height: 220px; transform: none; margin: 0; --board-copy: 12px; --board-title: 12px; --board-stat: 14px; }
@media (max-width: 767px) {
  .card-hover-tooltip.modern-inspector { left: 8px !important; top: 50% !important; transform: translateY(-50%); flex-direction: row; align-items: center; width: calc(100vw - 16px); max-width: none; gap: 8px; --board-card-width: min(56vw, 260px); --board-card-height: min(420px, calc(100dvh - 100px)); }
  .modern-inspector .tooltip-info-boxes { flex: 1; width: 0; }
}

.modern-inspector.visible .tooltip-card-preview .card { pointer-events: auto; }

/* Give the rival a real landing area in the formerly unused utility band.
   The transparent utility wrapper never intercepts attacks; its buttons do. */
.game-container .top-utilities { background: none; border: 0; pointer-events: none; justify-content: flex-start; }
.game-container .top-utilities > button { pointer-events: auto; }
.game-container .board-brand { display: none; }
.game-container #rival-strip { background: none; border-radius: 0; }
.game-container #rival-strip::before {
  content: ''; position: absolute; left: 84px; right: 94px;
  top: calc(-48px - env(safe-area-inset-top, 0px)); bottom: 0;
  background: #28494b; border: 1px solid #82998b55; border-bottom: 0;
  border-radius: 0; pointer-events: auto;
}
.game-container #rival-strip > * { z-index: 1; }
.game-container #rival-strip .scoreboard-stats > span { position: relative; z-index: 1; }
.game-container #rival-strip .opponent-hand-cards { top: 0; transform: translate(-50%, -65%); height: 38px; }
.game-container #rival-strip .card-back { width: 25px; height: 35px; }
@media (max-width: 767px) and (orientation: portrait) {
  .game-container #rival-strip::before { top: calc(-44px - env(safe-area-inset-top, 0px)); }
  .game-container #rival-strip .card-back { width: 18px; height: 26px; }
}
/* Historical cards retain their own recorded stats; deltas live below the face. */
.history-card-face { display: none; }
@media (min-width: 768px) {
  .game-container #game-history-log.visual-history { grid-template-rows: minmax(0, 34fr) minmax(0, 66fr); }
  .history-duel { gap: 10px; align-items: start; }
  .history-full-card.history-tile { height: auto; border: 0; border-radius: 8px; overflow: visible; }
  .history-full-card > .history-portrait, .history-full-card > .history-name { display: none; }
  .history-full-card > .history-card-face { display: block; width: 100%; max-width: 240px; margin-inline: auto; }
  .history-full-card .history-terminal { position: static; font-size: 11px; }
  .history-full-card .history-stats { height: auto; min-height: 30px; flex-wrap: wrap; gap: 4px; padding: 5px 2px; }
  .history-duel:not(.history-multi) .history-tile:only-child { width: min(100%, 240px); justify-self: center; }
}

.game-container .rival-strip-row,
.game-container .pages-container,
.game-container .page-battlefield.active,
.game-container .battlefield-layout-two-column { overflow: visible; }
@media (min-width: 768px) {
  .history-detail.history-single {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px; align-content: start;
  }
  .history-single > .history-moment,
  .history-single > .history-headline,
  .history-single > .history-description { grid-column: 1 / -1; }
  .history-single > .history-time-label:nth-of-type(1) { grid-column: 1; grid-row: 2; }
  .history-single > .history-time-label:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .history-single > .history-duel:nth-of-type(1) { grid-column: 1; grid-row: 3; }
  .history-single > .history-duel:nth-of-type(2) { grid-column: 2; grid-row: 3; }
  .history-card-face { border: 2px solid #82968a; border-radius: 10px; box-shadow: 0 4px 9px #0005; }
  .history-card-face .stat-atk, .history-card-face .stat-hp, .history-card-face .stat-nut { color: #e4eeea; }
}

/* Desktop history is a permanent rail, not a dismissible panel. */
@media (min-width: 768px) {
  .game-container #field-history-btn, .game-container #close-history { display: none; }
  .game-container .battlefield-layout-two-column.history-hidden {
    grid-template-columns: minmax(0, 1fr) clamp(290px, 23vw, 360px);
  }
  .game-container .history-hidden .battlefield-right-column { display: flex; }
  .game-container #rival-strip::before { left: 84px; right: 94px; }
}

/* v0.17: separate the rival target from utilities, HP and the field. */
.game-container #rival-strip::before {
 left:94px; right:104px; top:calc(-44px - env(safe-area-inset-top, 0px)); bottom:8px;
 border:1px solid #82998b55; border-radius:8px;
}
@media(max-width:767px) and (orientation:portrait) {
 .game-container #rival-strip::before { top:calc(-40px - env(safe-area-inset-top, 0px)); }
}

/* Compact mobile match tools; desktop keeps its visible pile controls. */
.game-container .field-surrender-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.board-diagnostics summary::-webkit-details-marker { display: none; }
@media (max-width: 767px) {
  .game-container .board-diagnostics summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 40px;
    padding: 0;
    border: 1px solid #81998c55;
    border-radius: 7px;
    background: #18343b;
    font-size: 22px;
  }
  .game-container .board-tools-panel {
    position: absolute;
    z-index: 40;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    width: 224px;
    padding: 12px;
    border: 1px solid #81998c;
    border-radius: 10px;
    background: #102730;
    box-shadow: 0 8px 24px #0008;
  }
  .game-container .own-control-row .board-tools-panel .piles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .game-container .own-control-row .board-tools-panel .pile-item {
    justify-content: space-between;
    min-height: 44px;
    padding: 10px 12px;
    color: #edf1e7;
    font-size: 15px;
  }
  .game-container .board-tools-panel .pile-item strong { font-size: 14px; }
  .game-container .board-diagnostics .advantage-display,
  .game-container .board-diagnostics .advantage-graph-container {
    position: static;
    width: 100%;
    min-height: 0;
    border: 0;
    padding: 0;
    background: transparent;
  }
}

/* Click-open inspection: no enclosing panel, just a light veil behind the content. */
.inspection-backdrop {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(2, 12, 18, 0.3);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.card-hover-tooltip.inspection-modal {
  left: 50% !important; top: 50% !important; transform: translate(-50%, -50%);
  width: min(650px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 8px; box-sizing: border-box; gap: 20px;
  flex-direction: row; align-items: flex-start; overflow-y: auto;
  background: transparent; border: 0; box-shadow: none; pointer-events: auto;
}
.inspection-modal:has(.inspection-navigation) { padding-top: 42px; }
.inspection-modal .tooltip-info-boxes { flex: 1; width: auto; max-height: none; overflow: visible; }
@media (max-width: 767px) {
  .card-hover-tooltip.inspection-modal {
    flex-direction: column; align-items: center; --board-card-width: min(230px, 65vw);
    --board-card-height: 340px; gap: 16px;
  }
  .inspection-modal .tooltip-info-boxes { flex: none; width: 100%; }
}
@supports not (backdrop-filter: blur(3px)) {
  .inspection-backdrop { background: rgba(2, 12, 18, 0.65); }
}

.inspection-navigation { position: absolute; left: 8px; top: 0; display: flex; gap: 8px; }
.inspection-navigation button { background: #18343b; border: 1px solid #82968a; color: #edf4f1; border-radius: 6px; padding: 8px; cursor: pointer; }

.modern-inspector .tooltip-token-link { color: #e5d598; font: 600 12px/1.5 system-ui; text-align: left; cursor: pointer; }
.tooltip-token-link:focus-visible, .inspection-navigation button:focus-visible { outline: 2px solid #f0cb84; outline-offset: 2px; }
