@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Marcellus&display=swap");
:root {
  font-family: "DM Sans", sans-serif;
  color: #e5e7df;
  background: #101c23;
  font-synthesis: none;
  --gold: #d9be7f;
  --teal: #8ce0c6;
  --muted: #91a6a5;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 10%, #1c363d 0, transparent 65%), #101c23;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  font: inherit;
  color: inherit;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
[hidden] {
  display: none !important;
}
main {
  max-width: 1100px;
  margin: auto;
  padding: 0 38px;
}
.topbar {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar a {
  text-decoration: none;
  color: #e8e6d9;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  letter-spacing: 3px;
}
.topbar small {
  display: block;
  font-size: 8px;
  letter-spacing: 2.6px;
  color: var(--muted);
  margin-top: 5px;
}
.brand-mark {
  font-size: 39px;
  color: var(--gold);
}
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid #4f626355;
  border-radius: 50%;
  background: #24373b66;
  font-size: 19px;
}
.icon-button:hover {
  background: #425d5d;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gold);
  font-weight: 700;
}
h1,
h2 {
  font-family: Marcellus, Georgia, serif;
  font-weight: 400;
}
h1 {
  font-size: 47px;
  line-height: 1.16;
  letter-spacing: -1px;
  margin: 20px 0;
}
h1 em {
  font-style: normal;
  color: #bddece;
}
.primary {
  display: inline-flex;
  gap: 35px;
  align-items: center;
  justify-content: center;
  border: 1px solid #b4ebd4;
  border-radius: 7px;
  background: #a2dfc7;
  color: #163d36;
  padding: 15px 25px;
  font-weight: 700;
  font-size: 12px;
  box-shadow:
    0 3px 0 #568974,
    0 10px 25px #061b2155;
  transition:
    transform 0.15s,
    filter 0.15s;
}
.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.primary:active {
  transform: translateY(2px);
  box-shadow: none;
}
footer {
  display: flex;
  justify-content: space-between;
  padding: 22px 0 30px;
  border-top: 1px solid #53666444;
  font-size: 8px;
  color: #718b87;
}
footer span:first-child {
  letter-spacing: 1.7px;
}
#game-screen {
  max-width: 740px;
  margin: 0 auto;
}
.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.game-heading > span {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gold);
}
.text-button {
  background: none;
  border: 0;
  padding: 8px 0;
  color: #a9c6bb;
  font-size: 11px;
}
.scoreboard {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.score-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: #1c3036;
  border: 1px solid #52726c55;
  border-radius: 9px;
  padding: 8px;
}
.score-chip.dead {
  opacity: 0.4;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia;
  font-size: 22px;
  background: var(--color);
  color: #132a30;
}
.score-chip strong {
  display: block;
  font-size: 11px;
  font-weight: 500;
}
.score-chip small {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}
.arena-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 3px 12px;
  color: #8caaa1;
  font-size: 9px;
  letter-spacing: 1px;
}
.arena-caption strong {
  font-size: 20px;
  color: #dfddc2;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.arena-caption strong.hurry {
  color: #f3ad87;
}
.live-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #8cd5b5;
  border-radius: 50%;
  margin-right: 5px;
}
.arena-wrap {
  position: relative;
  padding: 7px;
  background: #334842;
  border: 1px solid #77938166;
  border-radius: 13px;
  box-shadow:
    0 16px 55px #0005,
    inset 0 0 0 3px #1d302d;
}
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 13/11;
  border-radius: 7px;
  touch-action: none;
}
#game-overlay {
  position: absolute;
  inset: 7px;
  z-index: 2;
  background: #0e222ae8;
  backdrop-filter: blur(5px);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 20px;
}
.overlay-rune {
  font-size: 55px;
  color: var(--gold);
  margin-bottom: 14px;
}
#overlay-title {
  font-size: 38px;
  margin: 12px 0;
  color: #edf1dc;
}
#overlay-copy {
  max-width: 310px;
  color: #aac6bb;
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 20px;
}
#overlay-home {
  margin-top: 17px;
}
.inventory { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 52px; gap: 7px; }
.stat-card { position: relative; min-width: 0; padding: 8px; border: 1px solid #688a7d66; border-radius: 10px; background: #1c3036; }
.stat-heading { display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.stat-reading { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 0; }
.stat-reading > span { font-size: 8px; line-height: 9px; color: #b9cec2; }
.pickup-art { display: inline-grid; flex: 0 0 28px; width: 28px; height: 28px; place-items: center; }
.pickup-art > * { grid-area: 1 / 1; }
.pickup-art svg { display: block; width: 100%; height: 100%; overflow: hidden; visibility: hidden; }
.pickup-fallback { font-size: 23px; line-height: 1; color: #ffe5ac; }
.pickup-art.art-ready svg { visibility: visible; }
.pickup-art.art-ready .pickup-fallback { display: none; }
.stat-heading strong { font-size: 25px; line-height: 1; color: #f2f1db; font-variant-numeric: tabular-nums; }
.stat-card small { display: block; color: #aac5bb; font-size: 8px; letter-spacing: .4px; margin-top: 6px; }
.stat-meter { display: flex; align-items: flex-end; gap: 4px; height: 21px; margin-top: 7px; }
.stat-meter i { flex: 1; min-width: 0; height: 13px; border: 1px solid #809a8b88; background: #0f242b; border-radius: 2px; }
.stat-meter i.filled { background: var(--gold); border-color: #f9e1a5; }
.capacity-meter { padding-top: 4px; }
.capacity-meter i { position: relative; height: 16px; border-radius: 3px 3px 5px 5px; opacity: .25; }
.capacity-meter i::before { content: ""; position: absolute; width: 50%; height: 4px; left: 25%; top: -5px; background: #8cae9e; border-radius: 1px; }
.capacity-meter i.owned { opacity: 1; border-style: dashed; }
.capacity-meter i.filled { border-style: solid; background: var(--teal); border-color: #c9ffec; }
.speed-meter i:nth-child(1) { height: 7px; }
.speed-meter i:nth-child(2) { height: 10px; }
.speed-meter i:nth-child(3) { height: 13px; }
.speed-meter i:nth-child(4) { height: 17px; }
.speed-meter i:nth-child(5) { height: 21px; }
.speed-meter i.filled { background: #b6aff5; border-color: #e7dfff; }
.upgrade-badge { display: none; position: absolute; top: -12px; right: 5px; background: #dbeebe; color: #12372c; border-radius: 7px; padding: 2px 5px; font-size: 13px; }
.upgraded { animation: stat-upgrade 1.2s ease-out; }
.upgraded .upgrade-badge { display: block; }
@keyframes stat-upgrade { from { border-color: #f5ed98; background: #60774c; } to { border-color: #688a7d66; background: #1c3036; } }
#abilities { display: grid; grid-template-rows: 1fr 1fr; gap: 3px; min-width: 0; }
.ability-slot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid #9eaaa7; border-radius: 7px; background: #a4b5ae; color: #162b2b; }
.ability-slot .pickup-art { flex-basis: 24px; width: 24px; height: 24px; filter: brightness(0); }
.ability-name { font-size: 7px; line-height: 8px; font-weight: 700; }
.ability-slot b { display: none; position: absolute; top: 1px; right: 1px; border-radius: 50%;
  background: #c6f5ce; color: #153a30; font-size: 9px; line-height: 11px; width: 11px; text-align: center; }
.ability-slot.owned { border-color: #9be6ca; background: #254849; color: #e0f9eb; }
.ability-slot.owned .pickup-art { filter: none; }
.ability-slot.owned b { display: block; }
#hint {
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: #b5cabd;
  min-height: 32px;
  margin: 13px 0 8px;
}
#arena { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#swipe-help { text-align: center; color: #a9c6bb; font-size: 10px; margin: 0; }
#cast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 76px;
  touch-action: none;
  background: radial-gradient(ellipse at 50% 20%, #73bda9, #377b70);
  border: 1px solid #9bd1b1;
  border-radius: 20px;
  box-shadow: 0 5px 0 #1a4d48, 0 9px 28px #050e1555;
  color: #e2f2d8;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 700;
}
#cast > span {
  display: block;
  font-size: 0;
  width: 40px;
  height: 40px;
  background: url("assets/runtime-v1/props.9abb4118.webp") 0 100% / 200% 200%;
}
#cast:active { transform: translateY(3px); box-shadow: 0 2px 0 #1a4d48; }
.keyboard-help {
  text-align: center;
  font-size: 9px;
  color: #698e83;
  padding: 5px 0 25px;
}
.keyboard-help span {
  padding: 0 9px;
}
dialog {
  background: #1b3036;
  color: #dde5d6;
  border: 1px solid #608378;
  border-radius: 16px;
  max-width: 410px;
  width: calc(100% - 28px);
  padding: 27px;
  box-shadow: 0 30px 100px #0008;
}
dialog::backdrop {
  background: #07171dba;
  backdrop-filter: blur(7px);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
dialog h2 {
  font-size: 29px;
  margin: 17px 0 25px;
}
dialog label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  gap: 14px;
  margin: 20px 0;
  color: #c4d5c9;
}
select {
  background: #2a4446;
  color: #d7e4d4;
  border: 1px solid #617a6b;
  border-radius: 5px;
  padding: 8px;
  max-width: 165px;
  font: inherit;
  font-size: 11px;
}
input {
  accent-color: #9ce1c3;
  width: 19px;
  height: 19px;
}
.settings-note {
  font-size: 11px;
  line-height: 1.7;
  color: #8ca89e;
}
dialog .primary {
  width: 100%;
  margin-top: 10px;
}
body.playing .topbar {
  height: 70px;
}
body.playing main {
  max-width: 840px;
}
.asset-error {
  background: #744734;
  padding: 10px;
  text-align: center;
  font-size: 12px;
}
@media (min-width: 900px) {
  body.playing main {
    max-width: 700px;
  }
  body.playing .topbar {
    height: 65px;
  }
  #game-screen {
    max-width: 590px;
  }
  .arena-wrap {
    max-width: 550px;
    margin: auto;
  }
}
@media (max-width: 640px) {
  main {
    padding: 0 17px;
  }
  .topbar {
    height: 77px;
  }
  .topbar a {
    font-size: 13px;
    letter-spacing: 2px;
  }
  .topbar small {
    font-size: 6px;
  }
  .brand-mark {
    font-size: 33px;
  }
  h1 {
    font-size: 34px;
    line-height: 1.12;
    margin: 14px 0;
  }
  footer {
    gap: 10px;
    font-size: 7px;
  }
  .desktop {
    display: none;
  }
  .game-heading {
    margin-bottom: 12px;
  }
  .game-heading > span {
    font-size: 8px;
    letter-spacing: 1px;
  }
  body.playing main {
    padding: 0 10px;
  }
  body.playing .topbar {
    height: 57px;
  }
  .topbar .icon-button {
    width: 34px;
    height: 34px;
  }
  .scoreboard {
    gap: 5px;
    margin-bottom: 11px;
  }
  .score-chip {
    padding: 5px;
    gap: 4px;
    border-radius: 6px;
  }
  .avatar {
    width: 24px;
    height: 27px;
    font-size: 18px;
  }
  .score-chip strong {
    font-size: 9px;
  }
  .score-chip small {
    font-size: 8px;
    letter-spacing: 1px;
  }
  .arena-caption {
    margin-bottom: 8px;
    font-size: 7px;
  }
  .arena-caption strong {
    font-size: 18px;
  }
  .arena-wrap {
    padding: 4px;
    border-radius: 9px;
  }
  #game-overlay {
    inset: 4px;
  }
  #overlay-title {
    font-size: 30px;
  }
  .overlay-rune {
    font-size: 35px;
    margin-bottom: 8px;
  }
  #overlay-copy {
    font-size: 11px;
    margin-bottom: 15px;
  }
  #hint {
    font-size: 10px;
    min-height: 30px;
    margin: 10px 7px 3px;
  }
  .keyboard-help {
    display: none;
  }
  dialog {
    padding: 22px;
  }
}
@media (max-height: 700px) and (max-width: 640px) {
  body.playing .topbar {
    height: 45px;
  }
  .game-heading {
    margin-bottom: 5px;
  }
  .scoreboard {
    margin-bottom: 5px;
  }
  .game-heading .icon-button {
    height: 28px;
    width: 28px;
  }
  .arena-wrap {
    max-width: min(340px, calc((100svh - 290px) * 13 / 11));
    margin: auto;
  }
  #game-overlay {
    padding: 10px;
  }
  #game-overlay .overlay-rune {
    display: none;
  }
  #game-overlay h2 {
    font-size: 24px;
    margin: 8px 0;
  }
  #game-overlay .eyebrow {
    font-size: 7px;
  }
  #game-overlay p {
    font-size: 10px;
    margin-bottom: 9px;
  }
  #game-overlay .primary {
    padding: 9px 13px;
    font-size: 10px;
  }
  #overlay-home {
    margin-top: 7px;
  }
  #hint {
    margin: 5px 3px 2px;
    font-size: 9px;
    min-height: 27px;
  }
  #cast { height: 64px; }
  #swipe-help { font-size: 10px; margin-bottom: 7px; }

}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Touch targets stay usable even in the short-phone layout. */
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
body.playing .icon-button, .topbar .icon-button { min-width: 44px; min-height: 44px; }
#leave { min-height: 44px; padding: 8px 10px; }
#continue, #overlay-home { min-height: 44px; }
@media (max-width: 640px) {
  .game-heading { min-height: 44px; }
}
@media (max-height: 700px) and (max-width: 640px) {
  body.playing .topbar { height: 0; position: relative; z-index: 3; }
  body.playing .topbar #brand { display: none; }
  body.playing .topbar #settings-open { position: absolute; top: 4px; right: 54px; }
  .game-heading > span { visibility: hidden; }
  #game-screen { padding-top: max(4px, env(safe-area-inset-top)); }
  #game-overlay { overflow-y: auto; justify-content: safe center; }
}

/* Only active play owns the viewport. Home and settings remain ordinary pages. */
html.playing { overflow: hidden; overscroll-behavior: none; }
body.playing { position: fixed; inset: 0; width: 100%; overflow: hidden; overscroll-behavior: none; }
body.playing main { height: 100%; height: 100dvh; display: flex; flex-direction: column; padding-bottom: max(8px, env(safe-area-inset-bottom)); padding-top: env(safe-area-inset-top); }
body.playing .topbar { flex-shrink: 0; }
body.playing #game-screen { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; gap: 7px; container-type: inline-size; }
body.playing .game-heading, body.playing .scoreboard, body.playing .arena-caption { margin-bottom: 0; flex-shrink: 0; }
.arena-slot { flex: 1; min-height: 0; max-height: min(467px, calc((100cqw - 10px) * 11 / 13 + 10px)); container-type: size; display: flex; align-items: flex-end; justify-content: center; }
body.playing .arena-wrap { flex-shrink: 0; width: min(100cqw, calc((100cqh - 10px) * 13 / 11 + 10px)); max-width: 550px; padding: 4px; margin: 0; }
#arena { height: auto; }
body.playing #cast { flex-shrink: 0; height: 64px; }
body.playing .inventory, body.playing #abilities { flex-shrink: 0; }
/* Transient messages cannot borrow space from the responsive board. */
body.playing #hint {
  margin: 0; min-height: 0; font-size: 10px; line-height: 1.4;
  block-size: 2.8em; flex-shrink: 0; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}

