:root {
  --bg: #eef2f6;
  --bg-deep: #d8dee6;
  --ink: #0d141c;
  --ink-soft: #2a3440;
  --accent: #2e8bff;
  --warn: #ff5a5f;
  --safe: #2dd4bf;
  --paper: #f7faff;
  --line: #93a3b6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  height: 100%; width: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 50% 0%, #f4f7fb 0%, #c8d2de 60%, #98a6b8 100%);
  overflow: hidden;
}

#game {
  position: absolute;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #c8d2de;
  display: block;
  touch-action: none;
}

.sprites {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.sprites img {
  position: absolute;
  left: 0; top: 0;
  transform-origin: top left;
  pointer-events: none;
  will-change: transform;
  image-rendering: pixelated;
}
.sprites img.flip {
  transform-origin: top left;
}

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.hud .tag {
  margin-left: 10px;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  font-weight: 700;
}
.hud .inv {
  display: inline-flex;
  gap: 6px;
}
.hud .inv .pip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-weight: 600;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 253, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 30;
}
.overlay-card {
  max-width: 460px;
  width: calc(100% - 40px);
  padding: 28px 30px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: left;
  box-shadow: 0 30px 60px -30px rgba(13,20,28,0.4);
}
.overlay-eyebrow {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.overlay-card h1 {
  margin: 0 0 14px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.overlay-card p { margin: 0 0 12px; line-height: 1.55; }
.overlay-card p.muted { color: var(--ink-soft); font-size: 13px; }
.btn-primary, .btn-secondary {
  appearance: none;
  border: 0;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  margin-top: 8px;
  margin-right: 8px;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--ink); }
.link {
  display: inline-block;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
}
.link:hover { color: var(--accent); }

.dialog {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  max-width: 80%;
  z-index: 20;
  pointer-events: none;
}
.dialog-inner {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 20px 14px;
  border-radius: 4px;
  min-width: 280px;
  max-width: 480px;
  box-shadow: 0 20px 40px -20px rgba(13,20,28,0.35);
}
.dialog .speaker {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
  font-weight: 700;
}
.dialog .text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
.dialog .dialog-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
}

.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
}
.touch button {
  position: absolute;
  appearance: none;
  border: 1px solid rgba(13,20,28,0.45);
  background: rgba(247,250,255,0.55);
  color: rgba(13,20,28,0.85);
  border-radius: 50%;
  font: 700 12px/1 ui-sans-serif, sans-serif;
  letter-spacing: 0.1em;
  pointer-events: auto;
  touch-action: none;
}
.touch button:active { background: rgba(46,139,255,0.55); color: #fff; }

.dpad {
  position: absolute;
  left: 16px; bottom: 18px;
  width: 180px; height: 180px;
}
.dpad button { width: 60px; height: 60px; }
.t-up    { left: 60px; top: 0; }
.t-left  { left: 0;    top: 60px; }
.t-right { left: 120px;top: 60px; }
.t-down  { left: 60px; top: 120px; }

.actions {
  position: absolute;
  right: 16px; bottom: 18px;
  width: 200px; height: 180px;
}
.actions button { width: 70px; height: 70px; font-size: 11px; }
.t-jump  { right: 0;    bottom: 90px; background: rgba(46,139,255,0.55); color: #fff;}
.t-act   { right: 80px; bottom: 50px; }
.t-sneak { right: 0;    bottom: 0; }
.t-run   { right: 80px; bottom: 110px; }

@media (pointer: coarse) {
  .touch { display: block; }
}
@media (max-width: 720px) {
  .overlay-card h1 { font-size: 22px; }
}
