[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
/* Layout: a single 4:3 game stage centred on a dark forest ground; touch pad below it in portrait, over it in landscape. */
:root {
  --night: #1d2a24;      /* page ground, darkened forest from the menu art */
  --bark: #5b3a22;       /* wood panels */
  --bark-dark: #3a2414;  /* panel edges, shadows */
  --sap: #f3d9a4;        /* light wood / text on bark */
  --leaf: #93dc8b;       /* grass green from the ground layer */
  --ember: #f08a2c;      /* accents: fire, record */
  --font-display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; overscroll-behavior: none; touch-action: manipulation; }
body {
  background: var(--night);
  color: var(--sap);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.app {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}
.brand {
  width: var(--stage-w); max-width: 100%;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 13px; color: color-mix(in srgb, var(--sap) 70%, transparent);
}
.brand b { font-family: var(--font-display); font-weight: 400; font-size: 17px; letter-spacing: .04em; color: var(--sap); }
.brand span { letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }
.brand-r, .brand-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { align-items: center; }
.brand .brand-l, .brand .brand-r { text-transform: none; letter-spacing: normal; font-size: inherit; }
.backlink { display: inline-flex; align-items: center; gap: 2px; padding: 5px 10px 5px 4px; border-radius: 6px; border: 2px solid var(--bark-dark); background: var(--bark); color: var(--sap); text-decoration: none; font: 800 12px var(--font-body); letter-spacing: .04em; white-space: nowrap; }
.backlink svg { width: 18px; height: 18px; fill: currentColor; }
.backlink:hover { background: #6b4628; }
.backlink:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }
.panel .backlink { font-size: max(12px, 2cqw); }
.fsbtn { font: 800 11px var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--sap); background: var(--bark); border: 2px solid var(--bark-dark); border-radius: 6px; padding: 4px 8px; cursor: pointer; }
@media (max-width: 520px) { .brand b { display: none; } }
.fsbtn:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

:root { --pad-h: 0px; --stage-w: min(100%, 1040px, calc((100dvh - 64px - var(--pad-h)) * 4 / 3)); }
.stage {
  position: relative;
  width: var(--stage-w); max-width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 3px var(--bark-dark), 0 18px 40px rgba(0,0,0,.45);
  container-type: inline-size;
  background: #000;
  touch-action: none;
}
canvas { display: block; width: 100%; height: 100%; }

/* HUD buttons */
.hudbtns { position: absolute; top: 15%; right: 2.2%; display: flex; gap: 1.2cqw; }
.iconbtn {
  width: max(34px, 5.4cqw); height: max(34px, 5.4cqw);
  border-radius: 8px; border: 2px solid var(--bark-dark);
  background: color-mix(in srgb, var(--bark) 88%, transparent); color: var(--sap);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.iconbtn svg { width: 55%; height: 55%; fill: currentColor; }
.iconbtn:focus-visible, .btn:focus-visible, .pad button:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

/* Overlay panel (menu / game over / win / pause) */
.panel {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: 66%; width: min(62%, 560px);
  background: var(--bark); border: 3px solid var(--bark-dark);
  border-radius: 1.6cqw;
  box-shadow: inset 0 0 0 2px #7a5233, 0 1cqw 0 var(--bark-dark);
  padding: 1.6cqw 2.4cqw 1.8cqw;
  display: flex; flex-direction: column; align-items: center; gap: 1.1cqw;
  text-align: center;
}
.panel.center { top: 50%; transform: translate(-50%, -50%); }
.panel.story { width: min(70%, 600px); max-height: 92%; overflow: auto; gap: 1.3cqw; padding: 2.4cqw 3cqw 2.6cqw; }
.row.nowrap { flex-wrap: nowrap; }
.btn { white-space: nowrap; }
.panel.menu { width: min(80%, 680px); }
.recline { font-size: max(11px, 1.8cqw); font-weight: 800; color: color-mix(in srgb, var(--sap) 85%, transparent); }
.recline strong { color: #fff3d6; font-variant-numeric: tabular-nums; }
.panel .msg { margin: 0; font-family: var(--font-display); font-size: max(14px, 2.9cqw); line-height: 1.2; color: #fff3d6; text-wrap: balance; }
.panel .tipline { margin: 0; font-size: max(11px, 2cqw); font-weight: 800; line-height: 1.35; color: var(--leaf); text-wrap: balance; }
.lives { display: flex; align-items: center; gap: .6cqw; font-size: max(10px, 1.7cqw); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.lives i { width: max(10px, 1.8cqw); height: max(10px, 1.8cqw); border-radius: 3px; background: #9be36b; box-shadow: inset 0 -2px 0 #4e9a37; }
.lives span { margin-left: .6cqw; opacity: .85; }
.panel.end { top: 68.5%; bottom: auto; width: min(74%, 640px); gap: .9cqw; padding-block: 1.3cqw 1.5cqw; }
.panel.end .btn { font-size: max(15px, 3cqw); }
.panel.end .btn.ghost { font-size: max(13px, 2.4cqw); }
.panel h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: max(18px, 4.4cqw); letter-spacing: .03em; line-height: 1; }
.stats { display: flex; gap: 2.6cqw; justify-content: center; flex-wrap: wrap; font-size: max(11px, 2.1cqw); font-weight: 800; }
.stats div { display: flex; flex-direction: column; line-height: 1.1; }
.stats strong { font-family: var(--font-display); font-weight: 400; font-size: max(16px, 3.4cqw); color: #fff3d6; font-variant-numeric: tabular-nums; }
.stats small { text-transform: uppercase; letter-spacing: .08em; font-size: max(9px, 1.5cqw); opacity: .8; }
.badge { background: var(--ember); color: #3a1a05; font-weight: 800; border-radius: 99px; padding: .2em .8em; font-size: max(10px, 1.7cqw); letter-spacing: .06em; text-transform: uppercase; }
.row { display: flex; gap: 1.4cqw; flex-wrap: wrap; justify-content: center; }
.btn {
  font-family: var(--font-display); font-size: max(17px, 3.6cqw); letter-spacing: .05em;
  color: #2b1608; background: linear-gradient(#ffe2a3, #f0b860);
  border: 3px solid var(--bark-dark); border-radius: 1.2cqw;
  padding: .28em 1.3em .32em; cursor: pointer;
  box-shadow: 0 .5cqw 0 var(--bark-dark);
}
.btn:active { transform: translateY(.4cqw); box-shadow: 0 .1cqw 0 var(--bark-dark); }
.btn.ghost { background: transparent; color: var(--sap); border-color: #8a603c; box-shadow: none; font-size: max(14px, 2.6cqw); }
.help { font-size: max(10px, 1.7cqw); line-height: 1.45; opacity: .9; }
.help kbd { font-family: var(--font-body); font-weight: 800; background: var(--bark-dark); border-radius: 4px; padding: 0 .35em; }
.touch .help.keys { display: none; }
.help.touchhelp { display: none; }
@media (orientation: portrait) and (max-width: 560px) { .touch .tip { display: block; } }
.touch .help.touchhelp { display: block; }

/* Touch controls: D-pad (left) + PULAR / MACHADO (right).
   Portrait: game on top, controller strip below. Landscape: controls in the side margins. */
.pad { display: none; touch-action: none; }
.touch .pad {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  width: var(--stage-w); max-width: 100%;
  margin-top: auto;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(#4a2f1b, #3a2414);
  border: 3px solid #2b1a0e; border-radius: 18px;
  box-shadow: inset 0 2px 0 #6b4628;
}
.dpad {
  --s: clamp(128px, 36vw, 172px);
  position: relative; width: var(--s); height: var(--s); flex: none;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
/* every piece is a plain absolutely-positioned box, painted in DOM order (Safari-safe) */
.dpad > span { position: absolute; display: block; }
.dp-base { inset: 0; border-radius: 50%; background: #2b1a0e; box-shadow: inset 0 0 0 5px #241509, inset 0 4px 8px rgba(0,0,0,.5); }
.dp-bar { background: #6d4629; border: 3px solid #22140a; border-radius: 9px; }
.dp-v { box-shadow: 0 3px 0 #1a0f07; }
.dp-v { left: 33%; width: 34%; top: 5%; bottom: 5%; }
.dp-h { top: 33%; height: 34%; left: 5%; right: 5%; }
.dp-mid { left: calc(33% + 3px); width: calc(34% - 6px); top: 33%; height: 34%; background: #6d4629; }
.dpad .arm { display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.dpad .arm svg { width: 62%; height: 62%; display: block; }
.dpad .up    { left: calc(33% + 3px); width: calc(34% - 6px); top: calc(5% + 3px);    height: 26%; }
.dpad .down  { left: calc(33% + 3px); width: calc(34% - 6px); bottom: calc(5% + 3px); height: 26%; }
.dpad .left  { top: calc(33% + 3px); height: calc(34% - 6px); left: calc(5% + 3px);   width: 26%; }
.dpad .right { top: calc(33% + 3px); height: calc(34% - 6px); right: calc(5% + 3px);  width: 26%; }
.dpad .arm.on { background: #b07a43; }
.dp-dimple { left: 43%; top: 43%; width: 14%; height: 14%; border-radius: 50%; background: #3a2414; box-shadow: inset 0 2px 3px rgba(0,0,0,.6); }
.actions { position: relative; flex: none; width: calc(var(--b) * 2.15); height: calc(var(--b) * 1.75); --b: clamp(70px, 19vw, 92px); }
.actbtn {
  position: absolute; width: var(--b); height: var(--b); border-radius: 50%; padding: 0;
  border: 3px solid #22140a; color: #2b1608;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-family: var(--font-display); font-size: calc(var(--b) * .155); letter-spacing: .03em; line-height: 1;
  box-shadow: 0 5px 0 #22140a, inset 0 2px 0 rgba(255,255,255,.35);
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.actbtn svg { width: 40%; height: 40%; fill: currentColor; }
.actbtn.axe  { left: 0; bottom: 0; background: radial-gradient(circle at 40% 35%, #f6c27a, #d98a3a); }
.actbtn.jump { right: 0; top: 0; background: radial-gradient(circle at 40% 35%, #c4f0b8, #79c46e); }
.actbtn.on { transform: translateY(4px); box-shadow: 0 1px 0 #22140a, inset 0 2px 6px rgba(0,0,0,.3); filter: brightness(1.12); }
.pad :focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

.touch.app { justify-content: flex-start; }
.app { touch-action: none; }
.credits { touch-action: pan-y; }
.touch { --pad-h: clamp(190px, 46vw, 250px); }

/* Landscape phones: controls live in the side margins next to the game */
@media (orientation: landscape) and (max-height: 560px) {
  .touch { --pad-h: 0px; }
  .touch .brand { display: none; }
  .touch.app { justify-content: center; padding-block: 4px; }
  .touch.app { --stage-w: min(100%, calc((100dvh - 12px) * 4 / 3), calc(100vw - 2 * max(168px, 21vw))); }
  .touch .pad {
    position: fixed; inset: auto 0 0 0; width: auto; margin: 0;
    background: none; border: 0; box-shadow: none; pointer-events: none;
    padding: 0 max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    align-items: flex-end;
  }
  .touch .pad > * { pointer-events: auto; }
  .touch .dpad { --s: clamp(120px, 34vh, 150px); }
  .touch .actions { --b: clamp(56px, 16vh, 70px); }
}
.tip { display: none; width: var(--stage-w); max-width: 100%; text-align: center; font-size: 13px; line-height: 1.45; color: color-mix(in srgb, var(--sap) 80%, transparent); }
@container (max-width: 560px) {
  .panel { width: 84%; top: 64%; padding: 2.4cqw 3cqw; }
  .panel .help { display: none !important; }
  .row.nowrap .btn { font-size: 15px; padding: .26em .8em .3em; }
  .row.nowrap .btn.ghost { font-size: 13px; }
  .recline { font-size: 10.5px; }
  .panel.menu { width: 92%; }
  .panel.story { width: 90%; padding: 10px 12px 12px; gap: 6px; }
  .panel.story .msg { font-size: 15px; }
  .panel.story .tipline { font-size: 11.5px; }
  .panel.end { width: 94%; top: 66%; gap: 4px; padding: 6px 8px 8px; }
  .panel.end .stats { gap: 12px; flex-wrap: nowrap; }
  .panel.end .stats strong { font-size: 15px; }
  .panel.end .stats small { font-size: 8px; }
  .panel.end .stats .opt { display: none; }
  .panel.end .badge { font-size: 9px; padding: .15em .6em; }
  .panel.end .btn { font-size: 14px; padding: .2em 1em .24em; }
  .panel.end .btn.ghost { font-size: 13px; }
}
.qlogo { position: absolute; left: 50%; top: 43%; height: 21%; width: auto; max-width: none; transform: translateX(-50%); filter: drop-shadow(0 .4cqw .8cqw rgba(0,0,0,.45)); pointer-events: none; }
.qlogo.corner { left: 2.2%; top: 3%; height: 17%; transform: none; }
.credlogo { display: block; width: 120px; height: auto; margin: 12px 0 0; }
.byline { position: absolute; left: 0; right: 0; bottom: .6%; margin: 0; text-align: center; font-size: max(10px, 1.6cqw); font-weight: 800; letter-spacing: .05em; color: color-mix(in srgb, var(--sap) 85%, transparent); text-shadow: 0 1px 2px rgba(0,0,0,.7); pointer-events: none; }

/* Credits: full-page reading view so the text stays readable on phones */
.credits { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--night); -webkit-user-select: text; user-select: text;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px)); }
.credits-in { max-width: 640px; margin: 0 auto; padding-block: 0 40px; line-height: 1.6; font-size: 16px; }
.credits-top { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding-block: 12px; background: var(--night); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: color-mix(in srgb, var(--sap) 75%, transparent); }
.credits-top .iconbtn { width: 40px; height: 40px; }
.credits h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 9vw, 60px); line-height: 1; margin: 16px 0 6px; color: #f0b860; letter-spacing: .02em; text-wrap: balance; }
.credits .kicker { margin: 0 0 28px; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--leaf); }
.credits h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: .02em; margin: 30px 0 8px; color: #fff3d6; padding-top: 18px; border-top: 2px dashed color-mix(in srgb, var(--bark) 80%, var(--sap)); }
.credits p { margin: 0 0 12px; color: color-mix(in srgb, var(--sap) 92%, white); }
.credits dl { display: grid; grid-template-columns: minmax(0, 13em) minmax(0, 1fr); gap: 10px 20px; margin: 8px 0 0; background: var(--bark); border: 3px solid var(--bark-dark); border-radius: 10px; padding: 16px 18px; }
.credits dt { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: color-mix(in srgb, var(--sap) 70%, transparent); padding-top: 3px; }
.credits dd { margin: 0; font-weight: 800; color: #fff3d6; }
@media (max-width: 520px) { .credits dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .credits dd { margin-bottom: 10px; } }
.signoff { margin-top: 36px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.signoff strong { font-family: var(--font-display); font-weight: 400; font-size: 28px; color: #f0b860; letter-spacing: .03em; }
.signoff span { color: color-mix(in srgb, var(--sap) 85%, transparent); }
.signoff em { font-style: normal; font-weight: 800; color: var(--leaf); }
.credits-foot { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 28px; }
.credits-foot .btn { font-size: 20px; border-radius: 10px; box-shadow: 0 4px 0 var(--bark-dark); }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
