*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#05070a;color:#e9eef5;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}body{display:grid;place-items:center;padding:18px}.shell{width:min(100vw - 24px,1280px)}.topbar{display:flex;align-items:center;justify-content:flex-end;gap:16px;margin-bottom:8px;min-height:38px}h1{margin:0 0 2px;font-size:clamp(20px,3vw,34px);line-height:1.05;letter-spacing:.02em}p{margin:0;color:#aeb9c7;font-size:14px}button{flex:0 0 auto;appearance:none;border:1px solid #31465e;border-radius:10px;background:linear-gradient(#1d3146,#101923);color:#f5f7fb;padding:9px 14px;font-weight:800;cursor:pointer;box-shadow:0 6px 24px rgba(0,0,0,.35)}button:hover{border-color:#5f8dbd}canvas{display:block;width:100%;height:auto;aspect-ratio:16/9;background:#101820;border:2px solid #1f2b38;box-shadow:0 18px 80px rgba(0,0,0,.65);image-rendering:pixelated;image-rendering:crisp-edges}.help{margin-top:10px;color:#aeb9c7;font-size:14px;text-align:center;user-select:none;line-height:1.45}.help code{background:#111924;padding:2px 6px;border-radius:6px;color:#d8ecff}


/* PHASE 1: responsive fullscreen layout, no page scroll */
* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050609;
}

body {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f4f4f4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}

.shell {
  width: 100vw;
  height: 100svh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: 0 minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
  background: #050609;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  height: auto;
  pointer-events: auto;
}

#muteButton {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.26);
  border-radius: 999px;
  padding: 8px 13px;
  background: rgba(10,12,18,0.66);
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.game-wrap {
  position: relative;
  width: min(100vw, calc(100svh * 16 / 9));
  height: min(100svh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  display: block;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 20px 70px rgba(0,0,0,0.55);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #000;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

@supports not (height: 100svh) {
  body,
  .shell {
    min-height: 100vh;
    height: 100vh;
  }
  .game-wrap {
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
  }
}


.fullscreen-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 30;
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.32);
  background: rgba(0,0,0,0.48);
  color: rgba(255,255,255,0.94);
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  opacity: 0.78;
  transition: opacity .15s ease, background .15s ease, transform .15s ease;
  backdrop-filter: blur(4px);
}

.fullscreen-button:hover,
.fullscreen-button:focus-visible {
  opacity: 1;
  background: rgba(0,0,0,0.72);
  transform: scale(1.04);
}

.game-wrap:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  display: grid;
  place-items: center;
  background: #000;
}

.game-wrap:fullscreen #game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}

.game-wrap:fullscreen .fullscreen-button {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}


/* FIX: browser view top-aligned, horizontally centered */
html, body {
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

body {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
}

.shell {
  width: 100vw !important;
  height: 100svh !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  place-items: unset !important;
  overflow: hidden !important;
}

.game-wrap {
  flex: 0 0 auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: max(6px, env(safe-area-inset-top)) !important;
  transform: none !important;
}

.game-wrap:fullscreen {
  margin-top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  display: grid !important;
  place-items: center !important;
}

@supports not (height: 100svh) {
  .shell { height: 100vh !important; }
}



/* SCANLINE BRIGHTNESS COMPENSATION
   Scanlines remain dark, but the game canvas underneath is lifted so the final
   image does not lose as much luminance after the CSS multiply scanline layer. */
#game {
  filter: brightness(var(--bark-brightness, 1.25)) contrast(var(--bark-contrast, 1.07)) saturate(var(--bark-saturate, 1.10));
}

/* TRUE DISPLAY SCANLINES: fixed 2 CSS-pixel pattern, independent of internal canvas scaling */
.game-wrap {
  position: relative !important;
  isolation: isolate;
}

body.no-scanlines .game-wrap::after { display: none; }

.game-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.48) 0px,
    rgba(0, 0, 0, 0.48) 1px,
    rgba(0, 0, 0, 0.00) 1px,
    rgba(0, 0, 0, 0.00) 2px
  );
  background-size: 100% 2px;
  mix-blend-mode: multiply;
}

.fullscreen-button {
  z-index: 30;
}

.game-wrap:fullscreen::after {
  inset: auto;
  left: 50%;
  top: 50%;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  transform: translate(-50%, -50%);
}

.startup-fallback{display:none;}


