/* Layer Dig — brand tokens from the Layer product (slate primary, indigo accent). */
:root {
  --ink: #0f172a;
  --slate-600: #475569; --slate-500: #64748b; --slate-400: #94a3b8;
  --slate-300: #cbd5e1; --slate-200: #e2e8f0; --slate-100: #f1f5f9; --slate-50: #f8fafc;
  --paper: #ffffff;
  --indigo: #6366f1; --indigo-600: #4f46e5; --indigo-400: #818cf8; --indigo-50: #eef2ff;
  --red: #eb5546;
  --earth: #0e0906;
  --font: "Inter Tight", "Helvetica Neue", system-ui, sans-serif;
  --mono: "Space Grotesk", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--earth);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100dvh;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  height: 48px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 0 clamp(10px, 1.6vw, 18px);
  background: var(--paper);
  border-bottom: 1px solid var(--slate-200);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; border-radius: 6px; }
.brand:focus-visible { outline: 3px solid var(--indigo-400); outline-offset: 3px; }
.brand-mark { height: 23px; width: auto; display: block; }
.brand-tag {
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.22em; font-size: 11px;
  color: var(--indigo-600); padding: 3px 7px; border-radius: 6px; background: var(--indigo-50);
}
.hud { display: flex; align-items: center; gap: 0; }
.hud-chip {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 0 clamp(12px, 1.6vw, 20px); text-align: center; min-width: 46px;
}
.hud-chip + .hud-chip { border-left: 1px solid var(--slate-200); }
.hud-label { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--slate-500); font-weight: 700; }
.hud-value { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.1; }
.hud-chip--score .hud-value { color: var(--indigo-600); }
.hud-chip--lives .hud-value { color: var(--red); letter-spacing: 2px; }

/* ---------- Stage (fills the rest of the viewport; canvas is sized by JS) ---------- */
.stage {
  flex: 1 1 auto; min-height: 0;
  width: 100%; min-width: 0;
  position: relative;
  display: grid; place-items: center;
  background: var(--earth);
  overflow: hidden;
}
#game { display: block; max-width: 100%; max-height: 100%; touch-action: none; outline: none; }
#game:focus-visible { box-shadow: inset 0 0 0 3px var(--indigo-400); }

/* ---------- Overlay cards ---------- */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(1000px 560px at 50% 40%, rgba(13,16,24,0.5), rgba(9,11,17,0.8));
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
  z-index: 5;
  overflow: auto;
  padding: clamp(10px, 2.5vh, 24px);
}
.overlay[data-mode="play"] { opacity: 0; pointer-events: none; }
.overlay:not([data-mode="play"]) ~ .touch { opacity: 0; pointer-events: none; }
.overlay:not([data-mode="play"]) ~ .touch .tbtn,
.overlay:not([data-mode="play"]) ~ .touch .dpad { pointer-events: none; }
.title-plane {
  width: 66px; height: 50px; margin: 0 auto 6px;
  background: no-repeat center / contain url("assets/objects/layer-plane.png");
  animation: planeBob 3.2s ease-in-out infinite;
}
@keyframes planeBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7px) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) { .title-plane { animation: none; } }
.card {
  width: min(100%, 480px); max-height: 100%; overflow: auto; text-align: center;
  padding: clamp(22px, 3.4vw, 34px);
  background: var(--paper);
  border: 1px solid var(--slate-200); border-radius: 16px;
  box-shadow: 0 30px 70px -28px #000a;
}
.card .card-logo { height: 30px; width: auto; margin: 0 auto 16px; display: block; }
.card h1 { margin: 0 0 6px; font-size: clamp(28px, 5vw, 40px); font-weight: 800; letter-spacing: -0.02em; line-height: 0.98; color: var(--ink); }
.card h1 .accent { color: var(--indigo-600); }
.card .sub { color: var(--slate-500); font-size: 15px; margin: 0 0 18px; line-height: 1.5; }
.card .sub b { color: var(--ink); }
.card .stat-row { display: flex; justify-content: center; gap: 26px; margin: 16px 0 22px; }
.card .stat { display: flex; flex-direction: column; gap: 2px; }
.card .stat b { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--ink); }
.card .stat span { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--slate-500); }

