/* ==========================================================================
   PABĖGIMO LABIRINTAS — 16-BIT INTERAKTYVUS ŽAIDIMAS (TELEFONUI IR PC)
   Paruošta subdomenui: zaidimas.pabegimolabirintas.lt (arba /zaidimas/)
   ========================================================================== */

:root {
  --bg: #0f1a2e;
  --panel: rgba(14, 24, 44, 0.94);
  --panel-solid: #111e36;
  --cobalt: #2b5791;
  --gold: #f5b81d;
  --gold-bright: #ffe07d;
  --green: #3a962e;
  --green-bright: #4ade80;
  --red: #ef4444;
  --cyan: #38bdf8;
  --ink: #f4f7fc;
  --muted: #b4c6e2;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  user-select: none;
  -webkit-user-select: none;
}

/* ================= 3D 16-BIT PIXEL CANVAS ================= */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  z-index: 1;
  touch-action: none;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Lengvas 16-bit CRT kraštų efektas */
.crt-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 75% at 50% 50%, rgba(0, 0, 0, 0) 45%, rgba(8, 14, 28, 0.55) 100%);
}

/* Centrinis taikiklis (subtilus 16-bit taškelis) */
.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 2px solid rgba(255, 224, 125, 0.72);
  background: rgba(15, 26, 46, 0.45);
  pointer-events: none;
  display: none;
}

.crosshair.is-active {
  display: block;
}

.crosshair.is-target {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-color: var(--green-bright);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.9);
}

/* ================= PRADŽIOS IR PERGALĖS EKRANAI ================= */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(12, 22, 40, 0.78) 0%, rgba(10, 18, 34, 0.92) 100%),
    url('./assets/corridor-16bit-full.jpg') center / cover no-repeat;
  overflow-y: auto;
}

.overlay-screen.is-hidden {
  display: none;
}

.arcade-card {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2.5px solid var(--gold);
  border-radius: 22px;
  padding: 26px 22px 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65), 0 0 40px rgba(245, 184, 29, 0.16);
  text-align: center;
}

.arcade-logo {
  height: 36px;
  margin: 0 auto 12px;
  display: block;
}

.arcade-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(245, 184, 29, 0.18);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  margin-bottom: 10px;
}

.arcade-card h1,
.arcade-card h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.arcade-lead {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}

.mission-list {
  display: grid;
  gap: 9px;
  text-align: left;
  margin-bottom: 20px;
}

.mission-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13.8px;
  line-height: 1.4;
}

.mission-ico {
  font-size: 20px;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(245, 184, 29, 0.16);
}

.btn-arcade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 22px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-arcade--play {
  background: var(--green);
  color: #ffffff;
  border-color: #62e352;
  box-shadow: 0 12px 28px rgba(58, 150, 46, 0.48);
}

.btn-arcade--play:hover,
.btn-arcade--play:active {
  background: #2f7e24;
  transform: translateY(-2px);
}

.btn-arcade--gold {
  background: var(--gold);
  color: #0e182c;
  box-shadow: 0 10px 24px rgba(245, 184, 29, 0.36);
}

.btn-arcade--ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  margin-top: 10px;
  font-size: 14px;
  padding: 11px 16px;
}

.controls-note {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #93abc9;
  line-height: 1.5;
}

.back-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-bright);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* ================= GYVAS ŽAIDIMO HUD ================= */
.game-hud {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: none;
}

.game-hud.is-active {
  display: block;
}

.hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  background: rgba(14, 24, 44, 0.86);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.hud-icon-btn.is-on {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* Mėlynas skaitmeninis laikmatis kaip tikroje 155.png nuotraukoje (32:01)! */
.led-timer {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: #0a1428;
  border: 2px solid #2b6be6;
  box-shadow: inset 0 0 12px rgba(43, 107, 230, 0.55), 0 4px 14px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #60a5fa;
  text-shadow: 0 0 10px rgba(96, 165, 250, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.code-slots {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(14, 24, 44, 0.88);
  border: 1.5px solid rgba(245, 184, 29, 0.55);
  padding: 4px 8px;
  border-radius: 10px;
  backdrop-filter: blur(8px);
}

.code-slot {
  width: 28px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: #93abc9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-slot.is-found {
  background: rgba(58, 150, 46, 0.32);
  border-color: var(--green-bright);
  color: #ffffff;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.85);
}

/* Mini-žemėlapis (16-bit radaras) */
.minimap-wrap {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 48px);
  right: 10px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(12, 22, 40, 0.86);
  border: 2px solid rgba(245, 184, 29, 0.6);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#minimap-canvas {
  width: 96px;
  height: 96px;
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.minimap-legend {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #b4c6e2;
  white-space: nowrap;
}

.minimap-wrap.is-hidden {
  display: none;
}

/* Užduoties / Gyventojo pranešimas ekrano viršuje */
.status-banner {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 48px);
  left: 10px;
  max-width: calc(100vw - 134px);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 24, 44, 0.88);
  border-left: 4px solid var(--gold);
  font-size: 12.5px;
  font-weight: 600;
  color: #f4f7fc;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  line-height: 1.35;
}

.interact-prompt {
  position: absolute;
  left: 50%;
  bottom: 190px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(245, 184, 29, 0.96);
  color: #0e182c;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  border: 2px solid #ffffff;
  display: none;
  animation: pulsePrompt 1.2s ease-in-out infinite;
}

.interact-prompt.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@keyframes pulsePrompt {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

/* ================= APATINIAI VALDYMO MYGTUKAI (TELEFONUI IR PC) ================= */
.touch-controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 5px;
  pointer-events: auto;
  touch-action: none;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(16, 28, 49, 0.80);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
}

.dpad-btn:active,
.dpad-btn.is-pressed {
  background: var(--gold);
  color: #0e182c;
  border-color: #ffffff;
  transform: scale(0.94);
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

.action-pad {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}

.action-main-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  background: rgba(16, 28, 49, 0.82);
  color: #9bb1cf;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.action-main-btn span:first-child {
  font-size: 24px;
  line-height: 1;
}

.action-main-btn.is-ready {
  background: var(--gold);
  border-color: #ffffff;
  color: #0e182c;
  box-shadow: 0 0 26px rgba(245, 184, 29, 0.85);
  transform: scale(1.06);
}

.swipe-tip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(14, 24, 44, 0.7);
  padding: 4px 8px;
  border-radius: 6px;
}