/* BLOCK9 MOBILE WHITE SCREEN FIX: robust viewport fallback */
html, body { background:#050609; }
.game-wrap { background:#000; }
#game { background:#000; }
@supports (height: 100dvh) {
  body, .shell { min-height:100dvh; height:100dvh; }
  .game-wrap { width:min(100vw, calc(100dvh * 16 / 9)); height:min(100dvh, calc(100vw * 9 / 16)); }
}



/* BLOCK58: studio intro + title loading sequence */
.boot-splash{
  position:absolute;
  inset:0;
  z-index:60;
  pointer-events:none;
  overflow:hidden;
  background:#000;
  opacity:1;
  transition:opacity 1.05s ease;
}
.boot-splash.hidden{ opacity:0; }
.boot-splash.removed{ display:none; }
.boot-scene{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#000;
  opacity:0;
}
.boot-logo{
  display:block;
  max-width:100%;
  height:auto;
  filter:drop-shadow(0 18px 36px rgba(0,0,0,.70));
}
.boot-logo--iron{
  width:min(73vw, 860px);
  max-height:58%;
  object-fit:contain;
}
.boot-logo--bark{
  width:min(88vw, 1080px);
  max-height:52%;
  object-fit:contain;
  transform:translateY(-26px);
}
.boot-scene--iron{
  animation:barkIntroIron 4.55s ease-in-out forwards;
}
.boot-scene--bark{
  flex-direction:column;
  animation:barkIntroBark 7.50s ease-in-out forwards;
  animation-delay:4.85s;
}
.boot-load{
  width:min(54vw, 620px);
  margin-top:34px;
  text-align:center;
  opacity:0;
  animation:barkIntroLoadAppear 7.50s ease-in-out forwards;
  animation-delay:4.85s;
}
.boot-load__track{
  position:relative;
  height:22px;
  border-radius:999px;
  overflow:hidden;
  background:linear-gradient(180deg, rgba(15,18,22,.96), rgba(2,4,8,.98));
  border:1px solid rgba(255,196,83,.62);
  box-shadow:0 0 0 1px rgba(0,0,0,.85), inset 0 2px 8px rgba(255,255,255,.10), 0 10px 34px rgba(0,0,0,.75);
}
.boot-load__fill{
  position:absolute;
  inset:3px auto 3px 3px;
  width:0%;
  border-radius:999px;
  background:linear-gradient(90deg,#583015 0%,#c46b22 28%,#f2b84d 58%,#ffdf83 82%,#fff0b6 100%);
  box-shadow:0 0 16px rgba(255,176,55,.38), inset 0 1px 5px rgba(255,255,255,.42);
  animation:barkIntroLoadFill 4.95s cubic-bezier(.18,.82,.24,1) forwards;
  animation-delay:5.82s;
}
.boot-load__shine{
  position:absolute;
  top:3px;
  bottom:3px;
  width:70px;
  left:-90px;
  border-radius:999px;
  background:linear-gradient(90deg, transparent, rgba(255,255,255,.60), transparent);
  mix-blend-mode:screen;
  animation:barkIntroLoadShine 1.45s ease-in-out infinite;
  animation-delay:6.20s;
}
.boot-load__label{
  margin-top:14px;
  color:#f2b84d;
  font:900 18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing:.14em;
  text-shadow:0 3px 10px #000, 0 0 14px rgba(255,176,55,.28);
}
@keyframes barkIntroIron{
  0%{opacity:0;}
  15%{opacity:1;}
  74%{opacity:1;}
  100%{opacity:0;}
}
@keyframes barkIntroBark{
  0%{opacity:0;}
  13%{opacity:1;}
  79%{opacity:1;}
  100%{opacity:0;}
}
@keyframes barkIntroLoadAppear{
  0%,10%{opacity:0; transform:translateY(8px);}
  18%,82%{opacity:1; transform:translateY(0);}
  100%{opacity:0; transform:translateY(0);}
}
@keyframes barkIntroLoadFill{
  0%{width:5%;}
  28%{width:34%;}
  53%{width:66%;}
  78%{width:91%;}
  100%{width:calc(100% - 6px);}
}
@keyframes barkIntroLoadShine{
  0%{left:-90px; opacity:.0;}
  20%{opacity:.75;}
  100%{left:calc(100% + 30px); opacity:0;}
}


/* BLOCK 137: invisible game/canvas frame */
canvas,
#game {
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}

#game:focus,
#game:focus-visible,
canvas:focus,
canvas:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.game-wrap {
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
