:root {
  color-scheme: dark;
  --bg: #0c1213;
  --panel: #151e20;
  --surface: #1c292a;
  --line: #334642;
  --ink: #edf0e1;
  --muted: #b1c1b9;
  --gold: #efca8b;
  --mint: #c8e4ac;
  --pad: clamp(.55rem, 1.6vw, 1.25rem);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 40% -30%, #283a30, transparent 63%), var(--bg);
  color: var(--ink);
}
a { color: var(--gold); text-underline-offset: .17em; }
button, select, input { font: inherit; }
button, .cloud-actions a {
  min-height: 2.75rem;
  padding: .52rem .72rem;
  border: 1px solid var(--line);
  border-radius: .62rem;
  background: #223031;
  color: var(--ink);
  text-decoration: none;
  font-weight: 690;
  cursor: pointer;
}
button:hover:not(:disabled), .cloud-actions a:hover { background: #30433e; border-color: #769085; }
button:active:not(:disabled) { background: #3a5148; }
button:disabled { cursor: default; opacity: .56; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
summary { cursor: pointer; }
small { color: var(--muted); }
h1, h2, h3, p { margin: 0; }
.shell {
  --cabinet-height: clamp(29rem, calc(100svh - 8.5rem), 57rem);
  max-width: 1650px;
  min-width: 0;
  margin-inline: auto;
  padding: max(var(--pad), env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right))
    max(var(--pad), env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
}
.topbar {
  min-height: 3.25rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .55rem;
  padding-bottom: .6rem;
}
.topbar .back { justify-self: start; padding: .55rem .3rem; color: var(--muted); text-decoration: none; }
.brand {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  font-weight: 540;
  letter-spacing: -.035em;
  line-height: 1;
  color: #f3eccf;
}
.brand span { color: var(--gold); font-size: .65em; vertical-align: 11%; }
#fullscreen { justify-self: end; white-space: nowrap; }
#fullscreen[aria-pressed="true"] { color: var(--gold); border-color: #80694a; }
.cabinet-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(15rem, 23vw, 19.25rem);
  gap: .75rem;
  height: var(--cabinet-height);
}
.playfield { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: .52rem; min-width: 0; min-height: 0; }
.hud {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: .72rem;
  background: var(--panel);
}
.hud > div { display: grid; align-content: center; gap: .15rem; padding: .52rem .8rem; min-width: 0; }
.hud > div + div { border-left: 1px solid var(--line); }
.hud small { font-size: .63rem; text-transform: uppercase; letter-spacing: .11em; }
.hud strong { font-size: clamp(.72rem, 1.7vw, .95rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hud .region strong { color: var(--gold); }
.screen-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #506253;
  border-radius: .78rem;
  background: #111b18;
  box-shadow: 0 .75rem 2.15rem #070b0a66;
}
#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.field-notice {
  min-height: 2rem;
  max-height: 3.2rem;
  overflow: auto;
  padding: .36rem .55rem;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
}
.trainer-panel {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  align-self: start;
  max-height: 100%;
  padding: .76rem;
  display: grid;
  gap: .66rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: linear-gradient(145deg, #1c2927, #131c1e 55%);
}
.trainer-summary h2 {
  color: var(--gold);
  font-size: .71rem;
  letter-spacing: .13em;
  text-transform: uppercase;
}
#party-summary { margin-block: .25rem; color: var(--ink); font-size: .85rem; overflow-wrap: anywhere; }
#progress { font-size: .72rem; }
.play-controls, .movement-controls { display: grid; gap: .6rem; }
.movement-controls { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.dpad {
  display: grid;
  grid: repeat(3, 2.55rem) / repeat(3, 2.55rem);
  gap: .12rem;
  touch-action: none;
  user-select: none;
  justify-content: center;
}
.dpad button { min-height: 0; padding: 0; color: var(--mint); line-height: 1; }
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.dpad button::before {
  content: "";
  display: block;
  width: .48rem;
  height: .48rem;
  margin-inline: auto;
  border: solid currentColor;
  border-width: .14rem .14rem 0 0;
  transform: rotate(-45deg);
}
.dpad .left::before { transform: rotate(-135deg); }
.dpad .right::before { transform: rotate(45deg); }
.dpad .down::before { transform: rotate(135deg); }
.dpad::after {
  content: "";
  grid-area: 2 / 2;
  align-self: center;
  justify-self: center;
  width: .75rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #4d5a45;
  box-shadow: 0 0 0 .37rem #202e27;
}
.interact { background: #334432; border-color: #64795a; color: #e6edca; line-height: 1.24; }
.interact small { display: block; margin-top: .18rem; font-size: .62rem; }
.quickbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .36rem; }
.quickbar button { min-width: 0; padding-inline: .19rem; font-size: .77rem; }
.trainer-services {
  padding: .58rem .62rem;
  border: 1px solid var(--line);
  border-radius: .58rem;
  background: #101a1b;
}
.trainer-services summary { color: var(--mint); font-size: .83rem; font-weight: 680; padding-block: .18rem; }
.trainer-services[open] > summary { margin-bottom: .55rem; }
.service-content { display: grid; gap: .65rem; }
.online-panel, .cloud-panel { display: grid; gap: .42rem; overflow-wrap: anywhere; }
.online-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .35rem; }
.online-panel h2, .cloud-panel h2 { color: var(--gold); font-size: .85rem; }
.online-heading > span { font-size: .58rem; color: var(--muted); }
#online-status, #cloud-status, .hint { color: var(--muted); font-size: .75rem; line-height: 1.48; }
.cloud-actions, .online-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.cloud-actions button, .online-actions button, .cloud-actions a { padding: .38rem .52rem; font-size: .74rem; }
.cloud-panel { padding-top: .65rem; border-top: 1px solid var(--line); }
.online-details, .journal { padding-top: .36rem; font-size: .72rem; color: var(--muted); line-height: 1.45; }
.online-details ul { margin: .25rem 0 .5rem; padding-left: 1rem; }
.online-details li { padding-block: .18rem; }
.online-details li small { display: block; }
.online-details .quest-done strong { color: var(--mint); }
.journal p + p { margin-top: .38rem; }
footer { display: flex; justify-content: center; gap: .85rem; padding: .65rem 0 0; font-size: .72rem; }
footer a { color: var(--muted); }

.cabinet-expanded { overflow: hidden; }
.shell:fullscreen, .shell.is-expanded {
  --cabinet-height: auto;
  width: 100%;
  height: 100%;
  max-width: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #0d1515;
  overflow: auto;
  overscroll-behavior: contain;
}
.shell.is-expanded { position: fixed; inset: 0; z-index: 10; height: 100dvh; }
.shell:is(:fullscreen, .is-expanded) footer { display: none; }
.shell:is(:fullscreen, .is-expanded) .topbar { position: sticky; top: 0; z-index: 5; background: #0d1515; }

.overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  align-items: safe center;
  justify-items: center;
  padding: max(.55rem, env(safe-area-inset-top)) max(.55rem, env(safe-area-inset-right))
    max(.55rem, env(safe-area-inset-bottom)) max(.55rem, env(safe-area-inset-left));
  overflow: auto;
  overscroll-behavior: contain;
  background: #090f13cf;
}
.window {
  width: min(100%, 43rem);
  max-height: 100%;
  overflow: auto;
  padding: clamp(.68rem, 2vw, 1.15rem);
  border: 1px solid #52685a;
  border-radius: .9rem;
  background: #152023;
  box-shadow: 0 1rem 4rem #0009;
}
.window h2 { color: var(--gold); font-family: "Instrument Serif", Georgia, serif; font-size: 1.65rem; font-weight: 550; }
.window-top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding-bottom: .5rem; background: #152023; }
.menu-body { display: grid; gap: .65rem; color: var(--muted); font-size: .88rem; }
.starter-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-top: .8rem; }
.starter-options button { display: grid; align-content: center; justify-items: center; min-width: 0; padding: .65rem .2rem; }
.starter-options button:nth-child(1) { background: #25372b; }
.starter-options button:nth-child(2) { background: #412f2c; }
.starter-options button:nth-child(3) { background: #233645; }
.starter-portrait, .battle-stage canvas { image-rendering: pixelated; }
.starter-portrait { display: block; width: min(100%, 6.5rem); height: auto; }
.starter-options small { margin-top: .2rem; font-size: .66rem; overflow-wrap: anywhere; }
.creature-line, .shop-row { display: grid; gap: .42rem; padding: .65rem; background: #202e30; border: 1px solid var(--line); border-radius: .55rem; }
.shop-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .38rem; }
.inline-actions button, .shop-row button { font-size: .8rem; }
.dex-controls, .dex-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.dex-controls label { display: grid; gap: .22rem; }
.dex-controls input, .dex-controls select {
  min-width: 0;
  width: 100%;
  padding: .58rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #102022;
  color: var(--ink);
}
.dex-list > div { display: flex; flex-wrap: wrap; gap: .42rem; align-items: center; padding: .48rem; border: 1px solid var(--line); border-radius: .4rem; font-size: .74rem; }
.dex-list .unknown { color: var(--muted); }
.dex-list .caught { color: var(--mint); }
.dex-list [hidden] { display: none; }
#field-map{ width: min(100%, 512px); margin-inline: auto; border: 1px solid var(--line); image-rendering: pixelated; }

.battle-window { display: grid; grid-template-rows: auto minmax(8rem, 1fr) auto; width: min(100%, 53rem); min-height: 0; height: min(49rem, 100%); gap: .55rem; }
.battle-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #667861;
  border-radius: .65rem;
  background: #273a38 url("art/twilight-clearing.webp") center 60% / cover no-repeat;
}
.battle-stage::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, #10202a0a, #0a10193b); }
.battle-stage[data-biome="marsh"]::after { background: #205d5c3f; }
.battle-stage[data-biome="ridge"]::after { background: #391d6152; }
.enemy-slot, .ally-slot { display: grid; align-items: center; grid-template-columns: auto auto; position: absolute; gap: .35rem; }
.enemy-slot { bottom: 38%; right: 10%; }
.ally-slot { bottom: 6%; left: 6%; }
.battle-stage canvas { width: clamp(4.3rem, min(23vw, 19svh), 9.5rem); height: auto; filter: drop-shadow(0 .4rem .22rem #090d12ac); }
.battle-label { min-width: 7.5rem; padding: .52rem; border: 1px solid #93a18a; border-radius: .48rem; background: #151e20eb; }
.battle-label strong { font-size: .8rem; }
.battle-label small { font-size: .66rem; }
.health { display: block; height: .42rem; margin: .32rem 0 .13rem; overflow: hidden; border-radius: .4rem; background: #384348; }
.health > span { display: block; height: 100%; transition: width .22s; }
.battle-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: .48rem .65rem; }
.battle-bottom h3 { margin-bottom: .34rem; color: var(--gold); text-transform: uppercase; letter-spacing: .11em; font-size: .65rem; }
.battle-notes, .switch-group { grid-column: 1 / -1; }
.battle-notes { max-height: 3.7rem; min-height: 1.7rem; overflow: auto; padding: .38rem .55rem; background: #0e181b; border-radius: .4rem; font-size: .77rem; line-height: 1.42; }
.battle-notes p + p { margin-top: .18rem; color: var(--muted); }
.move-grid, .item-grid, .battle-healing > div, #battle-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .34rem; }
.move-grid button, .item-grid button, #battle-switch button { padding: .34rem .4rem; font-size: .72rem; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.move-grid button { display: grid; align-content: center; gap: .12rem; }
.move-grid button span { color: var(--muted); font-size: .62rem; }
.battle-healing, .switch-group { padding: .4rem .5rem; color: var(--muted); border: 1px solid var(--line); border-radius: .4rem; font-size: .73rem; }
.battle-healing { grid-column: 1 / -1; }
.battle-healing[open] > div, .switch-group[open] > div { margin-top: .35rem; }

@media (max-width: 850px) and (orientation: portrait) {
  .cabinet-layout { height: auto; grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  .playfield { grid-template-rows: auto clamp(14rem, 50svh, 35rem) auto; gap: .36rem; }
  .trainer-panel { overflow: visible; max-height: none; align-self: stretch; padding: .58rem; gap: .45rem; }
  .trainer-summary { order: 1; }
  .trainer-summary h2 { display: none; }
  .trainer-services { order: 2; }
  .movement-controls { grid-template-columns: 1fr minmax(6rem, 1fr); max-width: 27rem; width: 100%; justify-self: center; }
  .interact { min-height: 3rem; }
  .quickbar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .shell:is(:fullscreen, .is-expanded) { display: block; }
  .shell:is(:fullscreen, .is-expanded) .playfield { grid-template-rows: auto clamp(10rem, calc(100dvh - 22rem), 60dvh) auto; }
}
@media(max-width:520px) {
  .topbar { gap: .22rem; }
  .topbar .back, #fullscreen { font-size: .69rem; }
  .brand { font-size: clamp(1.45rem, 7vw, 1.9rem); }
  .hud { grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(0, 1fr)); }
  .hud > div { padding: .38rem .3rem; }
  .hud small { font-size: .53rem; }
  .field-notice { font-size: .75rem; }
  .starter-options { gap: .3rem; }
  .battle-window { gap: .38rem; }
  .battle-label { min-width: 6.5rem; padding: .3rem; }
  .battle-label strong { font-size: .72rem; }
  .enemy-slot { right: 4%; }
  .ally-slot { left: 4%; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .shell { --cabinet-height: max(15.5rem, calc(100svh - 4.1rem)); }
  .topbar { min-height: 2.45rem; padding-bottom: .35rem; }
  .topbar a, #fullscreen { min-height: 2.1rem; font-size: .73rem; }
  .brand { font-size: 1.65rem; }
  .cabinet-layout { grid-template-columns: minmax(0, 1fr) minmax(11rem, 25vw); gap: .42rem; }
  .trainer-panel { padding: .38rem; gap: .36rem; }
  .trainer-summary { display: none; }
  .dpad { grid-template: repeat(3, 1.75rem)/repeat(3, 1.75rem); }
  .movement-controls, .play-controls { gap: .25rem; }
  .quickbar button, .interact { min-height: 2.15rem; font-size: .68rem; }
  .trainer-services { padding: .22rem .4rem; }
  .hud > div { padding: .25rem .46rem; }
  .field-notice { min-height: 1.35rem; padding: .12rem .3rem; }
  .battle-window { grid-template-columns: minmax(0, 1.1fr) minmax(14rem, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .battle-caption { grid-column: 1 / -1; }
  .battle-stage canvas { width: clamp(3.5rem, 19svh, 7rem); }
  .battle-bottom { max-height: 100%; overflow: auto; align-content: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Cinderwild's field guide uses iron, brass, and the colors of the local terrain. */
:root {
  --bg: #111211;
  --panel: #25251c;
  --surface: #292920;
  --line: #57513d;
  --ink: #faf0da;
  --muted: #c5bea9;
  --gold: #ffd096;
  --mint: #b6d49f;
}
body {
  background: radial-gradient(ellipse at center top, #4a3a27 0, #251f19 38rem, #121210 86rem);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .42em;
  color: #fee5ae;
  font-variant: small-caps;
  letter-spacing: .035em;
  text-shadow: 0 2px #110f0d, 0 0 24px #dd904869;
}
.brand span {
  display: grid;
  place-items: center;
  width: 1.38em;
  aspect-ratio: 1;
  border: 1px solid #9d774a;
  border-radius: .2em;
  background: radial-gradient(#684b2c, #2a2219);
}
.hud {
  border-color: #817354;
  background: linear-gradient(166deg, #403724, #26261c 85%);
  box-shadow: inset 0 1px #d4b27c44, 0 3px 8px #0a090765;
}
.hud .region {
  border-radius: .65rem 0 0 .65rem;
  background: linear-gradient(125deg, #6a4e2d80, #302b2222);
}
.hud small { color: #c6b59a; }
.hud strong { color: var(--ink); font-size: clamp(.72rem, 1.7vw, 1rem); }
.hud .region strong { font-family: "Instrument Serif", Georgia, serif; font-size: clamp(.85rem, 2.1vw, 1.24rem); }
.screen-frame {
  border-color: #927853;
  box-shadow: 0 0 0 2px #282518, 0 .85rem 1.6rem #100c0995;
}
.screen-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 1.25rem #070e0eb3, inset 0 0 0 1px #dec48442;
}
.trainer-panel {
  background: linear-gradient(145deg, #3d3627, #28271e 74%);
  border-color: #786648;
  box-shadow: inset 0 1px #ad8a5c55, 0 8px 24px #090a0777;
}
.trainer-summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
  padding: .35rem .45rem;
  border: 1px solid #77634a;
  border-radius: .52rem;
  background: #241f19;
}
.trainer-summary h2, .trainer-summary p { margin: 0; }
.trainer-summary > div:last-child { min-width: 0; }
.creature-portrait {
  display: block;
  width: 3.4rem;
  flex: 0 0 auto;
  aspect-ratio: 1;
  border-radius: .42rem;
  background-color: #100f123d;
  background-image: var(--portrait);
  background-size: var(--atlas);
  background-position: var(--portrait-pos);
}
.quickbar button, .dpad button, .trainer-services, #fullscreen {
  background: linear-gradient(#3f3c2d, #29291f);
  border-color: #716647;
  box-shadow: inset 0 1px #c3a67132;
}
.trainer-services summary { color: #e9cba2; }
button:hover:not(:disabled) { border-color: #bba172; }
.interact {
  background: linear-gradient(#556646, #384632);
  border-color: #8c9a69;
  color: #f5efcc;
  box-shadow: inset 0 1px #e2edaa33, 0 .13rem .35rem #191b15;
}
.interact small { color: #deddb9; }
.field-notice { color: #e8d6ac; }
.shell:is(:fullscreen, .is-expanded), .shell:is(:fullscreen, .is-expanded) .topbar { background: #201d17; }
.window, .window-top {
  background: #2d2a22;
  color: var(--ink);
}
.window {
  border-color: #967f56;
  box-shadow: inset 0 1px #e9c18945, 0 1rem 4rem #000c;
}
.window h2 { color: #ffdaa3; }
.starter-window {
  background: linear-gradient(#211b1bb8, #231e1aec), url("art/twilight-clearing.webp") center 55% / cover;
}
.starter-window h2 {
  font-size: clamp(1.35rem, 5vw, 2.2rem);
  text-align: center;
  text-shadow: 0 2px #190d0a;
}
.starter-options button {
  background: radial-gradient(var(--element), #272322 72%) !important;
  border: 1px solid var(--element);
  box-shadow: inset 0 0 0 2px #e6d1b12c;
}
[data-element="grass"], [data-element="thorn"] { --element: #77965b; }
[data-element="fire"] { --element: #b87950; }
[data-element="water"] { --element: #5d9baf; }
[data-element="ghost"], [data-element="cosmic"] { --element: #aa8bc5; }
[data-element="electric"] { --element: #c5aa64; }
[data-element="stone"], [data-element="normal"] { --element: #93816b; }
[data-element="air"] { --element: #82a6ad; }
.starter-portrait { width: min(100%, 8.85rem); filter: drop-shadow(0 7px 5px #171318); }
.starter-options small { color: #fff0d3; text-transform: uppercase; letter-spacing: .11em; }
.battle-stage { border-color: #ad9363; }
.battle-stage[data-biome="marsh"] { background-image: url("art/lantern-marsh.webp"); }
.battle-stage[data-biome="ridge"] { background-image: url("art/eclipse-ridge.webp"); }
.battle-stage[data-biome="marsh"]::after, .battle-stage[data-biome="ridge"]::after { background: linear-gradient(transparent, #0509143b); }
.battle-label {
  border-color: #af9b73;
  background: #201e19ef;
  box-shadow: 0 2px 6px #110e0e95;
}
.battle-stage canvas { width: clamp(4.3rem, min(26vw, 23svh), 12rem); }
.move-grid button {
  background: linear-gradient(150deg, #383327, #29251c);
  border-color: var(--element);
}
.battle-notes { background: #211e18; }
.creature-line:has(.creature-portrait) { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.creature-line .creature-portrait { grid-row: span 2; }
.creature-line .health, .creature-line .inline-actions { grid-column: 1 / -1; }
.dex-list > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .2rem .55rem;
  color: var(--ink);
  background: #252218;
}
.dex-list .creature-portrait { grid-row: span 3; }
.dex-list .entry-number { font-size: .64rem; color: #c3b38b; }
.mystery-portrait {
  display: grid;
  place-items: center;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.8rem;
  color: #90836b;
}
@media (max-width: 550px) {
  .dex-list { grid-template-columns: minmax(0, 1fr); }
  .trainer-summary { padding: .27rem .4rem; }
  .trainer-summary .creature-portrait { width: 2rem; }
  .brand { letter-spacing: 0; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .battle-stage canvas { width: clamp(3.5rem, 22svh, 8.5rem); }
}

/* Fullscreen is a playable cabinet, not a letterboxed screenshot. Give the
   canvas the remaining viewport and keep the party controls reachable. */
.shell:is(:fullscreen, .is-expanded) {
  --cabinet-height: 100%;
  overflow: hidden;
}
.shell:is(:fullscreen, .is-expanded) .cabinet-layout {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}
.shell:is(:fullscreen, .is-expanded) .playfield {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.shell:is(:fullscreen, .is-expanded) .screen-frame { min-height: 0; }
.shell:is(:fullscreen, .is-expanded) .trainer-panel {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 850px) and (orientation: portrait) {
  .shell:is(:fullscreen, .is-expanded) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .shell:is(:fullscreen, .is-expanded) .cabinet-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: .35rem;
  }
  .shell:is(:fullscreen, .is-expanded) .playfield {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .shell:is(:fullscreen, .is-expanded) .trainer-panel {
    align-self: stretch;
    max-height: clamp(10rem, 34svh, 17rem);
  }
}
