:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f2f1e9;
  color: #253e3e;
  font-synthesis: none;
  --cream: #f1edda;
  --muted: #9fae9d;
  --lime: #d4e8ac;
  --ink: #163632;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 3px solid #e7b86c;
  outline-offset: 4px;
}
button {
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover:not(:disabled) {
  filter: brightness(1.08);
}
[hidden] {
  display: none !important;
}
.app {
  max-width: 1700px;
  margin: auto;
  padding: 0 42px;
}
.masthead {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 34px;
  height: 38px;
  border-radius: 10px 2px;
  background: var(--ink);
  color: #e7e8c9;
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 700;
}
.brand strong {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 2px;
}
.brand strong > span {
  font-weight: 400;
  margin-left: 3px;
}
.masthead-center {
  font-size: 9px;
  letter-spacing: 2.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.masthead-center i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #719576;
}
.header-actions {
  display: flex;
  gap: 10px;
}
.header-actions button {
  padding: 9px 13px;
  border: 1px solid #ced4c8;
  border-radius: 25px;
  color: #3e584c;
  background: none;
  font-size: 11px;
}
#fullscreen {
  font-size: 19px;
  line-height: 18px;
  padding: 7px 12px;
}
#stage {
  position: relative;
  aspect-ratio: 16/9;
  background: #1c3f42;
  overflow: hidden;
  border-radius: 6px;
  isolation: isolate;
  box-shadow: 0 16px 50px #122d3224;
}
#stage:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #101e28;
}
#stage:fullscreen canvas {
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
}
.screen {
  position: absolute;
  inset: 0;
}
.home-nav {
  position: absolute;
  top: 5%;
  left: 5.6%;
  display: flex;
  gap: 28px;
  align-items: center;
  font-size: 9px;
  letter-spacing: 1.7px;
  color: #b4c7b8;
}
.home-nav button {
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  padding: 8px 0;
}
.nav-active {
  color: #e0e9c9;
  position: relative;
}
.nav-active:after {
  position: absolute;
  content: '';
  bottom: -10px;
  left: 0;
  width: 27px;
  height: 2px;
  background: #d5dfa8;
}
.hero {
  position: absolute;
  top: 23%;
  left: 6.4%;
  color: var(--cream);
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 2.7px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c2d3ae;
}
.eyebrow > span {
  height: 1px;
  width: 24px;
  background: #c2d3ae;
}
h1 {
  font-size: clamp(36px, 5.7vw, 89px);
  font-weight: 750;
  line-height: 1.035;
  letter-spacing: -4px;
  margin: 20px 0 21px;
}
h1 em {
  font-family: Georgia, serif;
  font-weight: 400;
  color: #d3e8b0;
}
h1 + p {
  font-size: clamp(11px, 1vw, 15px);
  line-height: 1.8;
  color: #b9caba;
  margin: 0 0 26px;
}
.hero-actions {
  display: flex;
  gap: 13px;
  align-items: center;
}
.button {
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  padding: 15px 21px;
  display: inline-flex;
  gap: 35px;
  align-items: center;
  justify-content: space-between;
}
.primary {
  background: #d9e5b7;
  color: #253b32;
  font-weight: 600;
}
.primary span {
  font-size: 19px;
  line-height: 10px;
}
.ghost {
  background: #c9ddba0b;
  color: #d6e0cc;
  border: 1px solid #e0e9c333;
}
.save-hint {
  font-size: 9px;
  color: #a7bda9;
  margin-top: 16px;
}
.home-bottom {
  position: absolute;
  bottom: 20px;
  left: 5.6%;
  right: 4%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #b7c8b0;
  font-size: 8px;
  letter-spacing: 2px;
}
.home-bottom b {
  color: #e2d9a4;
  font-size: 18px;
  margin-left: 16px;
}
footer {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.control-legend {
  display: flex;
  gap: 18px;
  color: #758074;
  font-size: 10px;
}
.control-legend > span {
  display: flex;
  align-items: center;
  gap: 4px;
}
kbd {
  border: 1px solid #d2d8cb;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 4px 5px;
  font:
    9px 'Segoe UI',
    sans-serif;
  color: #52664f;
  min-width: 21px;
  text-align: center;
}
#help {
  font-size: 10px;
  border: 0;
  background: none;
  color: #5d7358;
  padding: 10px;
}
.build-note {
  text-align: center;
  font-size: 9px;
  color: #8d9787;
  margin: 0 0 15px;
}
.hud-top {
  position: absolute;
  top: 22px;
  left: 25px;
  right: 25px;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  pointer-events: none;
}
.vitals,
.region-hud {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #152e36de;
  backdrop-filter: blur(8px);
  border: 1px solid #e0efd522;
  color: #eef0d5;
  border-radius: 8px;
  padding: 10px 16px;
}
.avatar {
  font-family: serif;
  font-size: 26px;
  color: #e0bb90;
}
.mini-label {
  display: block;
  font-size: 8px;
  letter-spacing: 2px;
  color: #b0c1ae;
}
#hearts {
  color: #edb396;
  letter-spacing: 3px;
  font-size: 16px;
  line-height: 23px;
}
.vitals > i {
  height: 28px;
  width: 1px;
  background: #b9caba2e;
}
.coin-glyph {
  border: 2px solid #d6b56b;
  width: 22px;
  height: 26px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  color: #d6b56b;
}
.seal-count {
  font-size: 20px;
  letter-spacing: 3px;
  color: #d8e6b4;
  margin-left: 8px;
}
.region-hud strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}
.region-hud button {
  pointer-events: auto;
  border: 0;
  background: none;
  color: #e6edcd;
  font-size: 23px;
  padding: 3px 7px;
}
.hud-bottom {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}
.loadout {
  background: #152e36de;
  border: 1px solid #dcebd220;
  border-radius: 8px;
  padding: 8px 10px;
  backdrop-filter: blur(8px);
}
#weaponSlots {
  display: flex;
  gap: 5px;
}
#weaponSlots button {
  position: relative;
  pointer-events: auto;
  width: 42px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid #c6dbba22;
  background: #cad6b509;
  color: #aac3b1;
  font-size: 22px;
}
#weaponSlots button.active {
  border-color: #d2dfac;
  background: #d2dfac20;
  color: #f0e8bc;
}
#weaponSlots small {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 7px;
  color: #b8c9b5;
}
.energy {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 7px;
}
.energy > span {
  font-size: 6px;
  letter-spacing: 1px;
  color: #c4d9b9;
}
.energy > div {
  height: 3px;
  background: #97c8b329;
  width: 62px;
}
.energy i {
  display: block;
  height: 100%;
  background: #b4d6a2;
}
.energy small {
  font-size: 8px;
  color: #b7c9b2;
  margin-left: auto;
}
.objective {
  font-size: 10px;
  color: #e0e7cc;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px #122d34;
}
.panel-layer {
  position: absolute;
  inset: 0;
  background: #0d2532c9;
  backdrop-filter: blur(14px);
  display: grid;
  place-items: center;
  padding: 26px;
  z-index: 5;
}
.panel {
  position: relative;
  background: linear-gradient(140deg, #f2f0df, #e7ead7);
  width: min(840px, 94%);
  max-height: 100%;
  overflow: auto;
  border: 1px solid #f7f5dd8c;
  border-radius: 10px;
  padding: 32px;
  color: #24433e;
  box-shadow: 0 20px 70px #09213155;
  scrollbar-width: thin;
}
.panel .eyebrow {
  color: #71876b;
  font-size: 8px;
}
.panel h2 {
  font-size: 34px;
  letter-spacing: -1.2px;
  margin: 10px 0 8px;
  font-weight: 650;
}
.panel > p {
  font-size: 12px;
  line-height: 1.7;
  color: #72816c;
  margin: 0 0 20px;
}
.close {
  position: absolute;
  right: 15px;
  top: 13px;
  border: 0;
  background: #254c4010;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 22px;
  color: #5b735e;
}
.panel .primary {
  background: #254b3c;
  color: #ecf1d9;
}
.panel .ghost {
  color: #466649;
  border-color: #6a885c55;
  background: none;
}
.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.character-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.character-card {
  position: relative;
  text-align: left;
  border: 1px solid #b4c3a4;
  border-radius: 8px;
  background: #dbe3cb40;
  color: #29493e;
  padding: 18px;
  overflow: hidden;
}
.character-card.selected {
  border: 2px solid #5a7b52;
  padding: 17px;
  background: #cddcb966;
}
.character-card h3 {
  font-size: 25px;
  letter-spacing: -1px;
  margin: 8px 0 4px;
}
.character-card p {
  font-size: 11px;
  line-height: 1.7;
  max-width: 200px;
  color: #728169;
}
.character-card .portrait {
  height: 132px;
  width: 100%;
  display: block;
}
.char-tag {
  font-size: 8px;
  letter-spacing: 1.6px;
  color: #658058;
}
.stat-line {
  display: flex;
  gap: 18px;
  font-size: 9px;
  margin-top: 13px;
  color: #597651;
}
.weapon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.weapon-card {
  border: 1px solid #c0ccb2;
  background: #f8f7e847;
  padding: 16px 12px;
  border-radius: 6px;
  text-align: left;
  color: #344d42;
}
.weapon-card.selected {
  border: 2px solid #68865b;
  background: #dae5c4;
  padding: 15px 11px;
}
.weapon-art {
  font-size: 37px;
  color: #506e56;
  display: block;
  margin: 5px 0 18px;
}
.weapon-card strong {
  font-size: 13px;
  display: block;
}
.weapon-card small {
  font-size: 7px;
  letter-spacing: 0.7px;
  display: block;
  margin: 8px 0;
  color: #688363;
}
.weapon-card p {
  font-size: 10px;
  line-height: 1.7;
  color: #72816c;
  margin-bottom: 0;
}
.island-map {
  position: relative;
  height: 145px;
  margin: 20px 0;
  background: radial-gradient(ellipse, #bccfc0 0%, #dbe3cd 65%);
  border-radius: 8px;
  overflow: hidden;
}
.island-map svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid #e9e9ca;
  background: #416951;
  color: #edf3d4;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 15px;
  box-shadow: 0 0 0 6px #8ba78344;
}
.map-node small {
  position: absolute;
  top: 47px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #47634d;
  white-space: nowrap;
}
.chapter-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.chapter-card {
  text-align: left;
  border: 1px solid #c4ccb5;
  border-radius: 5px;
  background: #f7f6e753;
  padding: 13px 11px;
  color: #3b5d48;
}
.chapter-card strong {
  display: block;
  font-size: 12px;
  margin: 9px 0;
}
.chapter-card span {
  font-size: 8px;
  letter-spacing: 1px;
  color: #819072;
}
.chapter-card small {
  display: block;
  font-size: 9px;
  color: #7b8c72;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 25px;
}
.settings-grid label {
  font-size: 12px;
  color: #4e6b52;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.settings-grid input[type='range'] {
  width: 100%;
  accent-color: #56794d;
}
.settings-grid select {
  padding: 8px;
  border: 1px solid #b4c3a4;
  border-radius: 4px;
  background: #f4f4e5;
  color: #4c6950;
}
.settings-grid .check {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}
.settings-grid input[type='checkbox'] {
  accent-color: #4c704a;
}
.settings-note {
  font-size: 10px;
  color: #7e8f73;
  line-height: 1.7;
  margin-top: 20px;
}
.results-grid {
  display: flex;
  gap: 0;
  border-block: 1px solid #b9c9a8;
  padding: 18px 0;
  margin: 15px 0;
}
.results-grid > div {
  flex: 1;
  text-align: center;
}
.results-grid strong {
  display: block;
  font-size: 28px;
  font-weight: 500;
  color: #43684b;
}
.results-grid span {
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #788c6f;
}
.controls-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}
.controls-table td {
  border-bottom: 1px solid #c5cfb9;
  padding: 8px;
}
.controls-table td:first-child {
  font-weight: 600;
  width: 30%;
}
.credits {
  font-size: 12px;
  line-height: 1.9;
  color: #637a5e;
}
.credits em {
  color: #345c43;
}
#toast {
  position: absolute;
  top: 105px;
  left: 50%;
  transform: translateX(-50%);
  background: #f1eedce8;
  color: #365c45;
  border: 1px solid #f7f8df;
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 80%;
  text-align: center;
  z-index: 3;
}
#toast.visible {
  opacity: 1;
}
.chapter-banner {
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  color: #f3f1d7;
  text-shadow: 0 3px 14px #15323e;
  background: linear-gradient(90deg, transparent, #163844ae, transparent);
  padding: 22px;
}
.chapter-banner > span {
  font-size: 10px;
  letter-spacing: 5px;
  color: #d9e8b8;
}
.chapter-banner h2 {
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -1px;
  margin: 8px;
}
.chapter-banner p {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 15px;
  margin: 6px;
}
.chapter-banner {
  animation: chapter-in 0.5s ease-out;
}
@keyframes chapter-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#bossHud {
  position: absolute;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  text-align: center;
  color: #f5d5c1;
}
#bossHud > span {
  font-size: 9px;
  letter-spacing: 2px;
  text-shadow: 0 2px 5px #132c3d;
}
#bossHud > div {
  height: 5px;
  background: #102839bb;
  border: 1px solid #e1c6b63b;
  margin-top: 8px;
}
#bossFill {
  display: block;
  height: 100%;
  background: #edb38f;
}
#touch {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}
#touch > div {
  display: flex;
  gap: 8px;
}
#touch button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #eff5d875;
  color: #f3f2de;
  background: #15374799;
  font-size: 20px;
}
#touch button[data-action='cycle'],
#touch button[data-action='mount'] {
  font-size: 12px;
  width: 34px;
  height: 34px;
  align-self: end;
}
#rotateHint {
  display: none;
}
:root.touch-input .hud-bottom {
  bottom: 78px;
}
:root.touch-input .objective {
  display: none;
}
@media (max-width: 1100px) {
  .app {
    padding: 0 24px;
  }
  .masthead {
    height: 75px;
  }
  .masthead-center {
    font-size: 8px;
    letter-spacing: 1.6px;
  }
  .control-legend {
    gap: 10px;
    font-size: 8px;
  }
  .control-legend span:nth-child(3) {
    font-size: 0;
  }
  .control-legend span:nth-child(3) kbd {
    font-size: 8px;
  }
  h1 {
    font-size: 5.7vw;
  }
  .hero {
    top: 21%;
  }
  .home-nav {
    font-size: 8px;
    gap: 20px;
  }
  .hero-actions .button {
    font-size: 10px;
    padding: 12px 16px;
  }
  .hero h1 + p {
    margin-bottom: 19px;
  }
  .save-hint {
    font-size: 8px;
  }
  .panel {
    padding: 25px;
  }
  .panel h2 {
    font-size: 27px;
  }
  .panel > p {
    font-size: 11px;
    margin-bottom: 12px;
  }
  .character-card .portrait {
    height: 90px;
  }
  .character-card p {
    font-size: 10px;
  }
  .weapon-card {
    padding: 12px 9px;
  }
  .weapon-card.selected {
    padding: 11px 8px;
  }
  .weapon-art {
    margin-bottom: 10px;
  }
  .island-map {
    height: 105px;
    margin: 12px 0;
  }
  .map-node small {
    display: none;
  }
  .panel-actions {
    margin-top: 15px;
  }
}
@media (max-width: 760px) {
  .app {
    padding: 0 12px;
  }
  .masthead {
    height: 62px;
  }
  .brand strong {
    font-size: 15px;
  }
  .brand-mark {
    width: 27px;
    height: 30px;
    font-size: 20px;
  }
  .masthead-center {
    display: none;
  }
  .header-actions button {
    font-size: 10px;
    padding: 7px 10px;
  }
  .home-nav {
    font-size: 7px;
    gap: 15px;
    top: 4%;
  }
  .hero {
    top: 22%;
  }
  .eyebrow {
    font-size: 6px;
    letter-spacing: 1.5px;
  }
  h1 {
    font-size: 5.8vw;
    letter-spacing: -2px;
    margin: 10px 0 12px;
  }
  h1 + p {
    font-size: 8px;
    line-height: 1.65;
    margin-bottom: 12px !important;
  }
  .hero-actions {
    gap: 8px;
  }
  .hero-actions .button {
    font-size: 8px;
    gap: 12px;
    padding: 9px 11px;
  }
  .save-hint {
    font-size: 6px;
    margin-top: 9px;
  }
  .home-bottom {
    font-size: 6px;
    bottom: 12px;
    letter-spacing: 1px;
  }
  .home-bottom span:last-child {
    display: none;
  }
  footer {
    min-height: 60px;
    gap: 5px;
  }
  .control-legend {
    gap: 6px;
    flex-wrap: wrap;
    font-size: 8px;
  }
  .control-legend > span:nth-child(n + 4) {
    display: none;
  }
  #help {
    font-size: 9px;
  }
  .build-note {
    font-size: 8px;
  }
  .hud-top {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .vitals,
  .region-hud {
    padding: 6px 9px;
    gap: 8px;
  }
  .avatar {
    font-size: 20px;
  }
  .mini-label {
    font-size: 6px;
  }
  #hearts {
    font-size: 12px;
    letter-spacing: 1px;
    line-height: 17px;
  }
  .seal-count {
    font-size: 15px;
    letter-spacing: 1px;
  }
  .coin-glyph {
    width: 17px;
    height: 20px;
    font-size: 10px;
  }
  #coins {
    font-size: 12px;
  }
  .region-hud strong {
    font-size: 9px;
  }
  .region-hud button {
    font-size: 18px;
    padding: 0 5px;
  }
  .hud-bottom {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  #weaponSlots button {
    width: 30px;
    height: 27px;
    font-size: 17px;
  }
  .loadout {
    padding: 5px;
  }
  .energy small {
    font-size: 6px;
  }
  .energy > div {
    width: 35px;
  }
  .objective {
    font-size: 8px;
  }
  #toast {
    top: 65px;
    font-size: 9px;
    padding: 7px 14px;
  }
  #bossHud {
    top: 63px;
    width: 230px;
  }
  #bossHud > span {
    font-size: 7px;
  }
  .panel-layer {
    padding: 10px;
  }
  .panel {
    padding: 20px;
    width: 96%;
  }
  .panel h2 {
    font-size: 24px;
    margin: 6px 0;
  }
  .panel > p {
    font-size: 10px;
    margin-bottom: 12px;
  }
  .panel .button {
    font-size: 10px;
    padding: 11px 15px;
  }
  .character-card {
    padding: 12px;
  }
  .character-card.selected {
    padding: 11px;
  }
  .character-card h3 {
    font-size: 21px;
  }
  .character-card p {
    font-size: 9px;
  }
  .character-card .portrait {
    height: 90px;
  }
  .weapon-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .weapon-art {
    font-size: 25px;
    float: right;
    margin: 0;
  }
  .weapon-card strong {
    font-size: 11px;
  }
  .weapon-card p {
    font-size: 9px;
  }
  .weapon-card small {
    font-size: 6px;
  }
  .chapter-card {
    padding: 8px;
  }
  .chapter-card strong {
    font-size: 10px;
  }
  .chapter-card small {
    font-size: 8px;
  }
  .settings-grid {
    gap: 12px;
    font-size: 10px;
  }
  .settings-grid label {
    font-size: 10px;
  }
  .chapter-banner {
    padding: 12px;
  }
  .chapter-banner h2 {
    font-size: 28px;
  }
  .chapter-banner p {
    font-size: 11px;
  }
  .chapter-banner > span {
    font-size: 7px;
  }
  .results-grid strong {
    font-size: 22px;
  }
  .results-grid span {
    font-size: 7px;
  }
  .controls-table td {
    padding: 5px;
    font-size: 9px;
  }
}
@media (max-width: 560px) and (orientation: portrait) {
  #stage {
    aspect-ratio: 3/4;
  }
  canvas {
    object-fit: cover;
    object-position: 35% center;
  }
  .hero {
    top: 21%;
    left: 7%;
  }
  h1 {
    font-size: 11vw;
    letter-spacing: -2px;
    margin: 20px 0;
  }
  h1 + p {
    font-size: 10px;
  }
  .hero-actions {
    flex-direction: column;
    align-items: start;
    gap: 10px;
  }
  .hero-actions .button {
    font-size: 11px;
    padding: 13px 18px;
  }
  .home-nav {
    gap: 12px;
    font-size: 6px;
  }
  .hero .eyebrow {
    font-size: 7px;
  }
  .save-hint {
    font-size: 8px;
    max-width: 210px;
    line-height: 1.8;
  }
  .home-bottom {
    bottom: 35px;
  }
  .region-hud > div {
    display: none;
  }
  .vitals {
    gap: 5px;
  }
  #hearts {
    font-size: 11px;
  }
  .chapter-list {
    grid-template-columns: 1fr 1fr;
  }
  .island-map {
    height: 130px;
  }
  #rotateHint {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 8px;
    color: #dee6cc;
    display: block;
    pointer-events: none;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .character-grid {
    grid-template-columns: 1fr 1fr;
  }
  .character-card .portrait {
    height: 110px;
  }
  .chapter-banner h2 {
    font-size: 29px;
  }
  #touch {
    bottom: 28px;
    left: 10px;
    right: 10px;
  }
  #touch > div {
    gap: 4px;
  }
  #touch button {
    width: 37px;
    height: 37px;
    font-size: 18px;
  }
  .objective {
    display: none;
  }
  .hud-bottom {
    bottom: 85px;
  }
  .panel > p {
    font-size: 11px;
  }
  .controls-table td {
    font-size: 10px;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  .masthead {
    height: 48px;
  }
  .app {
    max-width: calc((100vh - 48px) * 1.7778);
    padding: 0;
  }
  footer,
  .build-note {
    display: none;
  }
  #stage {
    border-radius: 0;
  }
  .home-nav {
    font-size: 7px;
  }
  .panel {
    padding: 20px;
  }
  .character-card .portrait {
    height: 75px;
  }
  .character-card p {
    display: none;
  }
  .island-map {
    height: 95px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
.home-bottom > span:last-child {
  display: none;
}

.stage-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.island-column h3 {
  font-size: 11px;
  color: #4f7055;
  margin: 0 0 10px;
}
.island-column .chapter-card {
  display: block;
  width: 100%;
  margin-bottom: 7px;
}
.island-column .chapter-card strong {
  font-size: 11px;
  margin: 7px 0;
}
.island-column .chapter-card {
  padding: 10px;
}
.island-column .chapter-card:disabled {
  opacity: 0.55;
}
@media (max-width: 600px) {
  .stage-map {
    grid-template-columns: 1fr 1fr;
  }
  .island-column h3 {
    font-size: 10px;
  }
  .island-column .chapter-card strong {
    font-size: 10px;
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  .hud-top {
    top: 9px;
    left: 10px;
    right: 10px;
  }
  .vitals,
  .region-hud {
    padding: 5px 8px;
    gap: 6px;
  }
  .avatar {
    font-size: 18px;
  }
  .mini-label {
    font-size: 6px;
  }
  #hearts {
    font-size: 11px;
    letter-spacing: 1px;
    line-height: 15px;
  }
  .seal-count {
    font-size: 14px;
    letter-spacing: 1px;
  }
  .coin-glyph {
    font-size: 10px;
    width: 17px;
    height: 19px;
  }
  #coins {
    font-size: 11px;
  }
  .region-hud strong {
    font-size: 9px;
  }
  .region-hud button {
    font-size: 17px;
  }
  .loadout {
    transform: scale(0.78);
    transform-origin: left bottom;
  }
  .hud-bottom {
    left: 12px;
  }
  .chapter-banner {
    top: 27%;
    padding: 10px;
  }
  .chapter-banner h2 {
    font-size: 26px;
  }
  .chapter-banner p {
    font-size: 10px;
  }
  #toast {
    top: 58px;
    font-size: 9px;
  }
  #bossHud {
    top: 52px;
    width: 230px;
  }
}

