:root {
  --ink: #101a33;
  --ink-soft: #45536a;
  --paper: #fffaf0;
  --paper-deep: #f0e6d0;
  --forest: #10234d;
  --forest-deep: #07142e;
  --grass: #4f8a57;
  --grass-light: #75a768;
  --path: #d8c99f;
  --path-dark: #a99568;
  --river: #4c9bb1;
  --river-light: #89cbd0;
  --player: #2eaed4;
  --player-dark: #155b84;
  --player-light: #83d9ee;
  --ai: #d45d4f;
  --ai-dark: #8d352f;
  --ai-light: #f3a278;
  --gold: #e2aa3d;
  --gold-dark: #9b681c;
  --success: #4e9658;
  --danger: #c9403a;
  --line: rgba(16, 26, 51, 0.22);
  --shadow: rgba(4, 13, 35, 0.28);
  --card-width: 100px;
  --card-height: 140px;
  --radius: 8px;
  --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--forest-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(83, 204, 234, 0.08) 48% 52%, transparent 52%),
    linear-gradient(180deg, #10234d, #07142e 70%);
  background-size: 46px 46px, auto;
}

button,
select {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2,
strong {
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
}

.screen[hidden],
[hidden] {
  display: none !important;
}

.eyebrow,
.section-kicker {
  color: var(--gold-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.menu-screen {
  position: relative;
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--paper);
  background: #19384a url("assets/menu/jellykid-high-card-havoc-home.png") center / cover no-repeat;
}

.menu-screen::before {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: min(760px, 58%);
  background: rgba(7, 20, 46, 0.9);
  clip-path: polygon(0 0, 84% 0, 100% 100%, 0 100%);
  content: "";
  pointer-events: none;
}

.menu-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1600px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 28px 22px;
}

.menu-topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.26);
}

.jellykid-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.jellykid-brand div {
  display: grid;
}

.jellykid-brand strong {
  color: #fff;
  font-size: 1rem;
  text-transform: uppercase;
}

.jellykid-brand div span {
  color: #9bdff0;
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.menu-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  border: 2px solid #62d5ef;
  border-radius: 6px;
  place-items: center;
  background: #10234d;
  color: #fff;
  font-weight: 900;
}

.menu-command {
  display: grid;
  align-content: center;
  width: min(590px, 48%);
  min-height: 0;
  padding: 24px 0;
  transform: translateX(min(0px, calc((1600px - 100vw) / 4)));
}

.brand-lockup {
  max-width: 580px;
  padding: 0 0 24px;
}

.brand-lockup .eyebrow {
  color: #72d8ef;
}

.brand-lockup h1 {
  margin-top: 7px;
}

.brand-wordmark {
  display: block;
  width: min(100%, 520px);
  aspect-ratio: 2.2 / 1;
  object-fit: cover;
  object-position: center 48%;
}

.setup-controls {
  max-width: 560px;
  padding: 18px 0;
  border-top: 1px solid rgba(255, 250, 240, 0.32);
  border-bottom: 1px solid rgba(255, 250, 240, 0.32);
}

.rules-summary {
  position: absolute;
  z-index: 4;
  right: 28px;
  bottom: 28px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  width: min(900px, calc(100% - 56px));
  padding: 16px 20px;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 6px;
  background: rgba(7, 20, 46, 0.88);
  box-shadow: 0 18px 42px rgba(4, 13, 35, 0.42);
}

.rules-close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 4px;
  place-items: center;
  background: rgba(255, 250, 240, 0.08);
  color: #fff;
  font-weight: 900;
}

.setup-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
}

.setup-heading h2 {
  position: relative;
  left: 34px;
  color: #fff;
  font-size: 1.2rem;
  text-align: right;
  text-transform: uppercase;
}

.queue-code {
  color: #72d8ef;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rules-heading h2 {
  margin-top: 3px;
  color: #fff;
  font-size: 1.15rem;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.difficulty-control {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
}

.segment-button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  background: #f9f3e7;
  font-weight: 800;
}

.menu-screen .segmented-control {
  border-color: rgba(255, 250, 240, 0.3);
}

.menu-screen .segment-button {
  border-color: rgba(255, 250, 240, 0.22);
  background: rgba(255, 250, 240, 0.1);
  color: #fff;
}

.menu-screen .segment-button:hover:not(:disabled) {
  background: rgba(255, 250, 240, 0.18);
}

.menu-screen .segment-button.selected {
  background: #62d5ef;
  color: #07142e;
  box-shadow: inset 0 -3px 0 rgba(21, 91, 132, 0.28);
}

.segment-button:last-child {
  border-right: 0;
}

.segment-button:hover:not(:disabled) {
  background: #fffdf7;
}

.segment-button.selected {
  background: var(--forest);
  color: var(--paper);
}

.primary-button,
.secondary-button,
.utility-button {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 900;
}

.primary-button {
  border: 1px solid #744914;
  background: var(--gold);
  box-shadow: inset 0 -3px 0 rgba(116, 73, 20, 0.25);
  color: #2c1d0c;
}

.primary-button:hover:not(:disabled) {
  background: #efbd56;
}

.menu-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.play-button,
.menu-rules-button {
  width: 100%;
  font-size: 1.04rem;
  text-transform: uppercase;
}

.menu-rules-button {
  min-height: 44px;
  border: 1px solid rgba(255, 250, 240, 0.42);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.1);
  color: #fff;
  font-weight: 900;
}

.menu-rules-button:hover,
.menu-rules-button[aria-expanded="true"] {
  background: rgba(98, 213, 239, 0.2);
  border-color: #62d5ef;
}

