/* ════════════════════════════════════════════════════════════
   style.css — MazeCrypt: Escape the Dungeon
   Mobile-first, dark dungeon theme, no external resources
   ════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d14;
  --bg2:         #13131f;
  --bg3:         #1a1a2e;
  --panel:       #16213e;
  --panel2:      #1f2b4a;
  --border:      #2a3a6a;
  --gold:        #f0c040;
  --gold2:       #ffd700;
  --gold-dim:    #a07820;
  --cyan:        #00e5ff;
  --cyan2:       #00b8d4;
  --purple:      #7c4dff;
  --purple2:     #651fff;
  --green:       #00e676;
  --red:         #ff1744;
  --orange:      #ff6d00;
  --text:        #e8eaf6;
  --text-dim:    #9fa8da;
  --text-muted:  #5c6bc0;
  --shadow:      rgba(0,0,0,0.7);
  --glow-gold:   0 0 12px rgba(240,192,64,0.6);
  --glow-cyan:   0 0 12px rgba(0,229,255,0.5);
  --glow-purple: 0 0 12px rgba(124,77,255,0.5);
  --radius:      10px;
  --radius-lg:   16px;
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:   'Courier New', monospace;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3 { line-height: 1.2; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════
   TOP NAV
   ════════════════════════════════════════════════════════════ */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 48px;
  gap: 8px;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  white-space: nowrap;
  letter-spacing: 1px;
}
.nav-logo span { color: var(--cyan); }

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
}
.nav-link:hover, .nav-link.active {
  background: var(--panel2);
  color: var(--gold);
  text-decoration: none;
}

.lang-switcher {
  display: flex;
  gap: 3px;
}

.lang-btn {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.lang-btn:hover { color: var(--text-dim); border-color: var(--border); }
.lang-btn.active {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: rgba(240,192,64,0.1);
  text-shadow: var(--glow-gold);
}

/* ════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ════════════════════════════════════════════════════════════ */
.game-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 16px;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════════════════════════
   GAME HEADER
   ════════════════════════════════════════════════════════════ */
.game-header {
  text-align: center;
  padding: 6px 0 2px;
}

.game-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  text-transform: uppercase;
}

.game-subtitle {
  font-size: 0.75rem;
  letter-spacing: 4px;
  color: var(--cyan);
  text-transform: uppercase;
  opacity: 0.8;
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════
   HUD BAR
   ════════════════════════════════════════════════════════════ */
.hud-bar {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.hud-cell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--font-mono);
  line-height: 1;
}

.hud-cell.hud-time .hud-value { color: var(--cyan); }
.hud-cell.hud-time.warning .hud-value {
  color: var(--red);
  animation: blink 0.5s infinite;
}
.hud-cell.hud-keys .hud-value { color: var(--green); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ════════════════════════════════════════════════════════════
   CANVAS CONTAINER
   ════════════════════════════════════════════════════════════ */
.canvas-container {
  position: relative;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #080810;
  box-shadow: 0 0 30px rgba(0,0,0,0.8), inset 0 0 20px rgba(0,0,0,0.5);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Canvas corner decorations */
.canvas-container::before,
.canvas-container::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--gold);
  border-style: solid;
  z-index: 2;
  opacity: 0.5;
}
.canvas-container::before { top: 6px; left: 6px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.canvas-container::after  { bottom: 6px; right: 6px; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }

/* ════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ════════════════════════════════════════════════════════════ */
.toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: rgba(22,33,62,0.95);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 20;
  transition: transform 0.3s ease;
  pointer-events: none;
  box-shadow: var(--glow-gold);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════════════════════════════════
   TOUCH CONTROLS
   ════════════════════════════════════════════════════════════ */
.touch-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.touch-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 4px 8px var(--shadow);
}

.touch-btn:active,
.touch-btn.pressed {
  background: var(--panel2);
  border-color: var(--gold);
  transform: scale(0.92);
  box-shadow: var(--glow-gold);
}

.touch-btn.btn-up    { background: linear-gradient(180deg, var(--panel2), var(--panel)); }
.touch-btn.btn-down  { background: linear-gradient(0deg,   var(--panel2), var(--panel)); }
.touch-btn.btn-left  { background: linear-gradient(90deg,  var(--panel2), var(--panel)); }
.touch-btn.btn-right { background: linear-gradient(270deg, var(--panel2), var(--panel)); }