.binding-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 22px;
}
.binding-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  padding: 8px 9px;
  background: #faf9e966;
  border: 1px solid #bccbad;
  border-radius: 4px;
  color: #52704e;
  font-size: 10px;
  text-transform: capitalize;
}
.binding-button kbd {
  font-size: 8px;
  background: #f9f8e7;
}
@media (max-width: 600px) {
  .binding-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
:root.touch-input .hud-bottom {
  top: 62px;
  bottom: auto;
  align-items: flex-start;
}
:root.touch-input .loadout {
  transform: scale(0.78);
  transform-origin: left top;
}
@media (max-width: 560px) and (orientation: portrait) {
  :root.touch-input .hud-bottom {
    top: 59px;
    bottom: auto;
  }
}

.brand-mark img {
  width: 29px;
  height: 29px;
  object-fit: contain;
}
.coin-glyph img {
  width: 17px;
  height: 17px;
  object-fit: contain;
  filter: grayscale(1) brightness(1.7);
}

/* Audit G1: usable typography and thumb-safe, labelled controls. */
.controls-table th {
  text-align: left;
  padding: 8px;
  font-size: 12px;
}
@media (pointer: coarse) {
  #touch {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    align-items: flex-end;
  }
  #touch button,
  #touch button[data-action='cycle'],
  #touch button[data-action='mount'] {
    width: 48px;
    height: 48px;
    min-width: 44px;
    min-height: 44px;
    font-size: 11px;
    font-weight: 800;
    border: 1px solid #dfedcc99;
  }
  #touch .touch-act {
    display: grid;
    grid-template-columns: repeat(3, 48px);
    gap: 8px;
  }
  #touch .touch-act [data-action='jump'] {
    grid-column: span 2;
    width: 104px;
    background: #dce9ae;
    color: #243e38;
  }
  #touch .touch-move {
    gap: 8px;
  }
  #pause,
  #soundToggle,
  #fullscreen {
    min-width: 44px;
    min-height: 44px;
  }
}
@media (max-width: 600px) {
  .home-nav,
  .home-nav button {
    font-size: 11px;
  }
  .home-nav {
    flex-wrap: wrap;
    gap: 8px 14px;
  }
  .home-nav button {
    min-height: 36px;
  }
  .hero .eyebrow,
  .save-hint {
    font-size: 11px;
  }
  .hero p {
    font-size: 12px;
    line-height: 1.6;
  }
  .controls-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .controls-table td {
    font-size: 12px;
    min-width: 95px;
  }
  .panel {
    max-height: calc(100% - 16px);
    padding: 18px;
  }
  .settings-grid label,
  .settings-note,
  .character-card p {
    font-size: 12px;
  }
  .settings-grid input[type='range'] {
    min-height: 44px;
  }
  .binding-button {
    min-height: 44px;
    font-size: 12px;
  }
  .map-node small {
    font-size: 10px;
  }
}
@media (max-width: 560px) and (orientation: portrait) {
  .home-nav {
    top: 12px;
    left: 6%;
    right: 6%;
  }
  .hero {
    top: 24%;
  }
  .hero h1 {
    margin: 12px 0;
    font-size: 10.5vw;
  }
  .hero-actions {
    gap: 8px;
  }
  .hero-actions .button {
    min-height: 44px;
    font-size: 12px;
    padding: 11px 16px;
  }
  .home-bottom {
    display: none;
  }
  #rotateHint {
    bottom: 125px;
    font-size: 10px;
  }
  :root.touch-input .loadout {
    transform: scale(0.9);
  }
}

