:root {
  --bg: #030504;
  --panel: rgba(5, 11, 8, .94);
  --line: rgba(87, 255, 147, .25);
  --line-strong: rgba(87, 255, 147, .42);
  --green: #57ff93;
  --muted: #78a88a;
  --danger: #ff5c5c;
  --text: #d9ffe5;
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  width: 100%;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 20%, rgba(40, 110, 65, .08), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: manipulation;
  user-select: none;
}

/* =========================================================
   GAME FRAME
   Desktop = contained game cabinet
   Mobile = almost full-width, but still leaves breathing room
   ========================================================= */

.app {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    20px
    max(20px, env(safe-area-inset-bottom));
}

.game-shell {
  position: relative;
  width: min(92vw, 1120px);
  height: min(78dvh, 720px);
  min-height: 560px;

  overflow: hidden;
  isolation: isolate;

  background: #050806;

  border: 1px solid rgba(87, 255, 147, .25);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .7),
    0 20px 70px rgba(0, 0, 0, .55),
    0 0 80px rgba(30, 130, 70, .07);
}

/* subtle frame accents */
.game-shell::before,
.game-shell::after {
  content: "";
  position: absolute;
  z-index: 8;
  pointer-events: none;
}

.game-shell::before {
  inset: 8px;
  border: 1px solid rgba(87, 255, 147, .055);
}

.game-shell::after {
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(87, 255, 147, .45),
    transparent
  );
}

/* =========================================================
   BACKGROUND
   ========================================================= */

.game-bg,
.grid,
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.game-bg {
  z-index: -4;
  background: url("/assets/background.png") center / cover no-repeat;
  filter: brightness(.34) saturate(.7);
  transform: scale(1.01);
}

.grid {
  z-index: -2;
  opacity: .18;

  background-image:
    linear-gradient(
      rgba(74, 255, 142, .06) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(74, 255, 142, .06) 1px,
      transparent 1px
    );

  background-size: 48px 48px;
}

.scanlines {
  z-index: 4;
  opacity: .045;

  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 3px,
      rgba(255,255,255,.65) 4px
    );
}

/* =========================================================
   CANVAS
   ========================================================= */

#game {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  display: block;
  outline: 0;

  touch-action: none;
}

/* =========================================================
   HUD
   ========================================================= */

.hud {
  position: absolute;
  z-index: 6;

  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;

  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;

  pointer-events: none;
}

.hud-block,
.hud-status {
  min-width: 0;

  padding: 9px 12px;

  border: 1px solid var(--line);
  background: rgba(2, 7, 4, .76);

  font-size: 10px;
  letter-spacing: .12em;

  backdrop-filter: blur(2px);
}

.hud-block span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-block b {
  display: block;
  margin-top: 4px;

  font-size: clamp(15px, 2vw, 22px);
  line-height: 1;

  letter-spacing: .03em;
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.hud-status {
  display: flex;
  align-items: center;
  gap: 7px;

  color: var(--green);
  white-space: nowrap;
}

.hud-status i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;

  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(87,255,147,.7);
}

/* =========================================================
   MISSION STRIP
   ========================================================= */

.mission {
  position: absolute;
  z-index: 5;

  top: 91px;
  left: 14px;
  right: 14px;

  display: flex;
  justify-content: space-between;
  gap: 20px;

  color: var(--muted);
  font-size: 10px;
  letter-spacing: .12em;

  pointer-events: none;
}

.mission span {
  min-width: 0;
}

.mission span:last-child {
  text-align: right;
}

/* =========================================================
   FOOTER
   ========================================================= */

