:root {
  --night: #071632;
  --ink: #090a23;
  --panel: #11163e;
  --panel-hi: #25265d;
  --cream: #fff8df;
  --gold: #ffd35a;
  --gold-deep: #a9551b;
  --pink: #ff70b7;
  --cyan: #61e6ee;
  --green: #72e28f;
  --purple: #9b76ef;
  --danger: #ff7a86;
  --shadow: #02040f;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--night);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  font-family: "Press Start 2P", ui-monospace, monospace;
  background:
    radial-gradient(circle at 15% 12%, rgba(73, 147, 207, .25), transparent 30rem),
    radial-gradient(circle at 84% 80%, rgba(131, 65, 151, .22), transparent 35rem),
    linear-gradient(180deg, #071a3d 0, #061126 45%, #030713 100%);
  -webkit-user-select: none;
  user-select: none;
}

body.arcade-game {
  background:
    radial-gradient(circle at 15% 12%, rgba(73, 147, 207, .25), transparent 30rem),
    radial-gradient(circle at 84% 80%, rgba(131, 65, 151, .22), transparent 35rem),
    linear-gradient(180deg, #071a3d 0, #061126 45%, #030713 100%) !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 18px 18px;
}

[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible { outline: 3px solid white; outline-offset: 3px; }

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

.prototype-shell {
  width: min(1180px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 12px 0 28px;
}

.prototype-head {
  position: relative;
  margin-bottom: 13px;
  overflow: hidden;
  border: 5px solid var(--gold);
  background: #061124;
  box-shadow: 0 0 0 4px #000, 11px 11px 0 rgba(0,0,0,.56);
}

.prototype-head > img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.hero-bar {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-top: 3px solid rgba(255, 211, 90, .78);
  background: rgba(4, 9, 29, .92);
  box-shadow: 0 -8px 20px rgba(2,4,15,.38);
}

.hero-bar > span {
  color: var(--cyan);
  font-size: 7px;
  line-height: 1.5;
}

.hero-bar p {
  margin: 0;
  color: #e9ecff;
  font: 20px/1 "VT323", ui-monospace, monospace;
  text-align: center;
}

.game-frame {
  padding: 8px;
  border: 5px solid var(--purple);
  background: #020313;
  box-shadow: 0 0 0 4px #000, 0 0 0 8px #2d8aaa, 12px 12px 0 rgba(0,0,0,.58);
}

.game-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 3px solid #384182;
  background: #101948;
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.game-hud {
  position: absolute;
  z-index: 5;
  top: 9px;
  right: 108px;
  left: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 211, 90, .72);
  background: rgba(5, 9, 29, .9);
  box-shadow: 4px 4px 0 rgba(0,0,0,.45);
  pointer-events: none;
}

.hud-objective { min-width: 0; }

.hud-objective span {
  display: block;
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: 6px;
  letter-spacing: .1em;
}

.hud-objective strong {
  display: block;
  overflow: hidden;
  color: white;
  font-size: 8px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-counts {
  display: flex;
  gap: 13px;
  color: var(--gold);
  font: 22px/1 "VT323", ui-monospace, monospace;
  white-space: nowrap;
}

.hud-counts span:last-child { color: var(--pink); }

.quest-map {
  position: absolute;
  z-index: 6;
  top: 63px;
  right: 9px;
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 3px;
  padding: 7px;
  border: 2px solid rgba(97, 230, 238, .65);
  background: rgba(5, 9, 29, .9);
  pointer-events: none;
}

.quest-map i {
  display: block;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255,255,255,.38);
  background: #35385a;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.25);
}

.quest-map i.solved { background: var(--green); }
.quest-map i.target { background: var(--gold); animation: mapPulse .85s steps(2) infinite; }
.quest-map i.current { outline: 2px solid white; outline-offset: 1px; }
.quest-map i.locked { background: #2c2445; }

@keyframes mapPulse {
  50% { background: white; box-shadow: 0 0 9px var(--gold); }
}

.room-banner {
  position: absolute;
  z-index: 4;
  top: 69px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 11px;
  border: 2px solid rgba(255,255,255,.38);
  color: white;
  background: rgba(7, 9, 28, .78);
  font-size: 7px;
  letter-spacing: .06em;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s;
}

.room-banner.show { opacity: 1; }

.action-prompt {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 17px;
  transform: translateX(-50%);
  padding: 9px 13px;
  border: 3px solid var(--gold);
  color: var(--ink);
  background: var(--cream);
  box-shadow: 5px 5px 0 #000;
  font-size: 8px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  animation: promptBob .8s steps(2) infinite;
}

@keyframes promptBob {
  50% { transform: translate(-50%, -3px); }
}

.toast {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 16px;
  width: min(680px, calc(100% - 24px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 3px solid var(--gold);
  color: white;
  background: rgba(8,9,31,.95);
  box-shadow: 5px 5px 0 #000;
  font: 22px/1.12 "VT323", ui-monospace, monospace;
  text-align: center;
  pointer-events: none;
}

.dialogue {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: 14px;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  width: min(790px, calc(100% - 24px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border: 4px solid var(--cyan);
  background: #090d30;
  box-shadow: 7px 7px 0 #000;
}

.dialogue-portrait {
  width: 78px;
  height: 78px;
  border: 3px solid #5664aa;
  background-color: #17204f;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
}

.dialogue strong {
  color: var(--gold);
  font-size: 9px;
}

.dialogue p {
  min-height: 34px;
  margin: 7px 0 6px;
  color: white;
  font: 23px/1.05 "VT323", ui-monospace, monospace;
}

.dialogue button {
  float: right;
  padding: 4px 0;
  border: 0;
  color: var(--cyan);
  background: transparent;
  font-size: 7px;
  cursor: pointer;
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(10px, 3vw, 28px);
  background: rgba(3, 6, 23, .8);
  backdrop-filter: blur(2px);
}

.title-card,
.puzzle-card,
.assist-card {
  width: min(780px, 100%);
  max-height: 100%;
  overflow: auto;
  border: 5px solid var(--gold);
  background:
    linear-gradient(135deg, rgba(43, 43, 104, .98), rgba(22, 17, 66, .98));
  box-shadow: 9px 9px 0 #000, inset 0 0 0 3px rgba(255,255,255,.09);
}

.title-card {
  padding: clamp(18px, 4vw, 34px);
  text-align: center;
}

.title-card.compact { width: min(670px, 100%); }

.card-kicker {
  display: block;
  margin-bottom: 9px;
  color: var(--cyan);
  font-size: 7px;
  letter-spacing: .09em;
  line-height: 1.5;
}

.title-card h2,
.puzzle-card h2,
.assist-card h2 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(18px, 3.5vw, 35px);
  line-height: 1.25;
  text-shadow: 3px 3px 0 #9b3c6f, 5px 5px 0 #050617;
}

.title-card > p,
.assist-card p {
  margin: 18px auto;
  color: #f5efff;
  font: clamp(20px, 2.5vw, 28px)/1.13 "VT323", ui-monospace, monospace;
}

.quest-route {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
  margin: 15px 0 20px;
  padding: 11px;
  border: 2px dashed rgba(97,230,238,.55);
  color: #dce9ff;
  background: rgba(3,6,23,.35);
  font-size: 6px;
  line-height: 1.7;
}

.quest-route b { color: var(--pink); }

.pixel-button {
  position: relative;
  min-height: 40px;
  padding: 10px 13px;
  border: 3px solid #d8d9ff;
  color: white;
  background: #343b89;
  box-shadow: 4px 4px 0 #050617;
  font-size: 7px;
  line-height: 1.4;
  cursor: pointer;
}

.pixel-button:hover { filter: brightness(1.17); transform: translateY(-1px); }
.pixel-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #050617; }
.pixel-button:disabled { cursor: wait; opacity: .6; filter: grayscale(.6); }
.pixel-button.primary { border-color: #fff1a1; color: #201528; background: var(--gold); }
.pixel-button.subtle { border-color: #5d679e; color: #d7dcff; background: #111538; }
.pixel-button.smash { border-color: #ffd387; color: #191025; background: #ff8e44; }
.pixel-button.small { min-height: 34px; padding: 8px 10px; font-size: 6px; }

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 20px 0;
  text-align: left;
}

.help-grid span {
  min-height: 48px;
  padding: 11px;
  border: 2px solid rgba(147,121,239,.62);
  color: #dbe1ff;
  background: rgba(8,9,31,.58);
  font: 19px/1.15 "VT323", ui-monospace, monospace;
}

.help-grid b {
  display: block;
  margin-bottom: 4px;
  color: var(--pink);
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 7px;
}

.puzzle-overlay { z-index: 24; }

.puzzle-card {
  width: min(850px, 100%);
  padding: clamp(14px, 3vw, 24px);
  border-color: var(--cyan);
  background:
    linear-gradient(rgba(7,16,48,.95), rgba(16,19,59,.97)),
    url("/site-assets/web/shiloh-v3-world.webp") center / cover;
}

.puzzle-head {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 13px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 3px solid rgba(97,230,238,.45);
}

.puzzle-badge {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid #fff0a1;
  color: #29162d;
  background: var(--gold);
  box-shadow: 4px 4px 0 #000;
  font-size: 13px;
}

.puzzle-head h2 { font-size: clamp(15px, 3vw, 28px); }
.puzzle-progress { color: var(--pink); font-size: 6px; line-height: 1.5; text-align: right; }

.puzzle-instruction {
  margin: 16px 0 11px;
  color: white;
  font: clamp(22px, 3vw, 30px)/1.08 "VT323", ui-monospace, monospace;
  text-align: center;
}

.puzzle-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 105px;
  margin: 0 auto 12px;
  padding: 12px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.26);
  background: rgba(4,8,30,.7);
  box-shadow: inset 0 0 22px rgba(0,0,0,.4);
}

.puzzle-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.puzzle-choices.memory-mode {
  display: block;
}

.puzzle-choices.success-mode {
  grid-template-columns: minmax(220px, 520px);
  justify-content: center;
}

.choice-button {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 76px;
  padding: 10px;
  border: 3px solid #6b76bb;
  color: white;
  background: #283074;
  box-shadow: 4px 4px 0 #050617;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: clamp(8px, 1.6vw, 13px);
  line-height: 1.45;
  cursor: pointer;
}

.choice-button > span:last-child {
  display: block;
}

.choice-button:hover,
.choice-button.hinted {
  border-color: var(--gold);
  background: #454aa1;
  box-shadow: 0 0 16px rgba(255,211,90,.62), 4px 4px 0 #050617;
}

.choice-button.correct { border-color: var(--green); background: #23724a; }
.choice-button.wrong { animation: choiceShake .28s steps(2); border-color: var(--danger); }
.choice-button:disabled { cursor: default; }

@keyframes choiceShake {
  33% { transform: translateX(-5px); }
  66% { transform: translateX(5px); }
}

.puzzle-feedback {
  min-height: 42px;
  margin: 11px 0 8px;
  color: #eff3ff;
  font: 21px/1.1 "VT323", ui-monospace, monospace;
  text-align: center;
}

.puzzle-feedback.good { color: #a7ffc2; }
.puzzle-feedback.try { color: #ffd4a0; }

.success-burst {
  display: grid;
  place-items: center;
  gap: 5px;
  color: var(--gold);
  text-align: center;
}

.success-burst span {
  font-size: clamp(52px, 9vw, 82px);
  line-height: .9;
  text-shadow: 0 0 18px rgba(255,211,90,.78), 5px 5px 0 #8a3e31;
  animation: heartBeat .65s steps(2) infinite;
}

.success-burst b {
  color: white;
  font-size: 9px;
  line-height: 1.4;
}

.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-top: 9px;
  border-top: 2px solid rgba(255,255,255,.13);
}

.ely-mini { border-color: #ffcc75; background: #795229; }

.count-row,
.equation-row,
.pattern-row,
.heart-lanterns,
.finale-slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.equation-row { gap: 16px; }
.equation-symbol { color: var(--gold); font-size: clamp(18px, 3vw, 30px); }

.object-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 230px;
  padding: 9px;
  border: 2px dashed rgba(97,230,238,.45);
}

.dumpling {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 24px;
  border: 3px solid #9f5a27;
  border-radius: 50% 50% 42% 42%;
  background: #ffe6a1;
  box-shadow: inset -5px -4px 0 #e9a852, 2px 3px 0 rgba(0,0,0,.28);
}

.dumpling::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 7px;
  width: 14px;
  height: 8px;
  border-top: 3px dotted #9f5a27;
}

.firefly {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid #fff2a2;
  border-radius: 50%;
  background: #f5cc3c;
  box-shadow: 0 0 11px #ffe15a;
  animation: fireflyFloat .7s steps(2) infinite alternate;
}

.firefly:nth-child(even) { animation-delay: -.35s; }

@keyframes fireflyFloat {
  to { transform: translateY(-5px); }
}

.note-tile,
.move-tile,
.slot-tile {
  display: grid;
  place-items: center;
  min-width: 62px;
  min-height: 62px;
  padding: 8px;
  border: 3px solid rgba(255,255,255,.5);
  color: white;
  background: #41457e;
  box-shadow: 4px 4px 0 #030613;
  font-size: 11px;
  text-align: center;
}

.note-tile.pink { background: #b73d82; }
.note-tile.blue { background: #2576a9; }
.note-tile.gold { color: #2c1930; background: #e8b73c; }
.note-tile.mystery { background: #252949; animation: mysteryPulse .8s steps(2) infinite; }

@keyframes mysteryPulse { 50% { border-color: var(--gold); } }

.ribbon-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.ribbon-piece {
  width: 43px;
  height: 16px;
  border: 2px solid #a72e71;
  background: var(--pink);
  box-shadow: 3px 3px 0 #160919;
}

.ribbon-piece.gone {
  opacity: .2;
  filter: grayscale(1);
  transform: rotate(16deg) translateY(-10px);
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  gap: 9px;
  width: min(500px, 100%);
  margin: auto;
}

.memory-card {
  min-height: 68px;
  border: 3px solid #bc86df;
  color: transparent;
  background:
    radial-gradient(circle, #c75dd0 0 18%, transparent 19%),
    #3d245e;
  background-size: 17px 17px;
  box-shadow: 4px 4px 0 #050617;
  font-size: 12px;
  cursor: pointer;
}

.memory-card.revealed,
.memory-card.matched {
  color: white;
  background: #314c88;
}

.memory-card.matched {
  border-color: var(--green);
  background: #245f48;
}

.memory-card.hinted { animation: memoryWiggle .5s steps(2) infinite; }

@keyframes memoryWiggle {
  50% { transform: rotate(2deg) translateY(-2px); }
}

.dance-demo .move-tile { opacity: .35; }
.dance-demo .move-tile.active { opacity: 1; border-color: var(--gold); transform: translateY(-5px); box-shadow: 0 0 16px var(--gold), 4px 4px 0 #030613; }

.step-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
}

.step-dots i {
  width: 13px;
  height: 13px;
  border: 2px solid #b8c3ff;
  background: #252949;
}

.step-dots i.done { border-color: var(--green); background: var(--green); }

.heart-lanterns {
  position: relative;
  width: min(500px, 100%);
  min-height: 105px;
}

.heart-lantern {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 95px;
  height: 80px;
  color: #9e89b2;
  font-size: 45px;
  filter: grayscale(1);
}

.heart-lantern.lit {
  color: var(--pink);
  filter: none;
  text-shadow: 0 0 18px #ff85c2;
  animation: heartBeat .65s steps(2) infinite;
}

.temple-ribbon {
  position: absolute;
  z-index: 1;
  top: 51px;
  left: 50%;
  width: 0;
  height: 11px;
  transform: translateX(-50%);
  border: 3px solid transparent;
  background: transparent;
  transition: width .8s steps(8), background .2s;
}

.temple-ribbon.linked {
  width: 220px;
  border-color: #a53074;
  background: var(--pink);
  box-shadow: 0 0 14px #ff85c2;
}

@keyframes heartBeat { 50% { transform: scale(1.08); } }

.slot-tile {
  min-width: 100px;
  color: #697196;
  background: #171c43;
}

.slot-tile.filled {
  border-color: var(--green);
  color: white;
  background: #245f48;
}

.assist-overlay { z-index: 30; }

.assist-card {
  display: grid;
  grid-template-columns: minmax(120px, 210px) 1fr;
  gap: 20px;
  align-items: center;
  padding: clamp(15px, 3vw, 28px);
  border-color: #ffb257;
}

.assist-card > img {
  display: block;
  width: 100%;
  max-height: 245px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(6px 8px 0 rgba(0,0,0,.5));
}

.assist-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.ely-call {
  position: absolute;
  z-index: 9;
  right: 9px;
  bottom: 9px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  padding: 3px 8px 3px 2px;
  overflow: hidden;
  border: 3px solid #ffd184;
  color: white;
  background: #315e3e;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}

.ely-call img {
  width: 46px;
  height: 51px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}

.ely-call span { font-size: 5px; line-height: 1.5; text-align: left; }
.ely-call b { display: block; color: var(--gold); font-size: 7px; }

.ending-overlay { z-index: 35; background: rgba(3,6,23,.88); }
.ending-card { width: min(720px, 100%); border-color: var(--pink); }

.ending-scene {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  height: 145px;
  margin: 16px 0 8px;
  overflow: hidden;
  border-bottom: 4px solid var(--pink);
  background: radial-gradient(circle, rgba(255,215,104,.35), transparent 65%);
}

.ending-scene img {
  width: 128px;
  height: 138px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}

.ending-scene img:last-child { width: 68px; height: 105px; }
.ending-scene span { align-self: center; color: var(--pink); font-size: 36px; animation: heartBeat .65s steps(2) infinite; }
.ending-stats { color: var(--gold) !important; font-size: 22px !important; }

.desktop-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  padding: 13px 8px 6px;
  color: #bbc3ef;
  font: 19px/1 "VT323", ui-monospace, monospace;
}

.desktop-controls b {
  margin-right: 4px;
  color: var(--cyan);
  font: 6px/1 "Press Start 2P", ui-monospace, monospace;
}

.touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 660px;
  margin: 20px auto 0;
}

.touch-controls[data-disabled="true"] { opacity: .4; pointer-events: none; }

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 46px);
  gap: 5px;
}

.touch-dpad button,
.touch-actions button {
  border: 3px solid #7c8bd5;
  color: white;
  background: #22285f;
  box-shadow: 3px 3px 0 #000;
  touch-action: none;
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  gap: 8px;
}

.touch-actions button {
  min-height: 46px;
  padding: 6px;
  font-size: 6px;
}

.prototype-note {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 5px 0;
  color: #8f98c7;
  font: 18px/1.2 "VT323", ui-monospace, monospace;
}

.prototype-note a {
  color: var(--cyan);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.top-actions {
  position: absolute;
  z-index: 18;
  top: 9px;
  right: 9px;
  display: flex;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border: 3px solid var(--cyan);
  color: var(--cream);
  background: rgba(5, 9, 29, .94);
  box-shadow: 4px 4px 0 #000;
  font: 8px/1 "Press Start 2P", ui-monospace, monospace;
  text-decoration: none;
  cursor: pointer;
}

.exit-button {
  width: auto;
  min-width: 58px;
  padding: 0 8px;
  border-color: var(--gold);
  color: var(--gold);
}

.embed-only { display: none; }
.arcade-game.embedded .embed-only { display: inline-flex; }

body.arcade-game .game-frame {
  border-color: var(--purple) !important;
  box-shadow: 0 0 0 4px #000, 0 0 0 8px #2d8aaa, 12px 12px 0 rgba(0,0,0,.58) !important;
}

body.arcade-game.embedded .prototype-shell {
  width: 100%;
  padding: 0;
}

body.arcade-game.embedded .game-frame {
  padding: 0;
  border: 0;
  box-shadow: none !important;
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: flex; }
  .desktop-controls { display: none; }
  .prototype-shell { width: min(100% - 10px, 1180px); padding-top: 5px; }
  .game-frame { padding: 4px; border-width: 3px; box-shadow: 0 0 0 2px #000, 0 0 0 5px #2d8aaa; }
  .hero-bar { position: relative; grid-template-columns: 1fr auto; }
  .hero-bar p { display: none; }
  .game-hud { right: 108px; padding: 6px 8px; min-height: 42px; }
  .hud-objective span { font-size: 5px; }
  .hud-objective strong { max-width: 54vw; font-size: 6px; }
  .hud-counts { gap: 7px; font-size: 17px; }
  .quest-map { grid-template-columns: repeat(3, 8px); grid-template-rows: repeat(3, 8px); padding: 5px; gap: 2px; }
  .quest-map i { width: 8px; height: 8px; }
  .room-banner { top: 58px; font-size: 5px; padding: 6px 8px; }
  .ely-call { width: 52px; height: 46px; padding: 1px; }
  .ely-call img { width: 44px; height: 43px; }
  .ely-call span { display: none; }
  .action-prompt { bottom: 8px; font-size: 6px; padding: 7px 9px; }
  .dialogue { grid-template-columns: 57px 1fr; gap: 9px; bottom: 7px; padding: 8px; border-width: 3px; }
  .dialogue-portrait { width: 53px; height: 53px; }
  .dialogue p { min-height: 0; margin: 4px 0; font-size: 17px; }
  .dialogue strong, .dialogue button { font-size: 5px; }
  .overlay { place-items: start center; padding: 8px; }
  .title-card, .puzzle-card, .assist-card { max-height: none; margin: auto; border-width: 3px; box-shadow: 5px 5px 0 #000; }
  .title-card { padding: 15px; }
  .title-card > p, .assist-card p { margin: 11px auto; font-size: 19px; }
  .title-card h2, .assist-card h2 { font-size: 17px; }
  .quest-route { display: none; }
  .puzzle-card { padding: 10px; }
  .puzzle-head { grid-template-columns: 43px 1fr; gap: 8px; }
  .puzzle-badge { width: 40px; height: 40px; font-size: 9px; }
  .puzzle-progress { display: none; }
  .puzzle-head h2 { font-size: 12px; }
  .puzzle-instruction { margin: 9px 0 7px; font-size: 19px; }
  .puzzle-visual { min-height: 74px; padding: 7px; margin-bottom: 7px; }
  .puzzle-choices { gap: 6px; }
  .choice-button { min-height: 56px; padding: 6px; border-width: 2px; box-shadow: 2px 2px 0 #000; font-size: 7px; }
  .puzzle-feedback { min-height: 30px; margin: 7px 0 5px; font-size: 17px; }
  .puzzle-actions { gap: 5px; padding-top: 6px; }
  .pixel-button.small { min-height: 30px; padding: 6px 7px; font-size: 5px; }
  .dumpling { width: 27px; height: 19px; border-width: 2px; }
  .firefly { width: 14px; height: 14px; border-width: 2px; }
  .note-tile, .move-tile, .slot-tile { min-width: 44px; min-height: 44px; padding: 5px; border-width: 2px; font-size: 7px; }
  .memory-card { min-height: 49px; font-size: 8px; }
  .assist-card { grid-template-columns: 90px 1fr; gap: 10px; padding: 12px; }
  .assist-actions { gap: 5px; }
  .assist-actions .pixel-button { min-height: 34px; padding: 6px; font-size: 5px; }
  .ending-scene { height: 100px; }
  .ending-scene img { width: 90px; height: 98px; }
  .ending-scene img:last-child { width: 50px; height: 75px; }
  .prototype-note { flex-direction: column; gap: 4px; padding-top: 14px; text-align: center; }
}

@media (max-width: 720px) {
  .prototype-head { display: none; }
  body.arcade-game:not(.management-game) .game-viewport.viewport {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

@media (min-width: 721px) and (pointer: fine) {
  body.arcade-game.game-shilohs-quest:not(.management-game) .game-viewport.viewport {
    width: min(100cqw, calc(100cqh * 16 / 9));
    height: min(100cqh, calc(100cqw * 9 / 16));
  }
}

@media (max-width: 500px) {
  .prototype-head { border-width: 3px; }
  .hero-bar { padding: 7px; }
  .hero-bar > span { font-size: 5px; }
  .hero-bar .pixel-button { min-height: 32px; padding: 6px; font-size: 5px; }
  .hud-counts span:last-child { display: none; }
  .touch-dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 40px); }
  .touch-actions { grid-template-columns: repeat(2, 61px); }
  .touch-actions button { min-height: 40px; }
  .assist-card { grid-template-columns: 1fr; text-align: center; }
  .assist-card > img { display: none; }
  .help-grid { grid-template-columns: 1fr; gap: 5px; }
  .help-grid span { min-height: 38px; padding: 7px; font-size: 16px; }
  .ending-card > p { font-size: 17px; }
}

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