.ending-scene {
  margin: 16px 0;
}
.ending-scene canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  border-radius: 10px;
  object-fit: contain;
  background: #233c52;
}
#endingCaption {
  min-height: 2.8em;
  font-size: 14px;
  line-height: 1.6;
}
.memory-journal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.memory-journal article,
.memory-reward {
  background: #eaf0d4;
  color: #334f42;
  padding: 14px;
  border: 1px solid #b0c3a0;
  border-radius: 8px;
}
.memory-journal h3 {
  font-size: 14px;
}
.memory-journal p,
.memory-reward {
  font-size: 13px;
  line-height: 1.65;
}
.memory-reward {
  margin-top: 18px;
}
@media (max-width: 600px) {
  .memory-journal {
    grid-template-columns: 1fr;
  }
  .ending-scene canvas {
    max-height: 180px;
  }
  .home-nav {
    column-gap: 12px;
  }
}

/* Quality P0: landscape needs legible navigation too. */
@media (pointer: coarse) and (orientation: landscape) {
  .home-nav,
  .home-nav button {
    font-size: 11px;
  }
  .home-nav {
    gap: 12px;
    flex-wrap: wrap;
    top: 14px;
  }
  .home-nav button {
    min-height: 32px;
  }
  .hero .eyebrow {
    font-size: 10px;
  }
  .hero {
    top: 30%;
  }
  .hero h1 {
    font-size: 32px;
    margin: 8px 0;
    line-height: 1.04;
    letter-spacing: -1px;
  }
  .hero p {
    font-size: 11px;
    line-height: 1.4;
    margin: 7px 0;
  }
  .hero-actions {
    gap: 8px;
  }
  .hero-actions .button {
    min-height: 40px;
    padding: 9px 14px;
    font-size: 11px;
  }
  .save-hint {
    font-size: 10px;
  }
  .home-bottom {
    display: none;
  }
}