.rules-summary ol {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rules-summary li {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding-left: 10px;
  border-left: 3px solid rgba(98, 213, 239, 0.72);
}

.rules-summary li strong {
  color: #f8e5a8;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.rules-summary li span {
  color: rgba(255, 250, 240, 0.76);
  font-size: 0.68rem;
  line-height: 1.25;
}

.game-screen {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto 48px;
  width: min(1500px, 100%);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 8px;
  overflow: hidden;
}

.orientation-lock {
  display: none;
}

@media (min-width: 821px) {
  body:has(.menu-screen:not([hidden])),
  body:has(.game-screen:not([hidden])) {
    overflow: hidden;
  }
}

.game-header,
.opponent-strip,
.player-strip,
.feedback-panel {
  border: 1px solid rgba(255, 250, 240, 0.2);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 10px 24px var(--shadow);
}

.game-header {
  display: grid;
  grid-template-columns: minmax(205px, 1fr) auto minmax(205px, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 74px;
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.compact-brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--player);
  border-radius: var(--radius);
  background: var(--forest);
  color: var(--paper);
  font-weight: 900;
}

.compact-brand h1 {
  font-size: 1.65rem;
  line-height: 1;
}

.match-meta {
  display: grid;
  grid-template-columns: 62px minmax(118px, 150px) minmax(108px, 138px) minmax(100px, 130px) 78px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.player-attack-meta {
  background: #d9f5fb;
}

.player-attack-meta strong {
  color: var(--player-dark);
}

.player-defense-meta {
  background: #fff6da;
}

.player-defense-meta strong {
  color: var(--gold-dark);
}

.meta-item {
  min-width: 0;
  padding: 7px 10px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.meta-item:last-child {
  border-right: 0;
}

.meta-item span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.67rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-item strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.utility-button,
.secondary-button {
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #f5eddd;
}

.utility-button:hover,
.secondary-button:hover {
  background: #fffaf0;
}

.fullscreen-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
}

.fullscreen-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.fullscreen-corner {
  position: absolute;
  width: 6px;
  height: 6px;
  border-color: currentColor;
  transition: transform 160ms ease;
}

.fullscreen-corner.top-left {
  top: 0;
  left: 0;
  border-top: 2px solid;
  border-left: 2px solid;
}

.fullscreen-corner.top-right {
  top: 0;
  right: 0;
  border-top: 2px solid;
  border-right: 2px solid;
}

.fullscreen-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.fullscreen-corner.bottom-right {
  right: 0;
  bottom: 0;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.fullscreen-button[aria-pressed="true"] .top-left {
  transform: translate(3px, 3px);
}

.fullscreen-button[aria-pressed="true"] .top-right {
  transform: translate(-3px, 3px);
}

.fullscreen-button[aria-pressed="true"] .bottom-left {
  transform: translate(3px, -3px);
}

.fullscreen-button[aria-pressed="true"] .bottom-right {
  transform: translate(-3px, -3px);
}

.fullscreen-notice {
  position: fixed;
  z-index: 1200;
  right: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(440px, calc(100% - 24px));
  padding: 10px 14px;
  border: 1px solid rgba(240, 194, 75, 0.8);
  border-radius: 6px;
  background: rgba(7, 20, 46, 0.94);
  box-shadow: 0 8px 22px rgba(4, 13, 35, 0.4);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  transform: translateX(50%);
}

.fullscreen-notice[hidden] {
  display: none;
}

.opponent-strip,
.player-strip {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 10px 14px;
}

.opponent-strip {
  border-top: 0;
  background: rgba(255, 240, 228, 0.96);
}

.player-strip {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(540px, 1fr) minmax(280px, 0.55fr);
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  border-radius: var(--radius);
}

.player-strip-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.side-identity {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 0.78rem;
}

.side-identity span:not(.identity-dot) {
  display: block;
  color: var(--ink-soft);
}

.side-identity strong {
  display: block;
  margin-top: 1px;
  font-size: 0.95rem;
}

.identity-dot {
  width: 13px;
  height: 34px;
  border-radius: 4px;
}

.ai-identity .identity-dot {
  background: var(--ai);
}

.player-identity .identity-dot {
  background: var(--player);
}

.mini-hand {
  display: flex;
  gap: 5px;
  justify-content: center;
  min-width: 205px;
}

.mini-card {
  position: relative;
  display: grid;
  width: 34px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #091631;
  border-radius: 5px;
  background: var(--forest-deep);
  box-shadow: 0 2px 5px rgba(4, 13, 35, 0.25);
}

.mini-card.ai-card {
  border-color: var(--ai-dark);
  background: #4f171d;
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) 116px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid #0d281d;
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--grass);
  box-shadow: 0 16px 30px var(--shadow);
}

.lane-field {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(13, 40, 29, 0.4);
  border-left: 1px solid rgba(13, 40, 29, 0.4);
  background:
    linear-gradient(90deg, rgba(36, 126, 161, 0.14), transparent 33%, transparent 67%, rgba(212, 93, 79, 0.14)),
    url("assets/battlefield/grass-field.png") center / 420px 420px repeat;
}

.river {
  position: absolute;
  z-index: 0;
  top: -2%;
  bottom: -2%;
  left: 50%;
  width: min(460px, 58%);
  background: url("assets/battlefield/river-course.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 0 2px rgba(23, 59, 43, 0.28));
  transform: translateX(-50%);
}

.river::after {
  content: none;
}

.brush {
  position: absolute;
  z-index: 0;
  width: 120px;
  height: 64px;
  object-fit: contain;
  opacity: 0.82;
  filter: drop-shadow(0 4px 2px rgba(13, 40, 29, 0.32));
}

.brush-one {
  top: 44%;
  left: 18%;
  transform: rotate(-4deg);
}

.brush-two {
  right: 16%;
  bottom: 44%;
  transform: rotate(5deg);
}

.territory-label {
  position: absolute;
  z-index: 1;
  top: 10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.player-territory-label {
  left: 14px;
}

.ai-territory-label {
  right: 14px;
}

.lane-list {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 14px;
  height: 100%;
  min-height: 0;
  padding: 34px 12px 18px;
}

.lane-list.simultaneous-battle {
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.lane {
  position: relative;
  --lane-end-width: 150px;
  display: grid;
  grid-template-columns: var(--lane-end-width) minmax(260px, 1fr) var(--lane-end-width);
  align-items: center;
  min-width: 0;
  transition: opacity 180ms ease, filter 180ms ease;
}

.lane::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: 40px;
  left: 40px;
  height: 116px;
  border: 4px solid var(--path-dark);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 250, 240, 0.05), rgba(94, 78, 44, 0.05)),
    url("assets/battlefield/lane-path.png") center / 460px 320px repeat;
  box-shadow: inset 0 0 0 4px rgba(255, 250, 240, 0.22);
  content: "";
  transform: translateY(-50%);
}

.lane[data-lane="top"]::before {
  right: 40px;
  left: -14px;
}

.lane[data-lane="bottom"]::before {
  right: -14px;
  left: 40px;
}

.lane-title {
  position: absolute;
  top: 0;
  left: 50%;
  min-width: 150px;
  padding: 4px 8px;
  border: 1px solid rgba(23, 35, 29, 0.24);
  border-radius: 5px;
  background: rgba(255, 250, 240, 0.92);
  font-size: 0.76rem;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  white-space: nowrap;
}

.resolving-lane::before {
  border-color: #f0c24b;
  box-shadow:
    inset 0 0 0 4px rgba(255, 250, 240, 0.3),
    0 0 0 4px rgba(83, 204, 234, 0.24);
}

.waiting-lane {
  opacity: 0.72;
}

.settled-lane {
  filter: saturate(0.78);
}

.tower-structure {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: 138px;
  min-height: 145px;
  padding-top: 4px;
  text-align: center;
}

.open-route-end {
  width: 150px;
  min-height: 1px;
}

.lane-fort {
  display: grid;
  gap: 3px;
  justify-items: center;
  width: 148px;
  min-height: 148px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.22);
  color: var(--ink);
}

.lane-fort:hover,
.lane-fort:focus-visible {
  border-color: var(--gold-dark);
  outline: 0;
  background: rgba(255, 246, 218, 0.86);
  box-shadow: 0 0 0 3px rgba(226, 170, 61, 0.28);
}

.fort-visual {
  position: relative;
  display: block;
  width: 144px;
  height: 112px;
}

.fort-art {
  position: absolute;
  inset: 0;
  width: 144px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 3px 2px rgba(13, 40, 29, 0.32));
}

.fort-card {
  position: absolute;
  right: auto;
  bottom: 8px;
  left: 50%;
  display: grid;
  width: 38px;
  height: 53px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: -3px 2px 0 rgba(9, 22, 49, 0.3);
  transform: translateX(-50%) rotate(2deg);
}

.fort-label {
  max-width: 136px;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
}

.lane-fort > strong {
  font-size: 0.84rem;
}

.tower-art {
  display: block;
  width: 112px;
  height: 118px;
  object-fit: contain;
  filter: drop-shadow(0 5px 3px rgba(23, 35, 29, 0.28));
}

.tower-structure.destroyed .tower-art {
  width: 102px;
  height: 64px;
  margin-top: 26px;
  filter: drop-shadow(0 4px 2px rgba(23, 35, 29, 0.3));
}

.tower-structure.damaged .tower-art {
  filter: drop-shadow(0 5px 3px rgba(23, 35, 29, 0.32)) saturate(0.92);
}

.tower-structure.gate-hit .tower-art {
  animation: gate-hit-pulse 420ms ease-out;
}

.structure-label {
  display: block;
  max-width: 132px;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-value {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 900;
}

.health-pips {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 5px;
}

.health-pip {
  width: 14px;
  height: 7px;
  border: 1px solid rgba(23, 35, 29, 0.3);
  border-radius: 2px;
  background: var(--success);
}

.health-pip.empty {
  background: rgba(23, 35, 29, 0.18);
}

.core-health .health-pip {
  width: 13px;
  height: 9px;
}

.lane-track {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 160px;
}

.river-gate {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 108px;
  min-height: 128px;
  padding-top: 2px;
  transform: translate(-50%, -50%);
}

.inner-gate {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 108px;
  min-height: 132px;
  padding-top: 2px;
  transform: translate(-50%, -50%);
}

.inner-gate .tower-art {
  width: 100px;
  height: 112px;
}

.inner-gate.destroyed .tower-art {
  width: 76px;
  height: 48px;
  margin-top: 18px;
}

.inner-gate .structure-label {
  max-width: 102px;
  font-size: 0.62rem;
}

.player-inner-gate {
  left: 6%;
}

.ai-inner-gate {
  left: 94%;
}

.river-gate .tower-art {
  width: 88px;
  height: 108px;
}

.river-gate.destroyed .tower-art {
  width: 82px;
  height: 50px;
  margin-top: 19px;
}

.river-gate .structure-label {
  max-width: 104px;
  font-size: 0.62rem;
}

.player-outer-gate {
  left: 42%;
}

.ai-outer-gate {
  left: 58%;
}

.clash-zone {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 7px;
  width: min(360px, 70%);
  min-width: 250px;
  margin: 0 auto;
  transition: margin 360ms ease, transform 360ms ease;
}

.frontline-player-outer .clash-zone {
  margin-right: auto;
  margin-left: 50%;
}

.frontline-ai-outer .clash-zone {
  margin-right: 50%;
  margin-left: auto;
}

.frontline-player-inner .clash-zone {
  margin-right: auto;
  margin-left: 14%;
}

.frontline-ai-inner .clash-zone {
  margin-right: 14%;
  margin-left: auto;
}

.frontline-player-core .clash-zone {
  position: absolute;
  top: 50%;
  right: auto;
  left: calc(12px - var(--lane-end-width));
  margin-right: auto;
  margin-left: 0;
  transform: translateY(-50%);
}

.frontline-ai-core .clash-zone {
  position: absolute;
  top: 50%;
  right: calc(12px - var(--lane-end-width));
  left: auto;
  margin-right: 0;
  margin-left: auto;
  transform: translateY(-50%);
}

.frontline-player-inner .clash-zone.single-duel,
.frontline-ai-inner .clash-zone.single-duel {
  width: 154px;
  min-width: 154px;
}

.frontline-player-inner .card-slot .battle-card,
.frontline-ai-inner .card-slot .battle-card {
  width: 66px;
  height: 92px;
}

.frontline-player-core .clash-zone.single-duel,
.frontline-ai-core .clash-zone.single-duel {
  width: 126px;
  min-width: 126px;
}

.frontline-player-core .card-slot .battle-card,
.frontline-ai-core .card-slot .battle-card {
  width: 54px;
  height: 76px;
}

.clash-zone.single-duel {
  grid-template-columns: minmax(160px, 1fr);
  width: min(230px, 72%);
  min-width: 180px;
}

.duel-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(23, 35, 29, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.45);
}