.touch-center {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════════════════════════
   ACTION BUTTONS ROW
   ════════════════════════════════════════════════════════════ */
.action-row {
  width: 100%;
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  border-color: var(--purple);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124,77,255,0.4);
}
.btn-primary:hover  { box-shadow: 0 4px 20px rgba(124,77,255,0.7); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-secondary:hover  { border-color: var(--cyan); color: var(--cyan); }
.btn-secondary:active { transform: scale(0.97); }

.btn-gold {
  background: linear-gradient(135deg, #b8860b, var(--gold));
  border-color: var(--gold);
  color: #000;
  box-shadow: 0 4px 15px rgba(240,192,64,0.4);
}
.btn-gold:hover  { box-shadow: 0 4px 20px rgba(240,192,64,0.7); transform: translateY(-1px); }
.btn-gold:active { transform: scale(0.97); }

/* ════════════════════════════════════════════════════════════
   OVERLAY SCREENS (start, pause, level complete, game over)
   ════════════════════════════════════════════════════════════ */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8,8,16,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}
.overlay.show { opacity: 1; pointer-events: all; }

.overlay-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 0 40px rgba(0,0,0,0.9), 0 0 20px rgba(124,77,255,0.2);
  animation: cardIn 0.35s ease;
}

@keyframes cardIn {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.overlay-icon {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px currentColor);
}

.overlay-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.overlay-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.score-table {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.score-row .label { color: var(--text-dim); }
.score-row .value { color: var(--gold); font-weight: 700; font-family: var(--font-mono); }
.score-row.total  { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; }
.score-row.total .label { color: var(--text); font-weight: 600; }
.score-row.total .value { color: var(--gold2); font-size: 1.1rem; text-shadow: var(--glow-gold); }

.overlay-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Start screen specifics */
.start-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
  text-align: left;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* ════════════════════════════════════════════════════════════
   HOW TO PLAY MODAL
   ════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 85dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: cardIn 0.3s ease;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.howto-list li {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: var(--radius);
  border-left: 3px solid var(--purple);
}

/* ════════════════════════════════════════════════════════════
   LEVEL BADGE (decorative)
   ════════════════════════════════════════════════════════════ */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
}

/* ════════════════════════════════════════════════════════════
   PROGRESS BAR (time)
   ════════════════════════════════════════════════════════════ */
.time-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.time-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 2px;
  transition: width 1s linear, background 0.5s;
}
.time-bar.warning { background: linear-gradient(90deg, var(--orange), var(--red)); }

/* ════════════════════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════════════════════ */
.game-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 8px 0 4px;
}
.game-footer a { color: var(--text-muted); }
.game-footer a:hover { color: var(--cyan); }

/* ════════════════════════════════════════════════════════════
   STATIC PAGES (about / privacy)
   ════════════════════════════════════════════════════════════ */
.page-wrapper {
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  width: 100%;
}

.page-hero {
  text-align: center;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.page-hero-icon { font-size: 3rem; margin-bottom: 10px; }

.page-hero h1 {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.page-hero p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.page-section {
  margin-bottom: 28px;
}

.page-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.page-section p {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 10px;
}

.feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-list li {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 8px 12px;
  background: var(--panel);
  border-radius: var(--radius);
  border-left: 3px solid var(--gold);
  line-height: 1.4;
}

.controls-table {
  width: 100%;
  border-collapse: collapse;
}

.controls-table td {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.controls-table td:first-child {
  color: var(--gold);
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
  width: 40%;
}

.controls-table td:last-child { color: var(--text-dim); }

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

.score-item {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.score-item strong {
  display: block;
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.privacy-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.privacy-block h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 6px;
}

.privacy-block p {
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.badge.green { border-color: var(--green); color: var(--green); }
.badge.cyan  { border-color: var(--cyan);  color: var(--cyan);  }
.badge.gold  { border-color: var(--gold);  color: var(--gold);  }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — tablets / desktop
   ════════════════════════════════════════════════════════════ */
@media (min-width: 480px) {
  .game-title    { font-size: 2.4rem; }
  .touch-btn     { width: 72px; height: 72px; font-size: 1.7rem; }
  .touch-center  { width: 72px; height: 72px; }
  .hud-value     { font-size: 1.1rem; }
}

@media (min-width: 640px) {
  .game-wrapper  { padding: 16px 16px 24px; }
  .top-nav       { padding: 0 20px; }
  .nav-link      { font-size: 0.85rem; padding: 6px 14px; }
  .lang-btn      { font-size: 0.75rem; padding: 5px 9px; }
  .score-grid    { grid-template-columns: repeat(3, 1fr); }
}

/* ════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════ */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

.shimmer-text {
  background: linear-gradient(90deg, var(--gold) 25%, #fff 50%, var(--gold) 75%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2.5s linear infinite;
}

.float-anim { animation: float 3s ease-in-out infinite; }

/* ════════════════════════════════════════════════════════════
   VICTORY SCREEN
   ════════════════════════════════════════════════════════════ */
.confetti-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}