/* ================= 16-BIT UŽDUOČIŲ IR GYVENTOJO MODALAS ================= */
.puzzle-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 14, 28, 0.80);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.puzzle-backdrop.is-open {
  display: flex;
}

.puzzle-box {
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
  position: relative;
  text-align: center;
}

.puzzle-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
}

.puzzle-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  margin-bottom: 8px;
}

.puzzle-box h3 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #ffffff;
}

.puzzle-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* Užduotis 1: 4 arkadiniai mygtukai */
.simon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.simon-btn {
  height: 76px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: #0e182c;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.12s ease, box-shadow 0.12s ease;
  opacity: 0.72;
}

.simon-btn[data-col="0"] { background: #4ade80; }
.simon-btn[data-col="1"] { background: #facc15; }
.simon-btn[data-col="2"] { background: #38bdf8; }
.simon-btn[data-col="3"] { background: #f8fafc; }

.simon-btn.is-lit,
.simon-btn:active {
  opacity: 1;
  transform: scale(0.96);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.9);
  border-color: #ffffff;
}

/* Užduotis 2: 3 žibintų grandinė */
.lamps-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.lamp-bulb {
  padding: 16px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.18);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #7c93b5;
}

.lamp-bulb span {
  display: block;
  font-size: 30px;
  margin-bottom: 4px;
  filter: grayscale(1) opacity(0.4);
  transition: all 0.2s ease;
}

.lamp-bulb.is-on {
  background: rgba(245, 184, 29, 0.2);
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 22px rgba(245, 184, 29, 0.45);
}

.lamp-bulb.is-on span {
  filter: none;
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.switch-btn {
  padding: 12px 8px;
  border-radius: 10px;
  border: 2px solid var(--cyan);
  background: rgba(56, 189, 248, 0.14);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.switch-btn:active {
  transform: scale(0.95);
  background: var(--cyan);
  color: #0e182c;
}

/* Užduotis 3: 16-bit porų paieška */
.mem-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.mem-card {
  height: 78px;
  border-radius: 12px;
  border: 2px solid rgba(245, 184, 29, 0.45);
  background: #1b2f52;
  color: var(--gold-bright);
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mem-card.is-open {
  background: #254070;
  border-color: #ffffff;
}

.mem-card.is-matched {
  background: rgba(58, 150, 46, 0.32);
  border-color: var(--green-bright);
}

/* 16-bit Gyventojo portretas ir kodo klaviatūra */
.dweller-portrait-wrap {
  width: 112px;
  height: 144px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 62%, rgba(255, 184, 51, 0.36) 0%, #101d34 75%);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dweller-portrait-wrap canvas {
  width: 96px;
  height: 128px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.keypad-display {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.32em;
  padding: 10px 14px;
  border-radius: 10px;
  background: #081020;
  border: 2px solid #2b6be6;
  color: #60a5fa;
  margin-bottom: 12px;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.key-btn {
  padding: 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.key-btn:active {
  background: var(--gold);
  color: #0e182c;
}

.key-btn--ok {
  background: var(--green);
  border-color: var(--green-bright);
}

.puzzle-feedback {
  min-height: 22px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 8px 0 4px;
}

/* Pergalės kortelė */
.win-time-big {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 700;
  color: #60a5fa;
  background: #081020;
  border: 2.5px solid #2b6be6;
  border-radius: 14px;
  padding: 10px 20px;
  display: inline-block;
  margin: 8px 0 14px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 14px rgba(96, 165, 250, 0.85);
}

.win-stars {
  font-size: 30px;
  margin-bottom: 6px;
}

@media (max-width: 480px) {
  .hud-top {
    left: 8px;
    right: 8px;
    gap: 4px;
  }
  .hud-left,
  .hud-right {
    gap: 4px;
  }
  .hud-icon-btn {
    height: 36px;
    min-width: 34px;
    padding: 0 7px;
    font-size: 13.5px;
  }
  .led-timer {
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
  }
  .code-slots {
    gap: 3px;
    padding: 3px 5px;
  }
  .code-slot {
    width: 24px;
    height: 26px;
    font-size: 13px;
  }
  .status-banner {
    top: calc(max(10px, env(safe-area-inset-top)) + 44px);
    left: 8px;
    max-width: calc(100vw - 126px);
    font-size: 11.5px;
    padding: 6px 9px;
  }
  .minimap-wrap {
    top: calc(max(10px, env(safe-area-inset-top)) + 44px);
    right: 8px;
    padding: 5px;
    width: 102px;
  }
  #minimap-canvas {
    width: 88px;
    height: 88px;
  }
  .minimap-legend {
    font-size: 8.5px;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }
}

@media (min-width: 820px) {
  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
    opacity: 0.88;
  }
  .dpad-btn {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }
  #minimap-canvas {
    width: 118px;
    height: 118px;
  }
}
