/* ============================================================
   TRAP RUNNER — Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0F0F1A;
  --bg2: #1A1A2E;
  --panel: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.1);
  --text: #FFFFFF;
  --dim: rgba(255,255,255,0.5);
  --accent: #FF6B35;
  --accent2: #00E5FF;
  --success: #00E676;
  --danger: #FF1744;
  --gold: #FFD700;
  --xp: #BB86FC;
  --radius: 12px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Outfit', sans-serif;
  color: var(--text);
}

/* Canvas */
#game-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ---- SCREENS OVERLAY ---- */
.screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  align-items: center; justify-content: center;
  z-index: 10;
  background: rgba(15,15,26,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.screen-inner {
  width: 90%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
}

.screen-inner::-webkit-scrollbar { width: 4px; }
.screen-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---- TYPOGRAPHY ---- */
h1 { font-size: 2.4rem; font-weight: 900; margin-bottom: 4px; }
h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 12px; }
.subtitle { color: var(--dim); font-size: 0.9rem; margin-bottom: 20px; }

.logo-title {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 3rem; font-weight: 900;
  letter-spacing: -1px;
  text-shadow: none;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 28px;
  border: none; border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem; font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #FF8F35);
  color: #FFF;
  box-shadow: 0 4px 15px rgba(255,107,53,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 25px rgba(255,107,53,0.5); transform: translateY(-2px); }

.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-ghost {
  background: transparent;
  color: var(--dim);
}
.btn-ghost:hover { color: var(--text); }

.btn-accent2 {
  background: linear-gradient(135deg, var(--accent2), #00B8D4);
  color: #000;
  box-shadow: 0 4px 15px rgba(0,229,255,0.3);
}
.btn-accent2:hover { box-shadow: 0 6px 25px rgba(0,229,255,0.5); transform: translateY(-2px); }

.menu-btns {
  display: flex; flex-direction: column; gap: 10px;
  margin: 20px 0;
}
.menu-btns .btn { width: 100%; }

/* ---- STATS ---- */
.stats-row {
  display: flex; gap: 8px; justify-content: center;
  margin: 12px 0;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex; flex-direction: column; align-items: center;
}
.stat-label { font-size: 0.7rem; color: var(--dim); text-transform: uppercase; }
.stat-value { font-size: 1.1rem; font-weight: 700; }

/* XP Bar */
.xp-bar {
  width: 100%; height: 6px;
  background: var(--panel);
  border-radius: 3px;
  margin: 8px 0 16px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--xp), var(--accent2));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ---- LEVEL GRID ---- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.level-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}
.level-card:hover { border-color: var(--accent); transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255,107,53,0.2); }
.level-card.locked { opacity: 0.4; cursor: not-allowed; }
.level-card.locked:hover { transform: none; box-shadow: none; border-color: var(--border); }

.level-preview {
  height: 70px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.level-num {
  font-size: 2rem; font-weight: 900;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.level-info {
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.level-name { font-size: 0.8rem; font-weight: 600; }
.level-stars { color: var(--gold); font-size: 0.9rem; letter-spacing: 2px; }
.level-time { font-size: 0.75rem; color: var(--dim); }
.level-lock { font-size: 1.2rem; }

/* ---- CUSTOMIZATION ---- */
.custom-tabs, .lb-tabs {
  display: flex; gap: 6px; margin-bottom: 16px; justify-content: center;
}
.custom-tab, .lb-tab {
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.custom-tab.active, .lb-tab.active {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
}

.custom-preview {
  margin: 16px auto;
  width: 80px; height: 80px;
  background: var(--panel);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.custom-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.custom-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
}
.custom-item:hover { border-color: var(--accent2); }
.custom-item.equipped { border-color: var(--success); background: rgba(0,230,118,0.1); }
.custom-item.locked { opacity: 0.4; cursor: not-allowed; }

.item-color {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
}
.item-req { color: var(--xp); font-size: 0.65rem; }

/* ---- LEADERBOARD ---- */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.lb-table th {
  color: var(--dim);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.lb-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.lb-table .lb-me {
  background: rgba(255,107,53,0.1);
  font-weight: 700;
}
.lb-empty { color: var(--dim); padding: 30px; }

/* ---- WIN SCREEN ---- */
.win-title { font-size: 1.8rem; margin-bottom: 12px; }
.win-stars { font-size: 2.5rem; color: var(--gold); margin: 10px 0; letter-spacing: 8px; }
.win-record { color: var(--gold); font-weight: 700; font-size: 1.1rem; margin: 8px 0;
  animation: pulse 1s ease-in-out infinite; }
.win-stats { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.win-stat {
  background: var(--panel); border-radius: 8px; padding: 10px 16px;
  display: flex; flex-direction: column; gap: 2px; min-width: 80px;
}
.win-stat span:first-child { font-size: 0.7rem; color: var(--dim); }
.win-stat span:last-child { font-weight: 700; }
.win-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.multi-results { margin: 16px 0; }
.multi-result {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--panel); border-radius: 8px;
  margin-bottom: 6px;
}

/* ---- PAUSE ---- */
.pause-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

/* ---- NAME INPUT ---- */
.name-input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  width: 100%;
  max-width: 200px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--accent); }

/* ---- MULTI SETUP ---- */
.multi-info {
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  font-size: 0.85rem;
  color: var(--dim);
  line-height: 1.6;
}
.multi-info strong { color: var(--text); }

/* ---- TOUCH CONTROLS ---- */
#touch-controls {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 16px;
  z-index: 20;
  justify-content: space-between;
  pointer-events: none;
}
.touch-group {
  display: flex; gap: 10px;
  pointer-events: auto;
}
.touch-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: rgba(255,255,255,0.7);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.touch-btn:active { background: rgba(255,255,255,0.25); }
.touch-btn.large { width: 66px; height: 66px; }

/* ---- HEADER ---- */
.screen-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.back-btn {
  background: none; border: none; color: var(--dim);
  font-size: 1.4rem; cursor: pointer; padding: 4px;
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }

/* ---- RESPONSIVE ---- */
@media (max-width: 500px) {
  .screen-inner { padding: 20px 16px; border-radius: 16px; }
  h1 { font-size: 1.8rem; }
  .logo-title { font-size: 2.2rem; }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .custom-items { grid-template-columns: repeat(3, 1fr); }
  .win-stats { flex-direction: column; align-items: center; }
}