/* Primary modal controls stay thumb-sized without covering headings. */
@media (pointer: coarse) {
  .panel .close {
    width: 44px;
    height: 44px;
    right: 8px;
    top: 8px;
  }
  .panel h2 {
    padding-right: 32px;
  }
  .panel select,
  .panel-actions button {
    min-height: 44px;
  }
}

/* P3 visual acceptance: content-first title flow, not a clipped gameplay canvas. */
@media (max-width: 600px) and (orientation: portrait) {
  #stage[data-view='home'] {
    aspect-ratio: auto;
  }
  #stage[data-view='home'] > #gameCanvas {
    position: absolute;
    inset: 0;
    object-fit: cover;
  }
  #home {
    position: relative;
    inset: auto;
    min-height: 580px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 20px;
    background: linear-gradient(110deg, #153e37ed, #153e3770);
  }
  .home-nav {
    position: static;
    width: 100%;
    gap: 4px 12px;
    color: #e5ecd9;
  }
  .home-nav button {
    min-height: 44px;
  }
  .home-nav .nav-active {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .nav-active:after {
    bottom: 0;
  }
  .hero {
    position: static;
    width: 100%;
  }
  .hero .eyebrow {
    font-size: 11px;
    letter-spacing: 1.15px;
    line-height: 1.5;
  }
  .hero h1 {
    font-size: clamp(32px, 10vw, 48px);
    line-height: 1.06;
    margin: 16px 0;
  }
  .hero > p {
    font-size: 14px;
    line-height: 1.6;
    color: #e0e7d8;
    margin: 0 0 20px;
  }
  .hero > p br {
    display: none;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .hero-actions .button {
    width: 100%;
    min-height: 48px;
    font-size: 14px;
    padding: 12px 16px;
  }
  .hero-actions .ghost {
    background: #1a393dd9;
    border-color: #dce7c770;
    color: #f0f0df;
  }
  .save-hint {
    max-width: none;
    font-size: 12px;
    line-height: 1.6;
    color: #dce5d3;
    margin-top: 16px;
  }
  .hero #rotateHint {
    display: block;
    position: static;
    inset: auto;
    width: auto;
    margin: 14px 0 0;
    text-align: left;
    font-size: 12px;
    line-height: 1.5;
    color: #e0e7d8;
  }
}