footer {
  position: absolute;
  z-index: 7;

  bottom: max(10px, env(safe-area-inset-bottom));
  left: 14px;
  right: 14px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  color: var(--muted);
  font-size: 10px;
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

button:not(#audioBtn) {
  width: 100%;

  padding: 14px 16px;

  border: 1px solid var(--line-strong);
  background: rgba(4, 14, 8, .95);

  color: var(--green);
  font-weight: 800;
  letter-spacing: .08em;

  transition:
    background .15s ease,
    border-color .15s ease,
    transform .15s ease;
}

button:not(#audioBtn):hover {
  background: rgba(12, 30, 18, .98);
  border-color: rgba(87,255,147,.7);
}

button:not(#audioBtn):active {
  transform: translateY(1px);
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

#audioBtn {
  padding: 7px 9px;

  border: 1px solid var(--line);
  background: rgba(4,14,8,.94);

  color: var(--green);
  font-size: 10px;
}

/* =========================================================
   OVERLAYS
   ========================================================= */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;

  display: none;
  place-items: center;

  padding: 24px;

  background: rgba(1, 4, 2, .72);

  backdrop-filter: blur(4px);
}

.overlay.show {
  display: grid;
}

.card {
  width: min(560px, 100%);

  max-height: calc(100% - 20px);
  overflow-y: auto;

  padding: clamp(22px, 5vw, 42px);

  border: 1px solid rgba(87,255,147,.35);

  background: var(--panel);

  box-shadow:
    0 0 60px rgba(0,0,0,.45),
    0 0 100px rgba(20,100,50,.06);

  text-align: center;
}

.eyebrow {
  margin-bottom: 12px;

  color: var(--green);
  font-size: 10px;
  letter-spacing: .12em;
}

.danger {
  color: var(--danger);
}

h1,
h2 {
  margin: 0 0 14px;
  letter-spacing: .05em;
}

h1 {
  font-size: clamp(30px, 7vw, 64px);
  line-height: .95;
}

h2 {
  font-size: clamp(26px, 5vw, 45px);
  line-height: 1;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.boot {
  margin: 20px 0;
  padding: 13px;

  border: 1px solid rgba(87,255,147,.14);

  text-align: left;

  color: var(--muted);
  line-height: 1.9;
  font-size: 11px;
}

.boot b {
  float: right;
  color: var(--green);
}

.card small {
  display: block;

  margin-top: 13px;

  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;

  margin: 20px 0;
}

.results div {
  padding: 13px;

  border: 1px solid rgba(87,255,147,.14);

  color: var(--muted);
  font-size: 9px;
}

.results b {
  display: block;
  margin-top: 5px;

  color: var(--text);
  font-size: 19px;
}

.big {
  display: block;

  color: var(--green);
  font-size: clamp(44px, 10vw, 76px);
  line-height: 1;
}

.points {
  display: block;

  margin: 7px 0 15px;

  font-size: 18px;
}

#secureState {
  min-height: 18px;

  margin-top: 10px;

  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }

  .game-shell {
    width: min(94vw, 900px);
    height: min(80dvh, 680px);
    min-height: 500px;
  }

  .hud {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .hud-status {
    position: absolute;
    top: 58px;
    left: 0;
  }

  .mission {
    top: 94px;
  }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {
  body {
    overflow: hidden;
  }

  .app {
    min-height: 100dvh;

    padding:
      max(10px, env(safe-area-inset-top))
      10px
      max(10px, env(safe-area-inset-bottom));
  }

  .game-shell {
    width: calc(100vw - 20px);

    /*
      Leave the browser context visible.
      The game gets most of the screen, but isn't a 100vw takeover.
    */
    height: min(86dvh, 760px);

    min-height: 0;

    border-radius: 2px;
  }

  .game-shell::before {
    inset: 5px;
  }

  .hud {
    top: 10px;
    left: 10px;
    right: 10px;

    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .hud-block {
    padding: 7px 8px;
    font-size: 8px;
    letter-spacing: .08em;
  }

  .hud-block b {
    margin-top: 3px;
    font-size: clamp(14px, 4.2vw, 19px);
  }

  .hud-status {
    top: 53px;
    left: 0;

    padding: 6px 8px;

    font-size: 8px;
  }

  .hud-status i {
    width: 6px;
    height: 6px;
    flex-basis: 6px;
  }

  .mission {
    top: 86px;
    left: 10px;
    right: 10px;

    font-size: 8px;
    letter-spacing: .08em;
  }

  .mission span:first-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mission span:last-child {
    display: none;
  }

  footer {
    left: 10px;
    right: 10px;

    font-size: 8px;
  }

  #audioBtn {
    padding: 6px 8px;
    font-size: 8px;
  }

  .overlay {
    padding: 14px;
  }

  .card {
    padding: 22px 18px;
  }

  .boot {
    margin: 16px 0;
    font-size: 9px;
  }

  button:not(#audioBtn) {
    min-height: 48px;
  }
}

/* =========================================================
   SMALL PHONES
   ========================================================= */

@media (max-width: 390px) {
  .app {
    padding-left: 7px;
    padding-right: 7px;
  }

  .game-shell {
    width: calc(100vw - 14px);
    height: min(86dvh, 700px);
  }

  .hud {
    left: 7px;
    right: 7px;
  }

  .hud-block {
    padding: 6px 7px;
  }

  .hud-block b {
    font-size: 14px;
  }

  .hud-status {
    top: 50px;
  }

  .mission {
    left: 7px;
    right: 7px;
    top: 82px;
  }

  footer {
    left: 7px;
    right: 7px;
  }

  .card {
    padding: 18px 14px;
  }

  h1 {
    font-size: clamp(28px, 10vw, 42px);
  }

  h2 {
    font-size: clamp(24px, 8vw, 34px);
  }

  .results {
    gap: 5px;
  }

  .results div {
    padding: 10px 7px;
  }
}

/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 340px) {
  .game-shell {
    height: calc(100dvh - 14px);
  }

  .hud-block:nth-child(2) {
    text-align: center;
  }

  .hud-block:nth-child(3) {
    text-align: right;
  }

  .mission {
    display: none;
  }

  .card {
    padding: 16px 12px;
  }

  .card small {
    font-size: 8px;
  }
}