.resolving-lane .duel-pair {
  border-color: var(--gold-dark);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 0 0 4px rgba(240, 194, 75, 0.28);
}

.duel-pending {
  opacity: 0.76;
}

.duel-label {
  grid-column: 1 / -1;
  color: rgba(23, 35, 29, 0.66);
  font-size: 0.58rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.card-slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 92px;
  place-items: center;
  border: 1px dashed rgba(23, 35, 29, 0.32);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.34);
}

.player-placement-slot {
  isolation: isolate;
  border: 2px dashed rgba(21, 91, 132, 0.88);
  background: rgba(217, 245, 251, 0.66);
  box-shadow: 0 0 0 4px rgba(83, 204, 234, 0.24), inset 0 0 18px rgba(83, 204, 234, 0.22);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.player-placement-slot::before {
  position: absolute;
  z-index: -1;
  inset: -12px;
  border: 1px solid rgba(83, 204, 234, 0.32);
  border-radius: 10px;
  background: rgba(217, 245, 251, 0.12);
  content: "";
  pointer-events: auto;
}

.player-placement-slot[data-player-slot="attack"]::before {
  border-color: rgba(226, 170, 61, 0.4);
  background: rgba(255, 246, 218, 0.14);
}

.player-placement-slot:not(.filled-slot) {
  animation: slot-ready 1.8s ease-in-out infinite;
}

.player-placement-slot[data-player-slot="attack"] {
  border-color: rgba(155, 104, 28, 0.92);
  background: rgba(255, 246, 218, 0.78);
  box-shadow: 0 0 0 4px rgba(226, 170, 61, 0.3), inset 0 0 18px rgba(226, 170, 61, 0.24);
}

.player-placement-slot:hover,
.player-placement-slot:focus-visible {
  border-color: var(--gold-dark);
  outline: 0;
  background: rgba(255, 246, 218, 0.92);
  box-shadow: 0 0 0 3px rgba(226, 170, 61, 0.3);
}

.player-placement-slot.drag-over {
  border-color: var(--gold-dark);
  background: #fff6da;
  box-shadow: 0 0 0 7px rgba(226, 170, 61, 0.48), inset 0 0 24px rgba(255, 250, 240, 0.86);
}

.player-placement-slot.filled-slot {
  border-style: solid;
  animation: none;
}

.player-placement-slot.dragging-slot {
  opacity: 0.58;
}

.placed-card {
  animation: place-card 180ms ease-out;
}

.slot-caption {
  padding: 3px;
  color: rgba(23, 35, 29, 0.54);
  font-size: 0.58rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.battle-card {
  position: relative;
  display: grid;
  width: var(--card-width);
  height: var(--card-height);
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 2px solid rgba(23, 35, 29, 0.5);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 6px 12px rgba(23, 35, 29, 0.2);
  color: var(--player-dark);
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.battle-card.ai-card {
  background: #fff0ed;
  color: var(--ai-dark);
}

.battle-card.face-down {
  border-color: var(--player);
  box-shadow: 0 6px 12px rgba(4, 13, 35, 0.28);
}

.battle-card.face-down.ai-card {
  border-color: var(--ai);
}

.battle-role-badge {
  position: absolute;
  z-index: 5;
  right: 3px;
  bottom: 3px;
  left: 3px;
  display: grid;
  min-height: 15px;
  padding: 2px 3px;
  border: 1px solid rgba(255, 250, 240, 0.78);
  border-radius: 3px;
  place-items: center;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 1px rgba(4, 13, 35, 0.54);
  text-transform: uppercase;
}

.battle-role-badge.attack {
  background: rgba(142, 62, 45, 0.94);
}

.battle-role-badge.defense {
  background: rgba(21, 91, 132, 0.94);
}

.card-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.cut-card-piece {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  pointer-events: none;
}

.cut-card-piece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cut-card-top {
  clip-path: polygon(0 0, 100% 0, 100% 43%, 56% 55%, 0 45%);
}

.cut-card-bottom {
  clip-path: polygon(0 45%, 56% 55%, 100% 43%, 100% 100%, 0 100%);
}

.cut-loser-card,
.resolved-loser {
  overflow: visible;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.cut-loser-card > .base-card-art,
.resolved-loser > .base-card-art {
  opacity: 0;
}

.cut-loser-card .cut-card-top {
  animation: card-cut-top 720ms cubic-bezier(0.22, 0.72, 0.2, 1) forwards;
}

.cut-loser-card .cut-card-bottom {
  animation: card-cut-bottom 720ms cubic-bezier(0.22, 0.72, 0.2, 1) forwards;
}

.resolved-loser .cut-card-top {
  transform: translate(-8px, -10px) rotate(-5deg);
  opacity: 0.52;
}

.resolved-loser .cut-card-bottom {
  transform: translate(8px, 12px) rotate(6deg);
  opacity: 0.52;
}

.winning-card {
  z-index: 5;
  animation: winning-card-pop 720ms ease-out;
}

.resolved-winner {
  z-index: 4;
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(226, 170, 61, 0.34), 0 8px 16px rgba(23, 35, 29, 0.24);
  transform: translateY(-3px) scale(1.04);
}

.card-image-fallback {
  display: none;
  max-width: 100%;
  padding: 6px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.card-image-shell.image-missing {
  background:
    linear-gradient(135deg, rgba(83, 204, 234, 0.3), transparent 55%),
    var(--paper);
}

.card-image-shell.image-missing .card-image-fallback {
  display: block;
}

.card-slot .battle-card {
  width: 72px;
  height: 101px;
}

.core-structure {
  position: relative;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  padding: 8px;
  color: var(--paper);
  text-align: center;
}

.core-structure > :not(.core-route) {
  position: relative;
  z-index: 2;
}

.core-structure > .core-pile-button {
  position: absolute;
}

.core-route {
  position: absolute;
  z-index: 0;
  width: 100%;
  height: 38%;
  background:
    linear-gradient(rgba(255, 250, 240, 0.05), rgba(94, 78, 44, 0.08)),
    url("assets/battlefield/lane-path.png") center / 260px 220px repeat;
  box-shadow: inset 0 0 0 4px rgba(255, 250, 240, 0.18);
  filter: drop-shadow(0 0 2px rgba(71, 58, 36, 0.46));
  pointer-events: none;
}

.core-route::after {
  content: none;
}

.player-core-route {
  top: 9%;
  right: 0;
  clip-path: polygon(0 0, 62% 0, 62% 20%, 100% 20%, 100% 80%, 62% 80%, 62% 100%, 0 100%);
}

.ai-core-route {
  bottom: 7%;
  left: 0;
  clip-path: polygon(38% 0, 100% 0, 100% 100%, 38% 100%, 38% 80%, 0 80%, 0 20%, 38% 20%);
}

.core-pile-button {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 2px;
  justify-items: center;
  width: 108px;
  min-height: 102px;
  padding: 4px 2px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: rgba(255, 250, 240, 0.08);
  color: var(--paper);
  font-size: 0.59rem;
  font-weight: 900;
  text-transform: uppercase;
}

.core-pile-button:hover,
.core-pile-button:focus-visible {
  border-color: var(--gold);
  outline: 0;
  background: rgba(255, 250, 240, 0.17);
  box-shadow: 0 0 0 3px rgba(226, 170, 61, 0.28);
}

.player-discard-button {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.ai-discard-button {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.discard-stack {
  position: absolute;
  right: 7px;
  bottom: 21px;
  display: block;
  width: 28px;
  height: 38px;
  border: 2px solid var(--paper);
  border-radius: 3px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0 3px, transparent 3px 7px),
    var(--player);
  box-shadow: -4px 3px 0 rgba(255, 250, 240, 0.34), -7px 5px 0 rgba(4, 13, 35, 0.32);
  transform: rotate(-3deg);
}

.graveyard-art {
  display: block;
  width: 102px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px rgba(4, 13, 35, 0.38));
}

.graveyard-label {
  position: relative;
  z-index: 2;
}

.ai-discard-button .discard-stack {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0 3px, transparent 3px 7px),
    var(--ai);
}

.player-structure {
  background: var(--player-dark);
}

.ai-structure {
  align-content: center;
  padding: 8px;
  background: var(--ai-dark);
}

.ai-core-health-display {
  display: grid;
  justify-items: center;
  margin-top: clamp(48px, 8vh, 72px);
  margin-bottom: 2px;
}

.ai-core-health-display .health-pips,
.ai-core-health-display .health-value {
  margin-top: 0;
}

.ai-core-health-display > strong {
  max-width: 104px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  line-height: 1.05;
  font-weight: 900;
  text-transform: uppercase;
}

.core-structure > strong {
  max-width: 104px;
  margin-top: 7px;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.core-gem {
  display: block;
  width: 108px;
  height: 132px;
  margin-top: 4px;
  object-fit: contain;
  filter: drop-shadow(0 6px 4px rgba(4, 13, 35, 0.4));
}

.core-structure.destroyed .core-gem {
  filter: grayscale(1) brightness(0.68) drop-shadow(0 4px 2px rgba(4, 13, 35, 0.35));
  opacity: 0.7;
  transform: rotate(8deg) scale(0.82);
}

.player-hand {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 178px;
  align-items: center;
  padding: 16px 0 8px;
  overflow-x: auto;
  scrollbar-color: var(--path-dark) transparent;
}

.hand-card {
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.hand-card:hover:not(:disabled),
.hand-card:focus-visible {
  border-color: var(--gold-dark);
  box-shadow: 0 8px 0 rgba(155, 104, 28, 0.28);
  transform: translateY(-5px);
}

.hand-card.focused-card {
  z-index: 4;
  border-color: var(--gold-dark);
  box-shadow: 0 12px 24px rgba(4, 13, 35, 0.35), 0 0 0 4px rgba(226, 170, 61, 0.42);
  transform: translateY(-8px) scale(1.12);
}

.hand-card.dragging-card {
  opacity: 0.64;
}

.pointer-drag-preview {
  opacity: 0.9;
  transform: scale(1.06);
  filter: drop-shadow(0 12px 10px rgba(4, 13, 35, 0.42));
}

.card-pointer-dragging,
.card-pointer-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.game-screen,
.game-screen button,
.game-screen img {
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.card-flight-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.card-flight {
  position: fixed !important;
  z-index: 1001 !important;
  margin: 0 !important;
  pointer-events: none !important;
}

.receiving-card,
.departing-card {
  opacity: 0 !important;
  pointer-events: none !important;
}

.command-area {
  position: relative;
  z-index: 12;
  min-height: 48px;
  margin-top: 6px;
}

.feedback-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 0;
  width: min(300px, 100%);
  overflow: hidden;
  border-radius: var(--radius);
  transition: width 180ms ease;
}

.feedback-panel.expanded {
  width: min(560px, 100%);
  box-shadow: 0 18px 40px rgba(4, 13, 35, 0.34);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin-top: 2px;
  font-size: 1.05rem;
}

.feedback-panel .panel-heading {
  min-height: 48px;
  padding: 6px 9px 6px 12px;
}

.feedback-panel:not(.expanded) .panel-heading {
  border-bottom: 0;
}

.report-heading-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.log-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f5eddd;
}

.log-toggle:hover {
  background: #fffaf0;
}

.collapse-icon {
  position: absolute;
  top: 10px;
  left: 11px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 160ms ease, top 160ms ease;
}

.feedback-panel.expanded .collapse-icon {
  top: 14px;
  transform: rotate(225deg);
}

.instruction-text {
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.45;
}

.turn-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.player-strip > .turn-controls {
  grid-template-columns: 0.85fr 1.15fr;
  padding: 8px 0 8px 12px;
  border-top: 0;
  border-left: 1px solid var(--line);
}

.player-strip > .turn-controls .instruction-text {
  grid-column: 1 / -1;
}

.confirm-button {
  min-width: 150px;
  margin: 0;
  padding: 0 18px;
}

.clear-board-button {
  min-width: 104px;
}

.turn-chip {
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--forest);
  color: var(--paper);
  font-size: 0.67rem;
  font-weight: 900;
  text-transform: uppercase;
}

.battle-log {
  display: grid;
  gap: 8px;
  max-height: 244px;
  margin: 0;
  padding: 12px 16px 14px 36px;
  overflow-y: auto;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.38;
  background: var(--paper);
}

.battle-log li::marker {
  color: var(--gold-dark);
  font-weight: 900;
}

.battle-log .positive {
  color: #2b6f3c;
}

.battle-log .negative {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 24, 16, 0.78);
}

.pile-dialog {
  width: min(760px, 100%);
  max-height: min(760px, 90vh);
  overflow: auto;
  padding: 20px;
  border: 2px solid var(--gold-dark);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.pile-dialog-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.pile-dialog-header h2 {
  margin-top: 3px;
  font-size: 1.5rem;
}

.pile-viewer-summary {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.pile-viewer-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.pile-value-card {
  position: relative;
  display: grid;
  width: 72px;
  height: 101px;
  justify-self: center;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--paper-deep);
  box-shadow: 0 5px 10px rgba(4, 13, 35, 0.18);
}

.pile-value-card.empty-value {
  filter: grayscale(1);
  opacity: 0.38;
}

.pile-value-count {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--forest);
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 900;
}

.end-dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow-y: auto;
  border: 4px solid var(--forest-deep);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
  text-align: center;
  animation: end-dialog-arrive 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.end-showdown {
  position: relative;
  isolation: isolate;
  min-height: 190px;
  overflow: hidden;
  border-bottom: 4px solid var(--forest-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background:
    linear-gradient(90deg, rgba(7, 20, 46, 0.64), rgba(7, 20, 46, 0.08)),
    url("assets/menu/jellykid-high-card-havoc-home.png") 64% 38% / cover no-repeat;
}

.end-result-card {
  position: relative;
  z-index: 2;
  width: 92px;
  aspect-ratio: 5 / 7;
  filter: drop-shadow(0 9px 7px rgba(4, 13, 35, 0.46));
  animation: end-card-enter 480ms ease-out both;
}

.end-result-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.end-player-card {
  transform: rotate(-9deg);
}

.end-enemy-card {
  transform: rotate(9deg);
  animation-delay: 70ms;
}

.end-result-mark {
  position: relative;
  z-index: 3;
  display: grid;
  width: 86px;
  min-width: 86px;
  height: 86px;
  min-height: 86px;
  padding: 12px;
  border: 5px solid currentColor;
  border-radius: 50%;
  place-items: center;
  background: var(--forest-deep);
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 1000;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 250, 240, 0.45);
  box-shadow: 0 6px 0 rgba(4, 13, 35, 0.46);
  animation: end-mark-pop 420ms 140ms ease-out both;
}

.end-dialog.victory .end-result-mark {
  color: #8ee59a;
}

.end-dialog.defeat .end-result-mark {
  color: #ff958a;
}

.end-dialog.draw .end-result-mark {
  color: #f0c24b;
}

.end-dialog.victory .end-player-card,
.end-dialog.defeat .end-enemy-card {
  transform: translateY(-6px) scale(1.08) rotate(-4deg);
}

.end-dialog.draw .end-player-card {
  transform: rotate(-5deg);
}

.end-dialog.draw .end-enemy-card {
  transform: rotate(5deg);
}

.end-copy {
  padding: 20px 26px 0;
}

.end-kicker {
  color: var(--player-dark);
}

.end-dialog h2 {
  margin-top: 5px;
  color: var(--forest-deep);
  font-size: 3rem;
  line-height: 0.95;
  text-transform: uppercase;
}

.end-dialog.victory .end-kicker {
  color: #2f7b45;
}

.end-dialog.defeat .end-kicker {
  color: var(--danger);
}

.end-dialog.draw .end-kicker {
  color: var(--gold-dark);
}

.end-subtitle {
  margin-top: 7px;
  color: var(--ink-soft);
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
  padding: 0 26px;
  border-block: 1px solid var(--line);
  background: #f4eddf;
}

.end-stats div {
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.end-stats div:first-child {
  grid-column: 1 / -1;
}

.end-stats div:nth-child(odd):not(:first-child),
.end-stats div:last-child {
  border-right: 0;
}

.end-stats div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.end-stats dt {
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
}

.end-stats dd {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 900;
}

.end-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 0 26px 24px;
}

@keyframes end-dialog-arrive {
  from {
    transform: translateY(18px) scale(0.97);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes end-card-enter {
  from {
    transform: translateY(34px) scale(0.78);
    opacity: 0;
  }
}

@keyframes end-mark-pop {
  from {
    transform: scale(0.55) rotate(-8deg);
    opacity: 0;
  }

  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.impacting {
  animation: impact 320ms ease;
}

.revealing .battle-card {
  animation: card-flip 300ms ease;
}

.clash-win {
  animation: clash-win 360ms ease;
}

.clash-block {
  animation: clash-block 360ms ease;
}

.screen-shake {
  animation: screen-shake 280ms ease;
}

@keyframes card-flip {
  0% { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

@keyframes card-cut-top {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  42% { opacity: 1; transform: translate(-2px, -2px) rotate(-1deg); }
  100% { opacity: 0.52; transform: translate(-8px, -10px) rotate(-5deg); }
}

@keyframes card-cut-bottom {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  42% { opacity: 1; transform: translate(2px, 2px) rotate(1deg); }
  100% { opacity: 0.52; transform: translate(8px, 12px) rotate(6deg); }
}

@keyframes winning-card-pop {
  0% { filter: brightness(1); transform: translateY(0) scale(1); }
  45% { filter: brightness(1.18); transform: translateY(-8px) scale(1.1); }
  100% { filter: brightness(1); transform: translateY(-3px) scale(1.04); }
}

@keyframes place-card {
  0% { opacity: 0.55; transform: translateY(12px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slot-ready {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

@keyframes impact {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(4px); }
}

@keyframes gate-hit-pulse {
  0%, 100% { filter: brightness(1) saturate(1) drop-shadow(0 5px 3px rgba(23, 35, 29, 0.28)); }
  42% { filter: brightness(1.28) saturate(0.72) drop-shadow(0 0 9px rgba(255, 246, 218, 0.88)); }
}

@keyframes clash-win {
  0% { box-shadow: 0 0 0 0 rgba(226, 170, 61, 0.8); }
  100% { box-shadow: 0 0 0 16px rgba(226, 170, 61, 0); }
}

@keyframes clash-block {
  0% { box-shadow: 0 0 0 0 rgba(36, 126, 161, 0.75); }
  100% { box-shadow: 0 0 0 16px rgba(36, 126, 161, 0); }
}

@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .menu-screen::before {
    width: 68%;
  }

  .menu-command {
    width: 55%;
  }

  .rules-summary {
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 14px;
  }

  .rules-summary ol {
    gap: 8px;
  }

  .game-header {
    grid-template-columns: 1fr auto;
  }

  .match-meta {
    grid-row: 2;
    grid-column: 1 / -1;
    grid-template-columns: 62px minmax(110px, 1fr) minmax(100px, 1fr) minmax(96px, 1fr) 74px;
  }

  .command-area {
    grid-template-columns: 1fr;
  }

  .player-strip {
    grid-template-columns: 100px minmax(0, 1fr) 230px;
    gap: 8px;
  }

  .battle-log {
    max-height: 150px;
  }

  .clash-zone {
    width: min(320px, 80%);
  }
}

@media (max-width: 820px) {
  :root {
    --card-width: 84px;
    --card-height: 118px;
  }

  .menu-screen {
    background-position: 62% center;
  }

  .menu-screen::before {
    width: 78%;
  }

  .menu-command {
    width: 66%;
  }

  .rules-summary {
    grid-template-columns: 1fr;
  }

  .rules-summary ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-screen {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 8px;
  }

  .game-header {
    gap: 9px;
    padding: 9px;
  }

  .compact-brand .eyebrow {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .utility-button {
    min-height: 40px;
    padding: 0 8px;
    font-size: 0.76rem;
  }

  .opponent-strip {
    grid-template-columns: auto 1fr auto;
    padding: 8px;
  }

  .side-identity strong,
  .side-identity span:not(.identity-dot) {
    display: none;
  }

  .mini-hand {
    min-width: 0;
  }

  .arena {
    grid-template-columns: 82px minmax(0, 1fr) 82px;
    min-height: 520px;
  }

  .player-strip {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .player-strip > .turn-controls {
    grid-column: 1 / -1;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .core-gem {
    width: 78px;
    height: 94px;
  }

  .core-structure > strong {
    font-size: 0.82rem;
  }

  .ai-core-health-display > strong {
    max-width: 76px;
    font-size: 0.72rem;
  }

  .core-health {
    flex-wrap: wrap;
    max-width: 42px;
  }

  .core-health .health-pip {
    width: 10px;
  }

  .lane-list {
    min-height: 520px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .lane {
    --lane-end-width: 62px;
    grid-template-columns: var(--lane-end-width) minmax(230px, 1fr) var(--lane-end-width);
  }

  .tower-structure {
    width: 62px;
  }

  .tower-gate {
    min-height: 108px;
  }

  .river-gate {
    width: 72px;
    min-height: 94px;
  }

  .tower-gate .tower-art,
  .river-gate .tower-art {
    width: 70px;
    height: 54px;
  }

  .tower-gate.destroyed .tower-art,
  .river-gate.destroyed .tower-art {
    width: 58px;
    height: 40px;
    margin-top: 16px;
  }

  .river-gate .structure-label {
    max-width: 68px;
    font-size: 0.5rem;
  }

  .open-route-end {
    width: 62px;
  }

  .lane-fort {
    width: 62px;
    min-height: 88px;
  }

  .fort-visual {
    width: 56px;
    height: 58px;
    transform: scale(0.86);
  }

  .fort-art {
    width: 72px;
    height: 56px;
  }

  .fort-card {
    width: 27px;
    height: 38px;
  }

  .fort-label {
    max-width: 58px;
    font-size: 0.48rem;
  }

  .core-pile-button {
    width: 66px;
    min-height: 76px;
    font-size: 0.48rem;
  }

  .graveyard-art {
    width: 64px;
    height: 48px;
  }

  .discard-stack {
    width: 22px;
    height: 30px;
  }

  .tower-art {
    width: 58px;
    height: 72px;
  }

  .tower-structure.destroyed .tower-art {
    width: 62px;
    height: 45px;
    margin-top: 18px;
  }

  .structure-label {
    max-width: 60px;
    font-size: 0.59rem;
  }

  .clash-zone {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
    width: min(280px, 88%);
    min-width: 220px;
  }

}

@media (max-width: 640px) {
  .menu-screen {
    min-height: 100vh;
    overflow: auto;
    padding: 0;
    background-position: 64% center;
  }

  .menu-screen::before {
    width: 100%;
    background: rgba(7, 20, 46, 0.78);
    clip-path: none;
  }

  .menu-board {
    display: block;
    min-height: 100vh;
    padding: 12px 14px 18px;
  }

  .menu-command {
    width: 100%;
    padding: 42px 0 30px;
  }

  .brand-lockup {
    padding: 0 0 24px;
  }

  .brand-wordmark {
    width: min(100%, 430px);
  }

  .setup-controls {
    max-width: none;
    padding: 16px 0;
  }

  .setup-heading h2 {
    left: 0;
  }

  .rules-summary {
    display: grid;
    padding: 16px 12px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .rules-summary ol {
    grid-template-columns: 1fr;
  }

  .game-header {
    grid-template-columns: 1fr;
  }

  .compact-brand {
    display: none;
  }

  .header-actions {
    grid-row: 1;
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1 1 0;
  }

  .match-meta {
    grid-row: 2;
    grid-column: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-meta .meta-item:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .opponent-strip {
    min-height: 64px;
  }

  .mini-card {
    width: 27px;
    height: 40px;
  }

  .arena {
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    min-height: 520px;
  }

  .core-structure {
    padding: 4px;
  }

  .core-gem {
    width: 50px;
    height: 62px;
    margin-top: 9px;
  }

  .core-structure > strong {
    margin-top: 9px;
    font-size: 0.66rem;
  }

  .ai-core-health-display > strong {
    max-width: 50px;
    margin-bottom: 2px;
    font-size: 0.55rem;
  }

  .core-health {
    max-width: 34px;
    gap: 2px;
  }

  .core-health .health-pip {
    width: 9px;
    height: 7px;
  }

  .core-structure .health-value {
    font-size: 0.57rem;
  }

  .territory-label,
  .brush {
    display: none;
  }

  .river {
    min-width: 24px;
  }

  .lane-list {
    min-height: 520px;
    gap: 12px;
    padding: 24px 3px 10px;
  }

  .lane {
    --lane-end-width: 38px;
    grid-template-columns: var(--lane-end-width) minmax(0, 1fr) var(--lane-end-width);
  }

  .lane::before {
    right: 18px;
    left: 18px;
    height: 105px;
  }

  .lane-title {
    min-width: 118px;
    font-size: 0.63rem;
  }

  .battle-role-badge {
    right: 1px;
    bottom: 1px;
    left: 1px;
    min-height: 11px;
    padding: 1px;
    font-size: 0.38rem;
  }

  .tower-structure {
    width: 38px;
    min-height: 108px;
  }

  .tower-gate {
    width: 38px;
    min-height: 76px;
  }

  .river-gate {
    width: 46px;
    min-height: 72px;
  }

  .tower-gate .tower-art,
  .river-gate .tower-art {
    width: 46px;
    height: 58px;
  }

  .tower-gate.destroyed .tower-art,
  .river-gate.destroyed .tower-art {
    width: 40px;
    height: 30px;
    margin-top: 12px;
  }

  .player-outer-gate {
    left: 12%;
  }

  .ai-outer-gate {
    left: 88%;
  }

  .river-gate .structure-label {
    display: none;
  }

  .core-structure > strong {
    max-width: 46px;
    font-size: 0.55rem;
    line-height: 1.05;
  }

  .frontline-player-outer .clash-zone,
  .frontline-player-inner .clash-zone {
    margin-right: 0;
    margin-left: auto;
  }

  .frontline-ai-outer .clash-zone,
  .frontline-ai-inner .clash-zone {
    margin-right: auto;
    margin-left: 0;
  }

  .open-route-end {
    width: 38px;
  }

  .lane-fort {
    width: 38px;
    min-height: 70px;
    padding: 2px 0;
  }

  .fort-visual {
    width: 40px;
    height: 42px;
    transform: scale(0.66);
  }

  .fort-label {
    display: none;
  }

  .core-pile-button {
    width: 38px;
    min-height: 56px;
    padding: 3px 0;
  }

  .core-pile-button > span:last-child {
    display: none;
  }

  .graveyard-art {
    width: 42px;
    height: 34px;
  }

  .discard-stack {
    right: 2px;
    bottom: 5px;
    width: 18px;
    height: 25px;
  }

  .tower-art {
    width: 38px;
    height: 52px;
  }

  .tower-structure.destroyed .tower-art {
    width: 42px;
    height: 34px;
    margin-top: 20px;
  }

  .structure-label {
    max-width: 44px;
    font-size: 0.5rem;
  }

  .tower-structure .health-pip {
    width: 8px;
    height: 6px;
  }

  .tower-structure .health-value {
    font-size: 0.53rem;
  }

  .lane-track {
    min-height: 145px;
  }

  .clash-zone {
    grid-template-columns: 1fr;
    gap: 3px;
    width: min(132px, 96%);
    min-width: 0;
  }

  .duel-pair {
    gap: 2px;
    padding: 2px;
  }

  .duel-label {
    display: none;
  }

  .card-slot {
    min-height: 62px;
  }

  .card-slot .battle-card {
    width: 48px;
    height: 67px;
    border-width: 1px;
  }

  .slot-caption {
    font-size: 0.46rem;
  }

  .player-strip {
    padding: 9px;
  }

  .player-hand {
    justify-content: flex-start;
    min-height: 148px;
  }

  .player-strip > .turn-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .player-strip > .turn-controls .instruction-text {
    grid-column: 1 / -1;
  }

  .clash-zone.single-duel {
    width: min(132px, 96%);
    min-width: 0;
  }

  .confirm-button {
    position: sticky;
    z-index: 8;
    bottom: 8px;
    min-height: 50px;
  }

  .end-dialog {
    width: min(580px, 100%);
  }

  .end-showdown {
    min-height: 150px;
    gap: 18px;
  }

  .end-result-card {
    width: 72px;
  }

  .end-result-mark {
    width: 70px;
    min-width: 70px;
    height: 70px;
    min-height: 70px;
    border-width: 4px;
    font-size: 0.85rem;
  }

  .end-copy {
    padding: 16px 18px 0;
  }

  .end-dialog h2 {
    font-size: 2.45rem;
  }

  .end-stats {
    padding: 0 18px;
  }

  .end-actions {
    padding: 0 18px 18px;
  }

  .pile-dialog {
    padding: 14px;
  }

  .pile-viewer-grid {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    gap: 6px;
  }

  .pile-value-card {
    width: 56px;
    height: 78px;
  }
}

@media (max-width: 400px) {
  .arena {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .player-strip > .turn-controls {
    grid-template-columns: 1fr 1.35fr;
  }

  .pile-viewer-grid {
    grid-template-columns: repeat(5, minmax(40px, 1fr));
    gap: 4px;
  }

  .pile-value-card {
    width: 46px;
    height: 64px;
  }

  .confirm-button,
  .clear-board-button {
    min-width: 0;
    width: 100%;
  }
}

@media (min-width: 821px) and (max-height: 760px) {
  :root {
    --card-width: 84px;
    --card-height: 118px;
  }

  .game-header {
    min-height: 62px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .opponent-strip {
    min-height: 58px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .player-hand {
    min-height: 148px;
    padding-top: 12px;
    padding-bottom: 6px;
  }

  .lane-list {
    gap: 10px;
    padding-top: 24px;
    padding-bottom: 10px;
  }

  .tower-structure {
    min-height: 112px;
  }
}

@media (orientation: landscape) and (max-width: 950px) and (max-height: 540px) {
  :root {
    --card-width: 54px;
    --card-height: 76px;
  }

  body:has(.menu-screen:not([hidden])),
  body:has(.game-screen:not([hidden])) {
    overflow: hidden;
  }

  .menu-screen:not([hidden]) > .menu-board {
    visibility: hidden;
  }

  .menu-screen:not([hidden]) .menu-orientation-lock {
    display: grid;
  }

  .game-screen {
    grid-template-rows: 48px 36px minmax(0, 1fr) 90px 34px;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 4px;
    overflow: hidden;
  }

  .game-header {
    grid-template-columns: 145px minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    gap: 5px;
    min-height: 48px;
    height: 48px;
    padding: 4px 6px;
  }

  .compact-brand {
    gap: 6px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-width: 1px;
    font-size: 0.72rem;
  }

  .compact-brand .eyebrow {
    display: none;
  }

  .compact-brand h1 {
    font-size: 1rem;
  }

  .match-meta {
    grid-row: auto;
    grid-column: auto;
    grid-template-columns: 36px minmax(68px, 1fr) minmax(68px, 1fr) minmax(64px, 1fr) 44px;
    height: 34px;
  }

  .meta-item {
    padding: 3px 4px;
  }

  .meta-item span {
    font-size: 0.44rem;
  }

  .meta-item strong {
    margin-top: 0;
    font-size: 0.62rem;
  }

  .header-actions {
    gap: 3px;
  }

  .utility-button {
    min-height: 32px;
    padding: 0 6px;
    font-size: 0.58rem;
  }

  .opponent-strip {
    grid-template-columns: 96px minmax(0, 1fr) 96px;
    gap: 4px;
    min-height: 36px;
    height: 36px;
    padding: 2px 6px;
  }

  .side-identity {
    gap: 5px;
    font-size: 0.58rem;
  }

  .side-identity strong {
    font-size: 0.66rem;
  }

  .identity-dot {
    width: 8px;
    height: 22px;
  }

  .mini-hand {
    gap: 3px;
    min-width: 0;
  }

  .mini-card {
    width: 20px;
    height: 28px;
    border-radius: 3px;
  }

  .arena {
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    min-height: 0;
    height: auto;
  }

  .core-structure,
  .ai-structure {
    align-content: center;
    padding: 2px;
  }

  .core-gem {
    width: 48px;
    height: 58px;
    margin-top: 0;
  }

  .core-structure > strong {
    max-width: 58px;
    margin-top: 1px;
    font-size: 0.48rem;
  }

  .ai-core-health-display > strong {
    max-width: 58px;
    margin-bottom: 1px;
    font-size: 0.48rem;
  }

  .core-health {
    max-width: 52px;
    gap: 1px;
    margin-top: 2px;
  }

  .core-health .health-pip {
    width: 7px;
    height: 5px;
  }

  .core-structure .health-value {
    margin-top: 1px;
    font-size: 0.48rem;
  }

  .core-pile-button {
    width: 42px;
    min-height: 34px;
    padding: 1px;
  }

  .player-discard-button {
    bottom: 1px;
  }

  .ai-discard-button {
    top: 1px;
  }

  .graveyard-art {
    width: 38px;
    height: 28px;
  }

  .discard-stack {
    right: 0;
    bottom: 2px;
    width: 12px;
    height: 17px;
    border-width: 1px;
  }

  .graveyard-label {
    display: none;
  }

  .territory-label,
  .brush {
    display: none;
  }

  .lane-list {
    gap: 2px;
    min-height: 0;
    padding: 13px 3px 3px;
  }

  .lane {
    --lane-end-width: 52px;
    grid-template-columns: var(--lane-end-width) minmax(0, 1fr) var(--lane-end-width);
  }

  .lane::before {
    right: 14px;
    left: 14px;
    height: 61px;
    border-width: 2px;
    box-shadow: inset 0 0 0 2px rgba(255, 250, 240, 0.22);
  }

  .lane[data-lane="top"]::before {
    right: 14px;
    left: -4px;
  }

  .lane[data-lane="bottom"]::before {
    right: -4px;
    left: 14px;
  }

  .lane-title {
    min-width: 102px;
    padding: 1px 4px;
    font-size: 0.48rem;
  }

  .battle-role-badge {
    min-height: 9px;
    font-size: 0.34rem;
  }

  .lane-track {
    min-height: 68px;
  }

  .tower-structure,
  .tower-gate {
    width: 52px;
    min-height: 66px;
    padding-top: 0;
  }

  .tower-art,
  .tower-gate .tower-art,
  .river-gate .tower-art {
    width: 46px;
    height: 52px;
  }

  .river-gate {
    width: 48px;
    min-height: 66px;
  }

  .tower-structure.destroyed .tower-art,
  .river-gate.destroyed .tower-art {
    width: 38px;
    height: 28px;
    margin-top: 8px;
  }

  .structure-label,
  .river-gate .structure-label {
    display: none;
  }

  .tower-structure .health-pips {
    gap: 1px;
    margin-top: 1px;
  }

  .tower-structure .health-pip {
    width: 7px;
    height: 4px;
  }

  .tower-structure .health-value {
    margin-top: 1px;
    font-size: 0.45rem;
  }

  .open-route-end,
  .lane-fort {
    width: 52px;
  }

  .lane-fort {
    min-height: 62px;
    padding: 0;
  }

  .fort-visual {
    width: 48px;
    height: 43px;
    transform: none;
  }

  .fort-art {
    width: 48px;
    height: 42px;
  }

  .fort-card {
    bottom: 3px;
    width: 18px;
    height: 25px;
  }

  .fort-label {
    display: none;
  }

  .lane-fort > strong {
    font-size: 0.5rem;
  }

  .clash-zone,
  .clash-zone.single-duel {
    width: 116px;
    min-width: 108px;
  }

  .duel-pair {
    gap: 2px;
    padding: 2px;
  }

  .duel-label {
    display: none;
  }

  .card-slot {
    min-height: 54px;
  }

  .card-slot .battle-card {
    width: 38px;
    height: 53px;
    border-width: 1px;
  }

  .slot-caption {
    font-size: 0.42rem;
  }

  .player-strip {
    grid-template-columns: 58px minmax(280px, 1fr) minmax(156px, 188px);
    gap: 4px;
    min-height: 0;
    height: 86px;
    margin-top: 4px;
    padding: 2px 6px;
  }

  .player-strip-heading .side-identity span:not(.identity-dot),
  .player-strip-heading .side-identity strong {
    display: none;
  }

  .player-hand {
    gap: 5px;
    min-height: 82px;
    padding: 3px 0;
  }

  .hand-card:hover:not(:disabled),
  .hand-card:focus-visible {
    transform: translateY(-2px);
  }

  .hand-card.focused-card {
    transform: translateY(-3px) scale(1.06);
  }

  .player-strip > .turn-controls {
    grid-template-columns: 1fr 1.15fr;
    gap: 3px;
    padding: 2px 0 2px 5px;
  }

  .player-strip > .turn-controls .instruction-text {
    grid-column: 1 / -1;
  }

  .instruction-text {
    font-size: 0.55rem;
    line-height: 1.1;
  }

  .confirm-button,
  .clear-board-button {
    min-width: 0;
    min-height: 32px;
    width: 100%;
    padding: 0 4px;
    font-size: 0.58rem;
  }

  .command-area {
    min-height: 30px;
    margin-top: 2px;
  }

  .feedback-panel {
    width: min(220px, 100%);
  }

  .feedback-panel .panel-heading {
    min-height: 30px;
    height: 30px;
    padding: 2px 4px 2px 8px;
  }

  .feedback-panel .section-kicker,
  .log-turn-label {
    display: none;
  }

  .panel-heading h2 {
    font-size: 0.7rem;
  }

  .log-toggle {
    width: 26px;
    height: 26px;
  }

  .collapse-icon {
    top: 7px;
    left: 8px;
  }
}

/* Board-first landscape layout for phones with browser chrome still visible. */
@media (orientation: landscape) and (max-width: 1200px) and (max-height: 650px) {
  :root {
    --card-width: 66px;
    --card-height: 92px;
  }

  html,
  body,
  .app-shell {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .game-screen {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    height: 100svh;
    min-height: 0;
    padding:
      3px max(3px, env(safe-area-inset-right))
      max(3px, env(safe-area-inset-bottom))
      max(3px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .game-header {
    position: absolute;
    z-index: 30;
    top: max(3px, env(safe-area-inset-top));
    right: max(3px, env(safe-area-inset-right));
    left: max(3px, env(safe-area-inset-left));
    display: block;
    min-height: 0;
    height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  .compact-brand {
    display: none;
  }

  .match-meta {
    position: absolute;
    top: 0;
    left: 0;
    grid-template-columns: 38px minmax(78px, 108px);
    width: max-content;
    max-width: 100%;
    height: 28px;
    border-color: rgba(226, 170, 61, 0.66);
    border-radius: 5px;
    background: rgba(7, 20, 46, 0.76);
    box-shadow: 0 3px 8px rgba(4, 13, 35, 0.3);
    color: var(--paper);
    pointer-events: auto;
  }

  .match-meta .player-attack-meta,
  .match-meta .player-defense-meta,
  .match-meta .meta-item:last-child {
    display: none;
  }

  .meta-item {
    padding: 2px 5px;
  }

  .meta-item span {
    color: rgba(255, 250, 240, 0.68);
    font-size: 0.43rem;
  }

  .meta-item strong {
    margin-top: 0;
    color: var(--paper);
    font-size: 0.62rem;
  }

  .header-actions {
    position: absolute;
    top: 0;
    right: 0;
    gap: 3px;
    pointer-events: auto;
  }

  .utility-button {
    min-height: 28px;
    padding: 0 7px;
    border-color: rgba(226, 170, 61, 0.58);
    border-radius: 5px;
    background: rgba(7, 20, 46, 0.72);
    color: var(--paper);
    font-size: 0.58rem;
    box-shadow: 0 3px 8px rgba(4, 13, 35, 0.28);
  }

  .fullscreen-button {
    width: 28px;
    padding: 0;
  }

  .fullscreen-label {
    display: none;
  }

  .fullscreen-icon {
    width: 13px;
    height: 13px;
    flex-basis: 13px;
  }

  .fullscreen-corner {
    width: 5px;
    height: 5px;
  }

  .fullscreen-notice {
    bottom: max(6px, env(safe-area-inset-bottom));
    width: min(380px, calc(100% - 16px));
    padding: 7px 10px;
    font-size: 0.64rem;
  }

  .opponent-strip {
    position: absolute;
    z-index: 24;
    top: max(4px, env(safe-area-inset-top));
    left: 50%;
    display: block;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: 34px;
    padding: 2px 8px 3px;
    border: 1px solid rgba(240, 194, 75, 0.62);
    border-radius: 0 0 8px 8px;
    background: rgba(60, 24, 29, 0.88);
    box-shadow: 0 4px 10px rgba(4, 13, 35, 0.28);
    transform: translateX(-50%);
    pointer-events: none;
  }

  .opponent-strip .side-identity {
    display: none;
  }

  .mini-hand {
    gap: 3px;
    min-width: 0;
  }

  .mini-card {
    width: 20px;
    height: 28px;
    border-radius: 3px;
  }

  .arena {
    z-index: 1;
    grid-row: 1;
    grid-template-columns: 74px minmax(0, 1fr) 74px;
    min-height: 0;
    height: 100%;
    border: 2px solid rgba(226, 170, 61, 0.56);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(4, 13, 35, 0.34);
  }

  .core-structure,
  .ai-structure {
    align-content: center;
    padding: 2px;
  }

  .core-gem {
    width: 62px;
    height: 72px;
    margin-top: 0;
  }

  .core-structure > strong,
  .ai-core-health-display > strong {
    max-width: 68px;
    margin-top: 1px;
    margin-bottom: 1px;
    font-size: 0.5rem;
  }

  .ai-core-health-display {
    margin: 30px 0 0;
  }

  .core-health {
    max-width: 62px;
    gap: 2px;
    margin-top: 2px;
  }

  .core-health .health-pip {
    width: 8px;
    height: 5px;
  }

  .core-structure .health-value {
    margin-top: 1px;
    font-size: 0.49rem;
  }

  .core-pile-button {
    width: 48px;
    min-height: 38px;
    padding: 1px;
  }

  .player-discard-button {
    bottom: 1px;
  }

  .ai-discard-button {
    top: 1px;
  }

  .graveyard-art {
    width: 44px;
    height: 31px;
  }

  .discard-stack {
    right: 0;
    bottom: 2px;
    width: 13px;
    height: 18px;
    border-width: 1px;
  }

  .graveyard-label,
  .territory-label,
  .brush {
    display: none;
  }

  .lane-list,
  .lane-list.simultaneous-battle {
    grid-template-rows: repeat(2, minmax(94px, 112px));
    align-content: space-between;
    gap: 18px;
    min-height: 0;
    padding: 18px 3px 8px;
  }

  .lane {
    --lane-end-width: 58px;
    grid-template-columns: var(--lane-end-width) minmax(0, 1fr) var(--lane-end-width);
    min-height: 0;
  }

  .lane::before {
    top: 2px;
    right: 14px;
    bottom: 2px;
    left: 14px;
    height: auto;
    border-width: 2px;
    box-shadow: inset 0 0 0 2px rgba(255, 250, 240, 0.2);
    transform: none;
  }

  .lane[data-lane="top"]::before {
    right: 14px;
    left: -4px;
  }

  .lane[data-lane="bottom"]::before {
    right: -4px;
    left: 14px;
  }

  .lane-title {
    z-index: 8;
    top: -13px;
    min-width: 112px;
    padding: 2px 6px;
    border-color: rgba(226, 170, 61, 0.68);
    background: rgba(255, 250, 240, 0.96);
    font-size: 0.51rem;
    box-shadow: 0 2px 5px rgba(4, 13, 35, 0.18);
  }

  .lane[data-lane="top"] .lane-title {
    left: 24%;
  }

  .lane[data-lane="bottom"] .lane-title {
    left: 66%;
  }

  .lane-track {
    height: 100%;
    min-height: 0;
  }

  .tower-structure,
  .tower-gate,
  .river-gate,
  .inner-gate {
    width: 56px;
    min-height: 70px;
    padding-top: 0;
  }

  .tower-art,
  .tower-gate .tower-art,
  .river-gate .tower-art,
  .inner-gate .tower-art {
    width: 50px;
    height: 53px;
  }

  .tower-structure.destroyed .tower-art,
  .river-gate.destroyed .tower-art,
  .inner-gate.destroyed .tower-art {
    width: 42px;
    height: 30px;
    margin-top: 10px;
  }

  .structure-label,
  .river-gate .structure-label,
  .inner-gate .structure-label {
    display: none;
  }

  .tower-structure .health-pips {
    gap: 1px;
    margin-top: 1px;
  }

  .tower-structure .health-pip {
    width: 8px;
    height: 5px;
  }

  .tower-structure .health-value {
    margin-top: 1px;
    font-size: 0.46rem;
  }

  .open-route-end,
  .lane-fort {
    width: 58px;
  }

  .lane-fort {
    min-height: 70px;
    padding: 0;
    background: rgba(255, 250, 240, 0.14);
  }

  .fort-visual,
  .fort-art {
    width: 54px;
    height: 48px;
    transform: none;
  }

  .fort-card {
    bottom: 2px;
    width: 19px;
    height: 27px;
  }

  .fort-label {
    display: none;
  }

  .lane-fort > strong {
    font-size: 0.5rem;
  }

  .clash-zone,
  .clash-zone.single-duel,
  .frontline-player-inner .clash-zone.single-duel,
  .frontline-ai-inner .clash-zone.single-duel,
  .frontline-player-core .clash-zone.single-duel,
  .frontline-ai-core .clash-zone.single-duel {
    width: 132px;
    min-width: 132px;
  }

  .duel-pair {
    gap: 3px;
    padding: 3px;
    background: rgba(255, 250, 240, 0.56);
  }

  .duel-label {
    display: none;
  }

  .card-slot {
    min-height: 74px;
  }

  .player-placement-slot::before {
    inset: -16px -14px;
  }

  .card-slot .battle-card,
  .frontline-player-inner .card-slot .battle-card,
  .frontline-ai-inner .card-slot .battle-card,
  .frontline-player-core .card-slot .battle-card,
  .frontline-ai-core .card-slot .battle-card {
    width: 51px;
    height: 71px;
    border-width: 1px;
  }

  .slot-caption {
    padding: 2px;
    font-size: 0.43rem;
  }

  .battle-role-badge {
    right: 1px;
    bottom: 1px;
    left: 1px;
    min-height: 10px;
    padding: 1px;
    font-size: 0.34rem;
  }

  .player-strip {
    position: absolute;
    z-index: 20;
    top: max(3px, env(safe-area-inset-top));
    right: max(3px, env(safe-area-inset-right));
    bottom: max(3px, env(safe-area-inset-bottom));
    left: max(3px, env(safe-area-inset-left));
    display: block;
    min-height: 0;
    height: auto;
    margin-top: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  .player-strip-heading {
    display: none;
  }

  .player-hand {
    position: absolute;
    top: 50%;
    left: 82px;
    justify-content: center;
    gap: 0;
    width: min(310px, calc(100% - 300px));
    min-width: 250px;
    min-height: 88px;
    height: 88px;
    padding: 4px 8px 3px;
    overflow: visible;
    border: 1px solid rgba(255, 250, 240, 0.48);
    border-radius: 8px;
    background: rgba(7, 20, 46, 0.3);
    box-shadow: 0 6px 14px rgba(4, 13, 35, 0.22), inset 0 0 18px rgba(98, 213, 239, 0.08);
    backdrop-filter: blur(2px);
    transform: translateY(-50%);
    pointer-events: auto;
  }

  .player-hand .hand-card {
    flex: 0 0 auto;
    width: 58px;
    height: 81px;
    margin-left: -5px;
    transform-origin: center bottom;
    box-shadow: 0 5px 8px rgba(4, 13, 35, 0.46);
  }

  .player-hand .hand-card:first-child {
    margin-left: 0;
  }

  .hand-card:hover:not(:disabled),
  .hand-card:focus-visible {
    transform: translateY(-5px);
  }

  .hand-card.focused-card {
    z-index: 6;
    transform: translateY(-7px) scale(1.07);
  }

  .player-strip > .turn-controls {
    position: static;
    display: block;
    padding: 0;
    border-top: 0;
    border-left: 0;
  }

  .player-strip > .turn-controls .instruction-text {
    display: none;
  }

  .confirm-button,
  .clear-board-button {
    position: absolute;
    right: 86px;
    min-width: 0;
    width: 126px;
    padding: 0 5px;
    font-size: 0.6rem;
    pointer-events: auto;
  }

  .confirm-button {
    top: calc(50% - 34px);
    min-height: 42px;
    box-shadow: 0 5px 10px rgba(4, 13, 35, 0.32), inset 0 -3px 0 rgba(116, 73, 20, 0.25);
  }

  .clear-board-button {
    top: calc(50% + 12px);
    min-height: 25px;
    border-color: rgba(255, 250, 240, 0.34);
    background: rgba(7, 20, 46, 0.42);
    color: var(--paper);
  }

  .command-area {
    display: none;
  }

  .feedback-panel {
    right: 0;
    bottom: 0;
    width: 154px;
    background: rgba(255, 250, 240, 0.94);
    box-shadow: 0 4px 12px rgba(4, 13, 35, 0.3);
  }

  .feedback-panel.expanded {
    width: min(410px, calc(100vw - 16px));
  }

  .feedback-panel .panel-heading {
    min-height: 27px;
    height: 27px;
    padding: 2px 3px 2px 7px;
  }

  .feedback-panel .section-kicker,
  .log-turn-label {
    display: none;
  }

  .panel-heading h2 {
    font-size: 0.64rem;
  }

  .log-toggle {
    width: 23px;
    height: 23px;
  }

  .collapse-icon {
    top: 6px;
    left: 7px;
  }

  .battle-log {
    max-height: min(118px, calc(100svh - 170px));
    padding: 7px 10px 8px 25px;
    font-size: 0.64rem;
  }
}

@media (orientation: portrait) and (max-width: 640px) {
  body:has(.game-screen:not([hidden])) {
    overflow: hidden;
  }

  .game-screen:not([hidden]) {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .game-screen:not([hidden]) > :not(.game-orientation-lock) {
    visibility: hidden;
  }

  .game-screen:not([hidden]) .game-orientation-lock {
    display: grid;
  }
}

@media (orientation: portrait) and (max-width: 640px),
  (orientation: landscape) and (max-width: 950px) and (max-height: 540px) {
  .orientation-lock {
    position: fixed;
    z-index: 1000;
    inset: 0;
    align-content: center;
    justify-items: center;
    gap: 8px;
    padding: 28px;
    background:
      linear-gradient(rgba(7, 20, 46, 0.88), rgba(7, 20, 46, 0.96)),
      url("assets/menu/jellykid-high-card-havoc-home.png") center / cover no-repeat;
    color: var(--paper);
    text-align: center;
  }

  .orientation-lock strong {
    margin-top: 8px;
    font-size: 1.35rem;
    text-transform: uppercase;
  }

  .orientation-lock > span:last-child {
    color: #9bdff0;
    font-size: 0.82rem;
    font-weight: 800;
  }

  .orientation-phone {
    position: relative;
    display: block;
    width: 54px;
    height: 82px;
    border: 4px solid #fffaf0;
    border-radius: 8px;
    background: rgba(98, 213, 239, 0.18);
    box-shadow: 0 0 0 5px rgba(98, 213, 239, 0.15);
  }

  .orientation-phone::after {
    position: absolute;
    bottom: 5px;
    left: 50%;
    width: 10px;
    height: 3px;
    border-radius: 2px;
    background: #fffaf0;
    content: "";
    transform: translateX(-50%);
  }

  .landscape-phone {
    transform: rotate(90deg);
  }
}

@media (orientation: landscape) and (max-height: 650px) {
  .modal-backdrop {
    padding: 8px;
  }

  .end-dialog {
    max-height: calc(100dvh - 16px);
  }

  .end-showdown {
    min-height: 112px;
  }

  .end-result-card {
    width: 58px;
  }

  .end-result-mark {
    width: 58px;
    min-width: 58px;
    height: 58px;
    min-height: 58px;
    padding: 6px;
    border-width: 3px;
    font-size: 0.72rem;
  }

  .end-copy {
    padding: 10px 18px 0;
  }

  .end-dialog h2 {
    font-size: 2rem;
  }

  .end-subtitle {
    margin-top: 4px;
    font-size: 0.82rem;
  }

  .end-stats {
    margin: 10px 0;
  }

  .end-stats div {
    padding: 5px 7px;
  }

  .end-stats dt {
    font-size: 0.58rem;
  }

  .end-stats dd {
    margin-top: 2px;
    font-size: 1rem;
  }

  .end-actions {
    padding-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