/* Landscape title: a compact two-column composition, with both actions and save text intact. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 550px) {
  #stage[data-view='home'] {
    aspect-ratio: auto;
  }
  #stage[data-view='home'] > #gameCanvas {
    position: absolute;
    inset: 0;
    object-fit: cover;
  }
  #home {
    position: relative;
    inset: auto;
    width: 100%;
    min-height: calc(100svh - 48px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px 16px;
    background: linear-gradient(110deg, #153e37eb, #153e3790);
  }
  .home-nav {
    position: static;
    width: 100%;
    gap: 4px 12px;
    color: #e5ecd9;
  }
  .home-nav button,
  .home-nav .nav-active {
    min-height: 44px;
  }
  .home-nav .nav-active {
    display: inline-flex;
    align-items: center;
  }
  .nav-active:after {
    bottom: 0;
  }
  .hero {
    position: static;
    width: 100%;
    display: grid;
    align-items: start;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 'eyebrow eyebrow' 'title copy' 'save actions';
    gap: 10px 18px;
  }
  .hero .eyebrow {
    grid-area: eyebrow;
    font-size: 11px;
    letter-spacing: 1.4px;
  }
  .hero h1 {
    grid-area: title;
    font-size: 32px;
    line-height: 1.05;
    margin: 0;
  }
  .hero > p {
    grid-area: copy;
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: #e0e7d8;
  }
  .hero > p br {
    display: none;
  }
  .hero-actions {
    grid-area: actions;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .hero-actions .button {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 12px;
  }
  .hero-actions .ghost {
    background: #1a393dd9;
    border-color: #dce7c770;
    color: #f0f0df;
  }
  .save-hint {
    grid-area: save;
    font-size: 12px;
    line-height: 1.5;
    margin: 0;
    max-width: none;
    color: #dce5d3;
  }
}