.btn {
  appearance: none; cursor: pointer;
  font-family: var(--font); font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(180deg, var(--indigo), var(--indigo-600));
  border: none; border-radius: 10px; padding: 13px 26px;
  box-shadow: 0 10px 22px -10px #4f46e5b3;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .tbtn:focus-visible { outline: 3px solid var(--indigo-400); outline-offset: 3px; }

.howto { display: grid; gap: 9px; text-align: left; margin: 4px auto 22px; max-width: 340px; color: var(--slate-600); font-size: 13.5px; }
.howto .row { display: flex; align-items: center; gap: 10px; }
.howto .k {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--indigo-600);
  background: var(--indigo-50); border: 1px solid #c7d2fe; border-radius: 6px; padding: 3px 7px; min-width: 64px; text-align: center;
}
.card .cta-note { font-size: 11.5px; color: var(--slate-400); margin-top: 14px; }
.card .cta-note a { color: var(--slate-600); text-underline-offset: 2px; }
.card .cta-note a:hover { color: var(--indigo-600); }

/* ---------- Email entry ---------- */
.entry-gate { margin: 0 auto; max-width: 380px; text-align: left; }
.entry-gate .field-label {
  display: block; margin-bottom: 6px; color: var(--ink); font-size: 12px;
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.entry-gate input[type="email"] {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--slate-300); border-radius: 9px;
  color: var(--ink); background: var(--paper); font: 500 16px var(--font);
}
.entry-gate input[type="email"]::placeholder { color: var(--slate-400); }
.entry-gate input[type="email"]:focus { outline: 3px solid #818cf855; border-color: var(--indigo); }
.entry-options { display: grid; gap: 8px; margin: 12px 0; }
.cf-turnstile { margin: 12px 0; min-height: 65px; }
.entry-option { display: grid; grid-template-columns: 18px 1fr; gap: 9px; align-items: start; color: var(--slate-600); font-size: 12.5px; line-height: 1.35; cursor: pointer; }
.entry-option input { width: 17px; height: 17px; margin: 0; accent-color: var(--indigo-600); }
.entry-option input:focus-visible { outline: 3px solid var(--indigo-400); outline-offset: 2px; }
.entry-gate .btn { width: 100%; }
.entry-privacy { margin: 10px 0 0; color: var(--slate-500); font-size: 10.5px; line-height: 1.4; text-align: center; }
.entry-privacy a { color: var(--slate-600); text-underline-offset: 2px; }
.entry-status { min-height: 17px; margin: 6px 0 0; color: var(--slate-600); font-size: 11px; text-align: center; }
.entry-status[data-error="true"] { color: #b22010; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Touch controls ---------- */
.touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch {
    display: flex; position: absolute; inset: auto 0 0 0; z-index: 6;
    justify-content: space-between; align-items: flex-end;
    padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    pointer-events: none;
  }
  .touch .tbtn, .touch .dpad { pointer-events: auto; }
  .dpad { display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 4px; }
  .dpad .tbtn[data-dir="up"] { grid-area: 1 / 2; }
  .dpad .tbtn[data-dir="left"] { grid-area: 2 / 1; }
  .dpad .tbtn[data-dir="down"] { grid-area: 3 / 2; }
  .dpad .tbtn[data-dir="right"] { grid-area: 2 / 3; }
  .tbtn {
    font-size: 18px; color: #fff; background: #1a1109cc;
    border: 1px solid #ffffff2a; border-radius: 12px; backdrop-filter: blur(4px); user-select: none;
    touch-action: none; -webkit-tap-highlight-color: transparent;
  }
  .tbtn--fire {
    width: 82px; height: 82px; border-radius: 50%;
    font-family: var(--mono); font-weight: 700; letter-spacing: 0.06em; font-size: 12px; color: #fff;
    background: linear-gradient(180deg, var(--indigo), var(--indigo-600)); border: none; align-self: center;
  }
}

@media (max-width: 560px) {
  .hud-chip { padding: 0 10px; }
  .hud-label { display: none; }
  .brand-tag { display: none; }
}

@media (max-height: 520px) {
  .topbar { height: 40px; }
  .brand-mark { height: 20px; }
  .card { padding: 14px 18px; }
  .card h1 { font-size: 36px !important; margin-bottom: 4px !important; }
  .card .sub { margin-bottom: 8px; line-height: 1.35; }
  .howto { gap: 5px; margin-bottom: 10px; }
  .howto .k { padding-block: 2px; }
  .btn { padding: 10px 22px; }
  .card .cta-note { margin-top: 7px; }
  .entry-card .howto { display: none; }
  .entry-card .sub { font-size: 13px; }
  .entry-options { gap: 4px; margin: 7px 0; }
  .entry-option { font-size: 11px; line-height: 1.2; }
  .entry-gate input[type="email"] { min-height: 36px; padding-block: 7px; }
  .entry-privacy { margin-top: 5px; font-size: 9.5px; }
  .entry-status { min-height: 12px; margin-top: 2px; font-size: 9.5px; }
}