body.playing .arena-caption { block-size: 24px; line-height: 24px; }
body.playing .arena-caption strong { line-height: 24px; }
body.playing #swipe-help { flex-shrink: 0; line-height: 1.3; margin: 0; }
body.playing .keyboard-help { padding: 0; flex-shrink: 0; }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
@media (max-width: 640px) {
  body.playing .topbar { height: 46px; }
  body.playing #game-screen { gap: 6px; }
  .inventory { grid-template-columns: repeat(3, minmax(0, 1fr)) 40px; gap: 5px; }
  .stat-card { padding: 7px 5px; }
  .stat-heading strong { font-size: 24px; }
}
@media (max-height: 700px) {
  body.playing .topbar { height: 0; position: relative; z-index: 3; }
  body.playing .topbar #brand { display: none; }
  body.playing .topbar #settings-open { position: absolute; top: 0; right: 54px; }
  body.playing .game-heading > span { visibility: hidden; }
  body.playing #game-screen { padding-top: 0; gap: 4px; }
  body.playing #cast { height: 52px; }
  .stat-card { padding: 4px; }
  .stat-heading strong { font-size: 22px; }
  .stat-meter { margin-top: 5px; }
  .stat-card small { margin-top: 4px; font-size: 7px; }
  body.playing #hint { font-size: 9px; }
  body.playing #swipe-help { font-size: 9px; }
  body.playing .keyboard-help { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .upgraded { animation-timing-function: steps(1, end); }
}

.game-details { display: contents; }
@media (orientation: landscape) and (max-height: 600px) {
  body.playing main { max-width: 1100px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  body.playing #game-screen { max-width: none; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(230px, 1fr); grid-template-rows: 44px auto 24px minmax(0, 1fr); column-gap: 16px; }
  body.playing .game-heading { grid-column: 2; grid-row: 1; }
  body.playing .scoreboard { grid-column: 2; grid-row: 2; }
  body.playing .arena-caption { grid-column: 2; grid-row: 3; }
  body.playing .arena-slot { grid-column: 1; grid-row: 1 / 5; margin-bottom: 58px; max-height: none; align-self: stretch; }
  body.playing #cast { grid-column: 1; grid-row: 4; align-self: end; }
  .game-details { grid-column: 2; grid-row: 4; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
}

#game-overlay { touch-action: pan-y; overscroll-behavior: contain; overflow-y: auto; }

/* Result feedback never blocks Continue, and all outcomes have distinct text. */
#game-overlay[data-result] { border: 1px solid #8cac96; box-shadow: inset 0 0 45px #92b89218; }
#game-overlay[data-result="victory"], #game-overlay[data-result="lesson"] { border-color: #dbc68c; background: #152c2cf2; }
#game-overlay[data-result="defeat"] { border-color: #af9ebd; }
#game-overlay[data-result="draw"] { border-color: #9fb9c4; }
#game-overlay[data-result] .overlay-rune { position: relative; display: block; margin-bottom: 4px; }
#game-overlay[data-result="victory"] .overlay-rune, #game-overlay[data-result="lesson"] .overlay-rune { color: #f2d894; animation: result-bloom .7s ease-out; }
#game-overlay[data-result="defeat"] .overlay-rune { color: #c5b4d7; }
#game-overlay[data-result="draw"] .overlay-rune { color: #b0d1dc; }
#game-overlay[data-result="victory"] .overlay-rune::before, #game-overlay[data-result="lesson"] .overlay-rune::before { content: "✧"; position: absolute; left: -48px; top: 5px; font-size: 22px; animation: result-spark .9s ease-out both; }
#game-overlay[data-result="victory"] .overlay-rune::after, #game-overlay[data-result="lesson"] .overlay-rune::after { content: "✦"; position: absolute; right: -45px; top: 18px; font-size: 17px; animation: result-spark 1.1s ease-out both; }
@keyframes result-bloom { from { transform: scale(.8); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes result-spark { from { transform: translateY(10px); opacity: 1; } to { transform: translateY(-12px); opacity: 0; } }
@media (max-height: 700px) { #game-overlay[data-result] .overlay-rune { font-size: 27px; line-height: 1; } }
@media (prefers-reduced-motion: reduce) {
  #game-overlay[data-result] .overlay-rune, #game-overlay[data-result] .overlay-rune::before, #game-overlay[data-result] .overlay-rune::after { animation: none; }
}

@media (orientation: landscape) and (max-height: 600px) {
  #game-overlay { padding: 12px; justify-content: safe center; }
  #game-overlay .overlay-rune { font-size: 27px; line-height: 1; margin-bottom: 4px; }
  #game-overlay h2 { font-size: 28px; line-height: 1.1; margin: 6px 0; }
  #game-overlay p { font-size: 12px; margin-bottom: 12px; }
  #game-overlay .primary { min-height: 44px; padding: 10px 18px; }
  #overlay-home { margin-top: 6px; }
}

/* Campaign content uses the same board/Cast layout; objectives replace score chips. */
#chapter { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 24px; overflow-y: auto; }
#chapter h2 { margin: 12px 0; font-size: clamp(26px, 6vw, 36px); }
.chapter-copy, .chapter-legend { color: #b8c8c6; font-size: 13px; line-height: 1.5; }
.chapter-legend { font-size: 11px; margin-bottom: 0; }
#room-list { display: grid; gap: 8px; margin-top: 20px; }
.room-card { display: flex; align-items: center; gap: 14px; min-height: 68px; width: 100%; padding: 12px; border: 1px solid #56656b; border-radius: 10px; background: #26373e; text-align: left; color: #edf2e4; cursor: pointer; }
.room-card:disabled { opacity: .48; cursor: default; }
.room-card[data-complete="true"] { border-color: #86bfa3; }
.room-card:focus-visible { outline: 3px solid #e2c887; outline-offset: 2px; }
.room-card strong, .room-card small { display: block; }
.room-card strong { font-size: 15px; }
.room-card small { color: #becdcd; font-size: 11px; margin-top: 4px; }
.room-number { color: #d9c38d; font-size: 22px; min-width: 28px; }
.room-status { margin-left: auto; color: #ead08d; }
#chapter-award { padding: 12px; border: 1px solid #d9c38d; color: #ead08d; border-radius: 8px; font-size: 12px; }
.campaign-play #scoreboard { display: none; }
#campaign-objectives { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 36px; }
#campaign-objectives[hidden] { display: none; }
.objective-chip { color: #c5f4e9; border: 1px solid #729c96; background: #223b40; padding: 3px 12px; border-radius: 7px; font-size: 21px; font-weight: 700; }
.objective-chip.complete { border-color: #dac489; color: #ffe1a1; }
.objective-bonus { color: #e3c48d; font-size: 17px; }
@media (max-height: 700px) { #campaign-objectives { min-height: 28px; } .objective-chip { font-size: 18px; padding: 2px 10px; } }
@media (orientation: landscape) and (max-height: 600px) {
  .campaign-play #campaign-objectives { grid-column: 2; grid-row: 2; }
}

/* Stage selection lives outside play; changing copy never consumes board height. */
#ladder-dialog, #lessons { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; overflow-y: auto; }
#ladder-dialog h2, #lessons h2 { font-size: clamp(24px, 6vw, 34px); margin: 12px 0; }
#ladder-list, #lesson-list { display: grid; gap: 8px; margin-top: 18px; }
#ladder-resume { width: 100%; height: auto; min-height: 52px; white-space: normal; }
.custom-battle { min-height: 44px; margin-top: 12px; }

/* Give portrait phones to the arena before decorative HUD spacing. */
@media (max-width: 640px) and (orientation: portrait) {
  body.playing main {
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  body.playing .topbar { height: 0; position: relative; z-index: 3; }
  body.playing .topbar #brand { display: none; }
  body.playing .topbar #settings-open { position: absolute; top: 0; right: 54px; }
  body.playing .game-heading > span { visibility: hidden; }
  body.playing #scoreboard { block-size: 32px; }
  body.playing .score-chip { padding: 3px 5px; gap: 4px; }
  body.playing .score-chip > span:last-child { display: grid; gap: 1px; line-height: 10px; }
  body.playing .score-chip .avatar { width: 20px; height: 20px; flex-shrink: 0; font-size: 16px; }
  body.playing .arena-slot { max-height: min(467px, calc((100cqw - 6px) * 11 / 13 + 6px)); }
  body.playing .arena-wrap { padding: 2px; width: min(100cqw, calc((100cqh - 6px) * 13 / 11 + 6px)); }
}
@media (max-width: 640px) and (max-height: 700px) and (orientation: portrait) {
  /* Labels and meters already describe these stats; reserve space for play. */
  body.playing .stat-card small { display: none; }
  /* Keep the canvas's described instructions available to assistive technology. */
  body.playing #swipe-help {
    position: absolute; width: 1px; height: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* Home navigation is isolated from the fixed game viewport. */
.home-intro { text-align: center; padding: 12px 0 28px; }
.home-intro h1 { font-size: clamp(30px, 5vw, 44px); margin: 12px 0 8px; }
.home-intro p, .friends-intro p { color: #bdd0ce; font-size: 16px; margin: 0; line-height: 1.5; }
.play-paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.play-path { --path-color: #8ce0c6; display: flex; align-items: center; gap: 18px; width: 100%; min-width: 0;
  padding: 16px; border: 2px solid color-mix(in srgb, var(--path-color) 55%, #24343f); border-radius: 22px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--path-color) 12%, #142630), #162831);
  box-shadow: 0 5px 0 #08182080; color: #f5f3e9; text-decoration: none; text-align: left;
  transition: border-color .15s, background .15s; }
.play-path:hover { border-color: var(--path-color); background: #294049; }
.play-path:active { background: #334c50; }
.path-friends { --path-color: #a8cfff; }
.path-story { --path-color: #d8b0f3; }
.path-learn { --path-color: #f1d182; }
.path-art { display: block; width: 112px; height: 112px; flex: 0 0 auto; border-radius: 17px;
  background-image: url("assets/runtime-v1/choices.d7b497af.webp"); background-size: 200% 200%; background-color: #28454c; }
.art-solo { background-position: 0 0; }
.art-friends { background-position: 100% 0; }
.art-story { background-position: 0 100%; }
.art-learn { background-position: 100% 100%; }
.path-copy { display: grid; gap: 7px; min-width: 0; }
.path-copy strong { font-size: 23px; line-height: 1.16; font-weight: 700; }
.path-copy > span { color: #c3d2d2; font-size: 14px; line-height: 1.4; }
.path-copy small { color: var(--path-color); font-size: 12px; font-weight: 700; line-height: 1.4; }
.path-arrow { margin-left: auto; color: var(--path-color); font-size: 23px; }
.home-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; margin: 22px 0 12px; }
.home-tools button, .back-home { min-height: 48px; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #c5ded8; }
.home-help { border: 1px solid #48615f; border-radius: 14px; max-width: 620px; margin: 0 auto; padding: 0 18px; }
.home-help summary { cursor: pointer; min-height: 52px; padding: 15px 0; font-weight: 700; }
.home-help summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.home-help p { font-size: 14px; line-height: 1.6; color: #c3d2d2; }
.home-note { font-size: 12px; color: #a8bdb9; text-align: center; margin: 22px 0 30px; }
.back-home { text-decoration: none; font-weight: 700; }
.friends-intro { display: flex; gap: 18px; align-items: center; max-width: 560px; margin: 12px auto 20px; }
.friends-intro h1 { font-size: 30px; margin: 8px 0; }
.friends-home .back-home { margin-bottom: 4px; }
@media (max-width: 760px) {
  .play-paths { grid-template-columns: 1fr; gap: 12px; }
  .home-intro { padding: 2px 0 20px; }
  .home-intro h1 { font-size: 32px; }
  .play-path { gap: 14px; padding: 12px; border-radius: 18px; }
  .path-art { width: 88px; height: 88px; border-radius: 12px; }
  .path-copy { gap: 5px; }
  .path-copy strong { font-size: 21px; }
  .path-copy > span { font-size: 13px; }
  .path-copy small { font-size: 12px; }
  .path-arrow { font-size: 20px; }
  .friends-intro { gap: 12px; }
  .friends-intro h1 { font-size: 25px; }
  .friends-intro p { font-size: 14px; }
}
@media (max-width: 360px) {
  .path-art { width: 70px; height: 70px; background-size: 200% 200%; }
  .play-path { gap: 10px; padding: 10px; }
  .path-copy strong { font-size: 19px; }
  .path-arrow { display: none; }
  .friends-intro .path-art { width: 64px; height: 64px; }
}

/* Online results keep their action inside even a short desktop arena. */
#game-overlay.room-overlay { padding: 12px; justify-content: safe center; }
.room-overlay .overlay-rune { display: none; }
.room-overlay #overlay-title { font-size: 28px; margin: 8px 0; }
.room-overlay #overlay-copy { font-size: 12px; line-height: 1.4; margin: 0 0 10px; }
.room-overlay #continue { min-height: 44px; flex-shrink: 0; padding: 10px 16px; }

/* Reset lives below the main action so it is never the obvious tap (ADR-029). */
.reset-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.reset-row .text-button { min-height: 44px; padding: 10px 0; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.reset-row .text-button:disabled { opacity: 0.55; text-decoration: none; }
.reset-note { font-size: 11px; color: #8ca89e; }
#reset-confirm h2 { margin: 12px 0 14px; font-size: 26px; }
.danger-button { width: 100%; min-height: 44px; margin-top: 12px; border: 1px solid #c98b7b; border-radius: 7px;
  background: transparent; color: #f0b8a6; font-weight: 700; font-size: 12px; }
.danger-button:hover { background: #c98b7b22; }

/* Custom matches with advanced charms add Remote: the charm column becomes 2×2 (ADR-031). */
.extra-slot { display: none; }
.inventory.extras { grid-template-columns: repeat(3, minmax(0, 1fr)) 80px; }
.inventory.extras #abilities { grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: 1fr 1fr; }
.inventory.extras .extra-slot { display: flex; }
.inventory.extras .ability-slot .pickup-art { flex-basis: 20px; width: 20px; height: 20px; }
.ability-slot .pickup-art:not(:has(svg)) .pickup-fallback { font-size: 18px; }
.ability-slot:not(.owned) .pickup-art:not(:has(svg)) .pickup-fallback { color: #162b2b; }
@media (max-width: 640px) {
  .inventory.extras { grid-template-columns: repeat(3, minmax(0, 1fr)) 70px; }
}

/* Ladder: charms that arrive at a later stage show a quiet locked slot (ADR-036). */
.ability-slot.locked { border-style: dashed; border-color: #6f8580; background: #8c9c97; }
.ability-slot.locked .pickup-art { opacity: .45; }
.ability-slot.locked .ability-name { font-size: 6px; letter-spacing: 0; white-space: nowrap; }
.ability-slot .slot-lock { position: absolute; top: 1px; right: 1px; width: 9px; height: 11px; flex-basis: auto; filter: none; font-size: 7px; }

/* A collected charm's slot pops once so the new ability is noticed (ADR-037). */
.ability-slot.celebrate { animation: charm-collected .9s ease-out; }
@keyframes charm-collected {
  0% { transform: scale(1); box-shadow: 0 0 0 0 #f9e1a5; }
  35% { transform: scale(1.18); box-shadow: 0 0 0 4px #f9e1a5aa; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 #f9e1a500; }
}
@media (prefers-reduced-motion: reduce) {
  .ability-slot.celebrate { animation: none; }
}

/* Six-wizard scoreboard: numbered badges and pips only, same row height (ADR-038). */
.scoreboard.crowded { gap: 4px; }
.scoreboard.crowded .score-chip { gap: 4px; padding-left: 4px; padding-right: 4px; justify-content: center; }
.scoreboard.crowded .score-chip strong { display: none; }
.scoreboard.crowded .avatar { font-family: inherit; font-weight: 700; font-size: 13px; }
.scoreboard.crowded .score-chip small { letter-spacing: 1px; }

/* art-upgrade-v1 (ADR-039): emblems take the space of the glyphs they replace. */
.pickup-art.emblem { width: 1.25em; height: 1.25em; flex: 0 0 auto; vertical-align: -0.3em; }
.overlay-rune .pickup-art.emblem { width: 1.15em; height: 1.15em; vertical-align: middle; }
#ladder-award .emblem, #chapter-award .emblem { width: 22px; height: 22px; margin-right: 2px; }
.arena-label .emblem { width: 16px; height: 18px; vertical-align: -3px; }
/* Arena rewards share the card, art size and text hierarchy of every play choice. */
.path-grand { --path-color: #abc9dc; }
.path-great { --path-color: #dfbf82; }
.arena-art { background-image: url("assets/runtime-v1/arenas-v1.b0bf0860.webp"); background-size: 200% 100%; }
.arena-art.art-great { background-position: 100% 0; }
.arena-choice:disabled { opacity: 1; cursor: default; }
.arena-choice:disabled .arena-art { filter: saturate(.65); }
.arena-choice:disabled .path-arrow { visibility: hidden; }
.arena-choice:disabled:hover { border-color: color-mix(in srgb, var(--path-color) 55%, #24343f); background: linear-gradient(120deg, color-mix(in srgb, var(--path-color) 12%, #142630), #162831); }