/* =========================================================
   SHORT LANDSCAPE PHONES
   ========================================================= */

@media (max-height: 600px) and (orientation: landscape) {
  .app {
    padding: 8px;
  }

  .game-shell {
    width: min(96vw, 1100px);
    height: calc(100dvh - 16px);
    min-height: 0;
  }

  .hud {
    top: 8px;
  }

  .mission {
    top: 72px;
  }

  footer {
    bottom: 7px;
  }

  .card {
    padding: 16px 22px;
  }

  .boot {
    margin: 10px 0;
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

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

/* =========================================================
   GTD COMPLETION CTA — FUTURE INTEGRATION LOCK
   ========================================================= */

#secureBtn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  border-color: rgba(87, 255, 147, 0.28);
  color: rgba(87, 255, 147, 0.55);
  background: rgba(87, 255, 147, 0.025);
  box-shadow: none;
  pointer-events: none;
}

#secureBtn:disabled:hover,
#secureBtn:disabled:focus {
  transform: none;
  box-shadow: none;
  outline: none;
}

#secureBtn:disabled::after {
  content: " // PENDING";
  opacity: 0.7;
}


/* =========================================================
   GAME BACKGROUND COMPOSITION
   Portrait source image: 1706 x 2560
   Keep the important upper Goblin-face area visible.
   ========================================================= */

.game-bg {
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
}

/* Wide desktop / landscape */
@media (min-aspect-ratio: 4/3) {
  .game-bg {
    background-position: center top;
    background-size: cover;
  }
}

/* Standard landscape tablets */
@media (min-width: 768px) and (max-aspect-ratio: 4/3) {
  .game-bg {
    background-position: center top;
    background-size: cover;
  }
}

/* Portrait devices */
@media (max-width: 767px) {
  .game-bg {
    background-position: center top;
    background-size: cover;
  }
}

