:root {
  color-scheme: dark;
  --ink: #eef0e5;
  --muted: #9fa6af;
  --panel: #111522;
  --line: #394052;
  --red: #b9443f;
  --gold: #d7b36a;
  --cold-glow: rgba(113, 158, 178, .2);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.2vw, 28px);
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
  -webkit-touch-callout: none;
  background:
    radial-gradient(ellipse at 50% -25%, #31394d 0, #111622 40%, transparent 72%),
    linear-gradient(135deg, #05070c, #0a0d15 52%, #05060a),
    #070910;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: min(1120px, 100%);
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 26px 42px rgba(0,0,0,.48));
}

.hud {
  display: grid;
  grid-template-columns: minmax(190px, 2fr) repeat(4, minmax(82px, 1fr)) auto;
  align-items: center;
  gap: 1px;
  min-height: 64px;
  border: 1px solid #495163;
  border-bottom: 0;
  background: linear-gradient(180deg, #121725, #090c14);
  box-shadow: inset 0 1px rgba(208,220,229,.06), 0 -10px 45px rgba(89, 103, 146, .08);
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: .11em;
}

.brand {
  margin: 0;
  padding: 0 22px;
  color: #f2e8c7;
  font-size: clamp(17px, 2.3vw, 28px);
  font-weight: 900;
  letter-spacing: .15em;
  text-shadow: 0 2px 0 #5b2227, 0 0 18px rgba(214, 188, 126, .16);
  white-space: nowrap;
}

.hud-item {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 1px solid #292e3a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.hud-item span { color: #858c9a; font-size: 9px; margin-bottom: 5px; }
.hud-item strong { color: #edf0e6; font-size: 14px; letter-spacing: .07em; }
.hud-item strong { text-shadow: 0 1px 8px rgba(164,190,204,.11); }
.hud-item small {
  max-width: 132px;
  margin-top: 3px;
  color: #6f7783;
  font-size: 7px;
  line-height: 1.1;
  letter-spacing: .02em;
  text-align: center;
  text-transform: none;
}
.weapon { position: relative; }
.amulet-icon {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 12px;
  height: 14px;
  border: 1px solid #71838a;
  clip-path: polygon(20% 0, 82% 8%, 100% 43%, 76% 100%, 23% 92%, 0 45%);
  background: linear-gradient(145deg, #182126 20%, #090d11 62%, #54221f 100%);
  box-shadow: inset 0 0 0 2px #0c1115, 0 0 6px rgba(103,163,183,.2);
}
.amulet-icon::after { content: ""; position: absolute; inset: 3px 5px; background: #78b6ca; box-shadow: 2px 4px 0 #9b3a34; }
.amulet-icon.autofire-active { filter: brightness(1.35); box-shadow: 0 0 9px rgba(116,184,203,.45), 0 0 5px rgba(164,59,48,.35); }
.amulet-icon[hidden] { display: none; }
.hud-actions {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  border-left: 1px solid #292e3a;
}
.hud-button {
  width: 58px;
  padding: 5px;
  border: 0;
  border-left: 1px solid #292e3a;
  background: #111521;
  color: #aeb5bf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: none;
}
.hud-button:hover { color: #f3e8cc; background: #1b202d; }
.hud-button:active { background: #2a1b20; transform: scale(.96); }
.hud-button:focus-visible, .panel button:focus-visible, .touch-button:focus-visible { outline: 2px solid #b7d3dc; outline-offset: -3px; }
.hud-button:disabled, .panel button:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.6); }

.audio-debug {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #343b48;
  border-top: 0;
  background: rgba(5, 8, 13, .96);
  color: #9ed7b0;
  font: 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.audio-debug[hidden] { display: none; }
.campaign-debug {
  position: absolute;
  z-index: 9;
  top: 64px;
  left: 1px;
  max-width: min(330px, 46vw);
  max-height: calc(100% - 66px);
  overflow: hidden;
  border: 1px solid rgba(74, 96, 108, .72);
  background: rgba(4, 8, 13, .84);
  color: #b8dce5;
  font-size: 8px;
  line-height: 1.28;
  pointer-events: none;
}
.lives strong { display: flex; gap: 5px; min-height: 20px; }
.life-icon {
  display: inline-block;
  width: 16px;
  height: 19px;
  border: 2px solid #d8dce0;
  border-radius: 50% 50% 45% 45%;
  background: linear-gradient(90deg, #555f69, #e0e2df 48%, #737d86);
  clip-path: polygon(50% 0, 94% 22%, 82% 78%, 50% 100%, 18% 78%, 6% 22%);
  filter: drop-shadow(0 1px 2px #000);
}
.life-icon.lost { opacity: .16; filter: grayscale(1); }
#lives.critical .life-icon:not(.lost) {
  border-color: #d97a6c;
  background: linear-gradient(90deg, #6b3a38, #e8b7a8 48%, #8a4a44);
  animation: life-critical 1.1s ease-in-out infinite;
}
@keyframes life-critical {
  0%, 100% { filter: drop-shadow(0 1px 2px #000); }
  50% { filter: drop-shadow(0 0 7px rgba(220, 84, 68, .8)); }
}
@media (prefers-reduced-motion: reduce) {
  #lives.critical .life-icon:not(.lost) { animation: none; }
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #4a5264;
  outline: 1px solid rgba(156, 171, 186, .08);
  outline-offset: -5px;
  background: #080b16;
  box-shadow: inset 0 0 0 5px rgba(2,4,9,.42), 0 22px 55px rgba(0, 0, 0, .62), 0 0 42px var(--cold-glow);
  overflow: hidden;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  -webkit-user-drag: none;
}

.weapon-toast {
  position: absolute;
  left: 50%;
  top: 12%;
  z-index: 3;
  padding: 8px 15px;
  border: 1px solid rgba(211, 179, 104, .48);
  background: rgba(8, 11, 18, .82);
  color: #f4e4b9;
  box-shadow: 0 7px 24px rgba(0, 0, 0, .38), inset 0 0 16px rgba(217, 163, 83, .08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.weapon-toast.visible { opacity: 1; transform: translate(-50%, 0); }

.boss-intro {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(20, 34, 51, .52), rgba(2, 5, 12, .9));
  transition: opacity .42s ease, visibility .42s ease;
}
.boss-intro.visible { visibility: visible; opacity: 1; }
.boss-intro.leaving { opacity: 0; }
.boss-intro-mist {
  position: absolute;
  inset: 24% -18%;
  opacity: .34;
  background:
    radial-gradient(ellipse at 20% 52%, rgba(113, 161, 177, .24), transparent 35%),
    radial-gradient(ellipse at 76% 45%, rgba(75, 117, 145, .2), transparent 38%);
  animation: velko-mist 3.8s ease-in-out infinite alternate;
}
.boss-dialogue-frame {
  position: relative;
  width: min(650px, 92%);
  min-height: 170px;
  padding: 27px clamp(20px, 5vw, 54px) 31px;
  border: 1px solid rgba(142, 177, 190, .55);
  outline: 1px solid rgba(61, 82, 105, .7);
  outline-offset: -7px;
  background: linear-gradient(150deg, rgba(13, 22, 34, .96), rgba(5, 8, 16, .97));
  box-shadow: 0 22px 60px rgba(0, 0, 0, .72), inset 0 0 42px rgba(75, 129, 151, .09);
  text-align: center;
}
.boss-dialogue-frame::before,
.boss-dialogue-frame::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: linear-gradient(transparent, rgba(140, 181, 192, .62), transparent);
}
.boss-dialogue-frame::before { left: 13px; }
.boss-dialogue-frame::after { right: 13px; }
.boss-dialogue-frame h2 {
  margin: 0 0 18px;
  color: #e8edf0;
  font-size: clamp(36px, 7vw, 72px);
  line-height: .9;
  letter-spacing: .18em;
  text-indent: .18em;
  text-shadow: 0 3px 0 #263d50, 0 0 20px rgba(135, 191, 207, .2);
}
.boss-intro.campaign .boss-dialogue-frame h2 { font-size: clamp(24px, 4.8vw, 50px); letter-spacing: .1em; }
.boss-intro.velko { background: radial-gradient(circle at 50% 46%, rgba(18, 34, 54, .58), rgba(2, 5, 12, .92)); }
.boss-intro.velko .boss-dialogue-frame {
  border-color: rgba(132, 178, 196, .6);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .72), inset 0 0 48px rgba(75, 129, 165, .13);
}
.boss-intro.velko .boss-dialogue-frame h2 { text-shadow: 0 3px 0 #1e3a50, 0 0 26px rgba(125, 195, 215, .3); }
.boss-intro.todor { background: radial-gradient(circle at 50% 46%, rgba(52, 18, 14, .6), rgba(6, 3, 3, .92)); }
.boss-intro.todor .boss-dialogue-frame {
  border-color: rgba(198, 118, 84, .62);
  outline-color: rgba(122, 52, 40, .8);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .75), inset 0 0 48px rgba(165, 66, 42, .14);
}
.boss-intro.todor .boss-dialogue-frame h2 { text-shadow: 0 3px 0 #4c1c12, 0 0 26px rgba(226, 132, 82, .3); }
.boss-intro.todor .boss-intro-mist {
  background:
    radial-gradient(ellipse at 22% 50%, rgba(196, 92, 56, .2), transparent 36%),
    radial-gradient(ellipse at 74% 46%, rgba(150, 52, 36, .18), transparent 38%);
}
.boss-dialogue-frame p {
  min-height: 1.6em;
  margin: 0;
  color: #c8d5d8;
  font-size: clamp(15px, 2.3vw, 22px);
  line-height: 1.5;
  letter-spacing: .025em;
}

@keyframes velko-mist {
  from { transform: translate3d(-3%, 2%, 0) scale(1); }
  to { transform: translate3d(3%, -2%, 0) scale(1.06); }
}

.velko-subtitle {
  /* Docked in the HUD-safe band just below the boss health bar so it never
     covers the knight, the boss, or the touch controls. */
  position: absolute;
  left: 50%;
  top: 10.5%;
  z-index: 5;
  width: min(460px, 64%);
  max-height: 3.4em;
  overflow: hidden;
  padding: 5px 14px 7px;
  border: 1px solid rgba(116, 149, 159, .4);
  background: linear-gradient(100deg, rgba(5, 9, 16, .82), rgba(16, 25, 36, .8), rgba(5, 9, 16, .82));
  box-shadow: 0 7px 22px rgba(0, 0, 0, .4), inset 0 0 18px rgba(81, 127, 144, .06);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  pointer-events: none;
}
.velko-subtitle.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.velko-subtitle strong {
  display: block;
  margin-bottom: 2px;
  color: #b5cbd0;
  font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .24em;
  text-indent: .24em;
}
.velko-subtitle p {
  margin: 0;
  color: #edf0e8;
  font-size: clamp(11px, 1.7vw, 15px);
  line-height: 1.3;
  text-shadow: 0 2px 3px #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 7;
  background: radial-gradient(circle at 50% 42%, rgba(21, 25, 42, .6), rgba(3, 5, 10, .92));
  transition: opacity .25s ease, visibility .25s ease;
}

.overlay.visible { opacity: 1; visibility: visible; pointer-events: auto; }

.title-overlay {
  z-index: 8;
  overflow: hidden;
  background: radial-gradient(circle at 50% 38%, rgba(24, 30, 48, .72), rgba(3, 5, 10, .96));
}
.title-overlay::before,
.title-overlay::after {
  content: "";
  position: absolute;
  inset: 12% -20%;
  pointer-events: none;
  opacity: .32;
  background:
    radial-gradient(ellipse at 24% 58%, rgba(110, 156, 172, .22), transparent 34%),
    radial-gradient(ellipse at 72% 40%, rgba(72, 112, 140, .18), transparent 36%);
  animation: title-mist 9s ease-in-out infinite alternate;
}
.title-overlay::after {
  inset: 30% -24% 4%;
  opacity: .2;
  background:
    radial-gradient(ellipse at 60% 66%, rgba(150, 64, 52, .16), transparent 32%),
    radial-gradient(ellipse at 30% 44%, rgba(96, 128, 148, .14), transparent 38%);
  animation-duration: 13s;
  animation-direction: alternate-reverse;
}
@keyframes title-mist {
  from { transform: translate3d(-2.5%, 1.5%, 0) scale(1); }
  to { transform: translate3d(2.5%, -1.5%, 0) scale(1.07); }
}
.title-overlay .panel { position: relative; z-index: 1; background: linear-gradient(150deg, rgba(16, 20, 33, .9), rgba(6, 8, 14, .93)); }
.title-overlay .panel h2 {
  margin-bottom: 2px;
  font-size: clamp(38px, 8vw, 84px);
  letter-spacing: .14em;
  text-indent: .14em;
  color: #f2e9cf;
  text-shadow: 0 1px 0 #6c5a35, 0 4px 0 #472025, 0 7px 14px rgba(0, 0, 0, .8), 0 0 34px rgba(226, 200, 142, .16);
}
.title-overlay .panel h2::after {
  content: "";
  display: block;
  width: 42%;
  height: 2px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, rgba(178, 62, 52, .85), transparent);
}
@media (prefers-reduced-motion: reduce) {
  .title-overlay::before, .title-overlay::after { animation: none; }
}
.title-tagline {
  margin-top: 0;
  color: #93a4ad !important;
  font-style: italic;
  letter-spacing: .05em;
}
.title-controls {
  margin: 22px 0 0;
  color: #6f7783 !important;
  font: 10px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.panel {
  width: min(570px, 94%);
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid rgba(190, 197, 207, .35);
  outline: 1px solid rgba(179, 70, 60, .35);
  outline-offset: -7px;
  background: linear-gradient(145deg, rgba(20, 24, 38, .96), rgba(7, 9, 16, .96));
  box-shadow: 0 24px 70px #000, inset 0 0 45px rgba(99, 111, 146, .08);
  text-align: center;
}

#endOverlay.victory {
  background: radial-gradient(circle at 50% 35%, rgba(31, 48, 77, .58), rgba(3, 6, 14, .94));
}
#endOverlay.victory .panel {
  outline-color: rgba(87, 146, 162, .38);
  box-shadow: 0 24px 70px #000, inset 0 0 58px rgba(75, 125, 156, .12);
}
#endOverlay.victory .panel h2 { text-shadow: 0 4px 0 #223650, 0 0 25px rgba(142, 203, 213, .16); }

#endOverlay.defeat {
  background: radial-gradient(circle at 50% 46%, rgba(58, 14, 14, .55), rgba(6, 2, 3, .95));
}
#endOverlay.defeat .panel {
  border-color: rgba(158, 84, 74, .5);
  outline-color: rgba(178, 52, 44, .55);
  box-shadow: 0 24px 70px #000, inset 0 0 58px rgba(142, 38, 32, .13);
}
#endOverlay.defeat .panel h2 {
  color: #e8cfc2;
  text-shadow: 0 4px 0 #4a1210, 0 0 28px rgba(206, 74, 58, .25);
}

.panel h2 {
  margin: 4px 0 13px;
  color: #f1e8ce;
  font-size: clamp(34px, 7vw, 72px);
  line-height: .95;
  letter-spacing: .08em;
  text-shadow: 0 4px 0 #552127, 0 0 25px rgba(229, 213, 170, .15);
}

.panel h2 { font-size: clamp(33px, 6vw, 60px); }
#endTitle { font-size: clamp(30px, 5vw, 54px); }
#endOverlay.victory #endTitle { font-size: clamp(26px, 4.2vw, 44px); }
.panel p { color: #b8bdc5; font-size: clamp(14px, 2vw, 18px); }
.score-line { color: #898f99 !important; text-transform: uppercase; letter-spacing: .14em; }
.score-line strong { color: #f3e8ca; font-family: ui-monospace, monospace; }
.completion-list {
  display: grid;
  gap: 5px;
  margin: 15px auto 5px;
  color: #aebfc2;
  font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.completion-list[hidden], .panel button[hidden] { display: none; }
.overlay-actions { display: flex; flex-direction: column; align-items: center; }

.panel button {
  min-width: 180px;
  margin-top: 13px;
  padding: 13px 24px;
  border: 1px solid #d3a56c;
  border-radius: 2px;
  background: linear-gradient(#a9423d, #70252b);
  color: #fff4d9;
  box-shadow: 0 5px 0 #37131a, 0 9px 24px rgba(0, 0, 0, .4);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .13em;
}
.panel button:hover { filter: brightness(1.14); }
.panel button { transition: filter .14s ease, transform .08s ease, box-shadow .08s ease, border-color .14s ease; }
.panel button:active { transform: translateY(3px); box-shadow: 0 2px 0 #37131a; }
.panel button.secondary {
  border-color: #555d6b;
  background: linear-gradient(#242a36, #141822);
  box-shadow: 0 5px 0 #080a10;
  color: #b9bec6;
}

.touch-controls {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: clamp(12px, 4vw, 28px);
  margin-top: 12px;
  padding: 4px max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  touch-action: none;
  pointer-events: none;
}

.move-controls, .action-controls {
  display: flex;
  align-items: flex-end;
  gap: clamp(8px, 2.4vw, 14px);
  pointer-events: auto;
}

.touch-button {
  position: relative;
  width: clamp(72px, 19vw, 94px);
  height: clamp(68px, 17vw, 86px);
  min-width: 0;
  padding: 0 10px;
  border: 1px solid rgba(111, 126, 151, .82);
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(42, 49, 64, .97), rgba(13, 17, 27, .98));
  color: #e5e8e5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .11), inset 0 -12px 18px rgba(0, 0, 0, .2), 0 5px 0 #060810, 0 9px 18px rgba(0,0,0,.3);
  font-family: ui-monospace, monospace;
  font-size: clamp(13px, 3.5vw, 17px);
  font-weight: 800;
  letter-spacing: .05em;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  cursor: pointer;
  transition: transform .055s ease, filter .055s ease, border-color .055s ease, box-shadow .055s ease;
}
.touch-button::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(196, 207, 213, .07);
  border-radius: inherit;
  pointer-events: none;
}
.touch-button.round {
  width: clamp(68px, 18vw, 88px);
  border-radius: 50%;
  font-size: clamp(23px, 7vw, 31px);
  line-height: 1;
}
.touch-button.attack { border-color: #91443f; background: linear-gradient(155deg, #813633, #32171e); }
.touch-button.attack { width: clamp(88px, 23vw, 112px); height: clamp(76px, 19vw, 94px); border-radius: 26px; color: #fff2dd; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -14px 20px rgba(32,5,9,.26), 0 6px 0 #200b10, 0 0 24px rgba(154,52,43,.14); }
.touch-button.attack::before { content: "⚔"; margin-right: 7px; font-size: 18px; vertical-align: -2px; }
.touch-button.jump { border-color: #837b50; background: linear-gradient(155deg, #48462f, #1b1b18); }
.touch-button.jump::before { content: "↑"; display: block; margin-bottom: -2px; font-size: 21px; line-height: .8; }
.touch-button.pressed,
.touch-button[aria-pressed="true"] { transform: translateY(4px) scale(.96); border-color: #b7c5ca; box-shadow: inset 0 3px 12px #05060a, 0 1px 0 #070912; filter: brightness(1.28); }

@media (hover: none), (pointer: coarse) {
  .touch-controls { display: flex; }
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  body {
    display: block;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .hud { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; min-height: 51px; }
  .brand { display: none; }
  .hud-item { min-width: 0; min-height: 51px; }
  .hud-item span { font-size: 7px; margin-bottom: 3px; }
  .hud-item strong { font-size: clamp(9px, 2.5vw, 13px); }
  .weapon strong { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .weapon small { max-width: 72px; font-size: 5px; line-height: 1; }
  .amulet-icon { right: 3px; top: 3px; transform: scale(.82); }
  .life-icon { width: 12px; height: 15px; border-width: 1px; }
  .hud-actions { display: flex; align-items: stretch; }
  .hud-button { width: 40px; min-height: 50px; padding: 0; font-size: 0; border-bottom: 0; }
  #soundButton::after { content: "♪"; font-size: 17px; }
  #fullscreenButton::after { content: "⛶"; font-size: 18px; }
  #pauseButton::after { content: "Ⅱ"; font-size: 14px; letter-spacing: -2px; }
  .hud-button[hidden] { display: none; }
  .campaign-debug { top: 51px; max-width: 52vw; font-size: 7px; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .game-shell { display: flex; flex-direction: column; width: 100%; height: 100%; }
  .stage { flex: 0 0 auto; }
  .touch-controls { min-height: 112px; margin-top: auto; padding: 14px 2px 4px; }
  .overlay { padding: 6px; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; }
  .panel { width: min(570px, 98%); max-height: calc(100% - 4px); padding: 10px 14px; overflow: auto; overscroll-behavior: contain; }
  .panel h2, #endTitle, #endOverlay.victory #endTitle { margin: 2px 0 6px; font-size: clamp(23px, 7.5vw, 32px); }
  .title-overlay .panel h2 { margin-bottom: 2px; font-size: clamp(25px, 8vw, 34px); }
  .title-overlay .panel h2::after { margin-top: 6px; }
  .panel p { margin: 5px 0; font-size: 12px; }
  .panel button { min-width: 170px; min-height: 42px; margin-top: 6px; padding: 7px 16px; font-size: 12px; }
  .title-controls { margin-top: 7px !important; font-size: 8px !important; line-height: 1.3 !important; }
  .completion-list { gap: 2px; margin: 6px auto 2px; font-size: 8px; }
}

@media (max-width: 380px) {
  .touch-button { width: 68px; height: 66px; font-size: 12px; }
  .touch-button.round { width: 64px; }
  .touch-button.attack { width: 82px; height: 72px; }
  .touch-controls, .move-controls, .action-controls { gap: 6px; }
  .hud-button { width: 34px; }
  .hud-item strong { font-size: 9px; }
  .lives strong { gap: 3px; }
}

@media (pointer: coarse) and (orientation: landscape), (max-height: 520px) and (orientation: landscape) {
  body {
    display: grid;
    place-items: center;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: max(3px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .game-shell { width: min(100%, calc(177.778vh - 111px)); width: min(100%, calc(177.778dvh - 111px)); filter: none; }
  .hud { min-height: 38px; }
  .hud-item { min-height: 38px; }
  .hud-button { min-height: 37px; width: 36px; }
  .touch-controls { position: fixed; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(9px, env(safe-area-inset-bottom)); z-index: 9; margin: 0; padding: 0; pointer-events: none; }
  .move-controls, .action-controls { pointer-events: auto; }
  .touch-button { width: clamp(56px, 14vh, 68px); min-width: 0; height: clamp(56px, 14vh, 68px); padding: 0 6px; opacity: 1; font-size: 11px; background: linear-gradient(155deg, rgba(42, 49, 64, .9), rgba(9, 12, 20, .92)); }
  .touch-button.round { width: clamp(54px, 13vh, 64px); min-width: 0; height: clamp(56px, 14vh, 68px); font-size: clamp(21px, 6vh, 28px); }
  .touch-button.jump { width: clamp(62px, 16vh, 76px); min-width: 0; }
  .touch-button.attack { width: clamp(76px, 19vh, 94px); min-width: 0; height: clamp(62px, 16vh, 76px); }
  .touch-button.jump::before { font-size: 17px; }
  .velko-subtitle { top: 12%; width: min(420px, 56%); padding: 4px 12px 6px; }
  .velko-subtitle p { font-size: 12px; }
  .overlay { padding: 6px; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; }
  .panel { width: min(680px, 98%); max-height: calc(100% - 4px); padding: 9px 16px; overflow: auto; overscroll-behavior: contain; }
  .panel h2, #endTitle, #endOverlay.victory #endTitle { margin: 1px 0 5px; font-size: clamp(23px, 7vh, 34px); }
  .title-overlay .panel h2 { margin-bottom: 1px; font-size: clamp(25px, 8vh, 38px); }
  .title-overlay .panel h2::after { margin-top: 5px; }
  .panel p { margin: 4px 0; font-size: 11px; }
  .overlay-actions { flex-flow: row wrap; justify-content: center; gap: 7px; }
  .panel button { min-width: 132px; min-height: 40px; margin-top: 4px; padding: 6px 12px; font-size: 11px; }
  .title-controls { margin-top: 6px !important; font-size: 7px !important; line-height: 1.25 !important; }
  .completion-list { gap: 2px; margin: 5px auto 2px; font-size: 8px; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 390px) {
  .game-shell { width: min(100%, calc(177.778vh - 100px)); width: min(100%, calc(177.778dvh - 100px)); }
  .hud, .hud-item { min-height: 31px; }
  .hud-button { min-height: 30px; width: 32px; }
  .hud-item span { display: none; }
  .weapon small { display: none; }
  .touch-button { width: 54px; height: 54px; }
  .touch-button.round { width: 52px; height: 54px; }
  .touch-button.jump { width: 62px; height: 54px; }
  .touch-button.attack { width: 78px; height: 62px; }
  .panel { padding: 6px 12px; }
  .panel button { min-height: 36px; padding: 4px 10px; }
  .title-controls { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay { transition: none; }
  .boss-intro-mist { animation: none; }
  .velko-subtitle { transition: none; }
  .weapon-toast, .panel button { transition: none; }
}

/* ?embed=1 — played inside the saitora.nedelchevweb.com player: fit the frame, no credit badge, no own fullscreen button */
.is-embed .saitora-credit, .is-embed #fullscreenButton { display: none !important; }
.is-embed body { height: 100vh; height: 100dvh; min-height: 0; padding: 8px; }
@media (hover: hover) and (pointer: fine) and (min-width: 761px) {
  .is-embed .game-shell { width: min(1120px, 100%, calc((100vh - 84px) * 1.7778)); width: min(1120px, 100%, calc((100dvh - 84px) * 1.7778)); filter: none; }
}
@media (pointer: coarse) and (orientation: portrait) {
  .is-embed .hud { margin-top: auto; }
}
