/* RAK 3022 web shell. Colors follow the game's own menu (dark moss, lime, bone). */
@font-face {
  font-family: "Press Start 2P";
  src: url("font/press-start-2p.woff2") format("woff2");
  font-display: swap;
}
:root {
  --ink: #050805;
  --moss: #16240f;
  --lime: #a8b820;
  --lime-hi: #c9dc3a;
  --bone: #d9e3b4;
  --dim: #6f7f58;
  --rare: #a0fd05;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #000; color: var(--bone);
  overflow: hidden; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body {
  position: fixed; inset: 0;
  font-family: "Press Start 2P", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
[hidden] { display: none !important; }

/* The stage is sized in JS from the visual viewport so mobile browser bars never crop the game. */
#stage {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  background: #000; overflow: hidden; touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
#frame { position: relative; flex: none; width: 100%; height: 100%; background: #000; }
#unity-canvas {
  display: block; width: 100%; height: 100%; background: #000; outline: none;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
body.is-booting #frame, body.is-portrait.is-mobile #frame { visibility: hidden; }

/* ---------- boot / loading ---------- */
#boot {
  position: absolute; inset: 0; z-index: 20;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 20px) calc(var(--sab) + 14px) calc(var(--sal) + 20px);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(60, 96, 28, .38), rgba(0, 0, 0, 0) 62%),
    linear-gradient(180deg, #070b06 0%, var(--moss) 100%);
  transition: opacity .35s ease;
}
#boot.out { opacity: 0; pointer-events: none; }
.boot-main {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 3.2vh, 26px);
}
#boot-logo {
  width: auto; height: auto; max-width: min(78vw, 560px); max-height: 44vh;
  image-rendering: pixelated; filter: drop-shadow(0 6px 22px rgba(0, 0, 0, .6));
}
#bar {
  --p: 0;
  width: min(72vw, 420px); height: clamp(12px, 3.4vh, 18px); border: 2px solid var(--dim); padding: 2px;
  background: linear-gradient(90deg, var(--lime) 0 calc(var(--p) * 1%), #0b120a 0) content-box, #0b120a;
}
/* segment gaps drawn on top of the fill */
#bar::after {
  content: ""; display: block; width: 100%; height: 100%;
  background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 2px), #0b120a calc(5% - 2px) 5%);
}
#bar.busy { animation: pulse 1s steps(2, end) infinite; }
#status { font-size: clamp(8px, 2.3vh, 11px); letter-spacing: .14em; color: var(--bone); text-align: center; min-height: 1.4em; line-height: 1.5; }
#play {
  appearance: none; border: 2px solid var(--lime-hi); background: var(--lime); color: #0b120a;
  font: inherit; font-size: clamp(12px, 3.6vh, 18px); letter-spacing: .1em;
  padding: clamp(12px, 3.4vh, 18px) clamp(22px, 6vw, 44px); min-height: 48px; cursor: pointer;
  box-shadow: 0 4px 0 #56600f, 0 10px 30px rgba(168, 184, 32, .28);
  animation: breathe 1.4s ease-in-out infinite;
}
#play:active { transform: translateY(3px); box-shadow: 0 1px 0 #56600f; }
#play:focus-visible, #fatal-btn:focus-visible, #fs-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#tip { font-size: clamp(7px, 1.9vh, 9px); letter-spacing: .08em; line-height: 1.7; color: var(--dim); text-align: center; max-width: 520px; }
.boot-foot { flex: none; display: flex; align-items: center; gap: 14px; opacity: .92; }
.boot-foot img { height: clamp(18px, 5vh, 28px); width: auto; }
.boot-foot span { font-size: clamp(6px, 1.7vh, 8px); letter-spacing: .16em; color: var(--dim); }
@keyframes breathe { 50% { filter: brightness(1.14); transform: scale(1.025); } }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- rotate prompt (phones held upright) ---------- */
#rotate {
  position: absolute; inset: 0; z-index: 30; background: #050805;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  font-size: 13px; letter-spacing: .1em; text-align: center; padding: 24px;
}
#rotate small { font-size: 8px; color: var(--dim); letter-spacing: .1em; }
#rotate .phone {
  width: 54px; height: 96px; border: 4px solid var(--lime); border-radius: 10px; margin-bottom: 14px;
  animation: turn 2.2s ease-in-out infinite;
}
@keyframes turn { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ---------- full screen button ---------- */
#fs-btn {
  position: absolute; z-index: 10; top: calc(var(--sat) + 6px); left: 62%;
  width: 34px; height: 34px; padding: 8px; border: 1px solid rgba(217, 227, 180, .45); border-radius: 4px;
  background: rgba(5, 8, 5, .5); cursor: pointer; opacity: .55; transition: opacity .2s;
}
#fs-btn svg { width: 100%; height: 100%; fill: var(--bone); display: block; }
#fs-btn:hover { opacity: 1; }
body.is-desktop #fs-btn { top: auto; left: auto; right: calc(var(--sar) + 10px); bottom: calc(var(--sab) + 10px); opacity: .28; }
body.is-desktop #fs-btn:hover { opacity: 1; }

/* ---------- fatal error ---------- */
#fatal {
  position: absolute; inset: 0; z-index: 40; background: rgba(5, 8, 5, .96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center;
}
#fatal-title { font-size: 13px; letter-spacing: .1em; color: #ff7a6b; }
#fatal-msg { font: 13px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--bone); max-width: 560px; -webkit-user-select: text; user-select: text; }
#fatal-btn { appearance: none; font: inherit; font-size: 12px; letter-spacing: .1em; padding: 14px 26px; min-height: 48px; border: 2px solid var(--lime-hi); background: var(--lime); color: #0b120a; cursor: pointer; }

#debug {
  position: absolute; z-index: 50; left: calc(var(--sal) + 4px); bottom: calc(var(--sab) + 4px); margin: 0; padding: 4px 6px;
  font: 10px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #b6ff5c; background: rgba(0, 0, 0, .6); pointer-events: none; white-space: pre;
}

@media (prefers-reduced-motion: reduce) {
  #play, #bar.busy, #rotate .phone { animation: none; }
  #boot { transition: none; }
}
