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

:root {
  --pri: #7c3aed;
  --pri2: #a855f7;
  --dark: #2e1065;
  --gold: #f59e0b;
  --glow: 0 0 20px rgba(168,85,247,.5);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%; overflow: hidden;
  background: #1a0533;
  font-family: 'Nunito', system-ui, sans-serif;
  color: #fff;
  touch-action: manipulation;
  user-select: none;
}
button { font-family: inherit; cursor: pointer; border: none; }
#app { height: 100dvh; width: 100%; position: relative; overflow: hidden; }

/* ── Screens ──────────────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
  overflow-y: auto; overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.screen.active { opacity: 1; pointer-events: all; }

/* ── MENU ─────────────────────────────────────────────────────────── */
#sMenu { justify-content: center; }
.menu-bg {
  position: absolute; inset: 0; z-index: 0;
  background-image: url('assets/menu_bg.png');
  background-size: cover; background-position: center;
  filter: brightness(.55) saturate(1.3);
}
.menu-overlay {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(46,16,101,.3) 0%, rgba(46,16,101,.85) 100%);
}
.menu-content { position: relative; z-index: 2; text-align: center; padding: 20px; width: 100%; max-width: 480px; }
.logo-icon { width: 110px; height: 110px; border-radius: 28px; box-shadow: 0 8px 40px rgba(168,85,247,.7), 0 0 60px rgba(168,85,247,.3); margin-bottom: 12px; }
.logo-text { font-size: clamp(2.2rem,8vw,3.2rem); font-weight: 900; background: linear-gradient(135deg,#fff,#e9d5ff,#c4b5fd); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-shadow: none; letter-spacing: 1px; }
.logo-sub { font-size: .95rem; color: #c4b5fd; margin-bottom: 36px; font-weight: 700; }
.menu-btns { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.menu-btn {
  width: 100%; padding: 18px 24px; border-radius: 20px;
  font-size: 1.2rem; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s, box-shadow .12s; letter-spacing: .3px;
}
.menu-btn.primary { background: linear-gradient(135deg,#7c3aed,#a855f7); color:#fff; box-shadow: 0 6px 24px rgba(124,58,237,.6), inset 0 1px 0 rgba(255,255,255,.2); }
.menu-btn.secondary { background: rgba(255,255,255,.1); color:#e9d5ff; border: 2px solid rgba(196,181,253,.3); backdrop-filter: blur(10px); }
.menu-btn:active { transform: scale(.96); }
.btn-icon { font-size: 1.4rem; }
.menu-footer { font-size: .85rem; color: #a78bfa; font-weight: 700; }

/* ── PAGE HEADER ──────────────────────────────────────────────────── */
.page-header {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 16px 16px 8px;
  background: linear-gradient(180deg,#2e1065,transparent);
  position: sticky; top: 0; z-index: 10;
}
.page-header h2 { font-size: 1.3rem; font-weight: 900; color: #e9d5ff; }
.back-btn {
  width: 42px; height: 42px; border-radius: 14px;
  background: rgba(255,255,255,.12); color: #e9d5ff; font-size: 1.2rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.back-btn:active { background: rgba(255,255,255,.22); }

/* ── LEVEL SELECT ─────────────────────────────────────────────────── */
#sLevel { background: radial-gradient(ellipse at top, #3b0764 0%, #1a0533 60%); padding-top: 0; }
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 10px 16px 30px; width: 100%; max-width: 500px; }
.level-card {
  background: linear-gradient(135deg,rgba(124,58,237,.4),rgba(168,85,247,.2));
  border: 2px solid rgba(196,181,253,.25);
  border-radius: 24px; padding: 22px 14px;
  text-align: center; cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform .14s, border-color .14s, box-shadow .14s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.level-card:hover, .level-card:active { transform: scale(.97); border-color: #a78bfa; box-shadow: 0 0 20px rgba(167,139,250,.4); }
.level-card .lc-stars { font-size: 1.8rem; }
.level-card .lc-name { font-size: 1.05rem; font-weight: 900; color: #e9d5ff; }
.level-card .lc-detail { font-size: .78rem; color: #a78bfa; font-weight: 700; }
.level-card .lc-best { font-size: .75rem; color: #fbbf24; font-weight: 800; margin-top: 4px; }

/* ── PONY SELECT ──────────────────────────────────────────────────── */
#sPony { background: radial-gradient(ellipse at top, #3b0764 0%, #1a0533 60%); padding-top: 0; gap: 0; }
.pony-showcase {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; padding: 10px 14px; width: 100%; max-width: 500px;
}
.pony-card {
  background: rgba(255,255,255,.06);
  border: 2.5px solid rgba(196,181,253,.15);
  border-radius: 20px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: transform .12s, border-color .15s, background .15s;
  position: relative; overflow: hidden;
}
.pony-card:active { transform: scale(.95); }
.pony-card.active { border-color: #a855f7; background: rgba(168,85,247,.2); box-shadow: 0 0 18px rgba(168,85,247,.4); }
.pony-card.locked { opacity: .45; cursor: default; filter: grayscale(.6); }
.pony-card .pc-img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 50%; border: 3px solid rgba(196,181,253,.3);
  background: rgba(255,255,255,.05);
}
.pony-card canvas.pc-img { border-radius: 50%; }
.pony-card .pc-name { font-size: .8rem; font-weight: 900; color: #e9d5ff; text-align: center; }
.pony-card .pc-lock { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.5); border-radius: 8px; font-size: .65rem; font-weight: 800; padding: 2px 5px; color: #fbbf24; }
.pony-info-bar { text-align: center; padding: 10px 16px 4px; width: 100%; }
.pony-info-name { font-size: 1.3rem; font-weight: 900; color: #e9d5ff; }
.pony-info-trait { font-size: .88rem; color: #a78bfa; font-weight: 700; margin-top: 3px; }
.action-btn {
  width: calc(100% - 32px); max-width: 420px;
  background: linear-gradient(135deg,#7c3aed,#a855f7);
  color: #fff; font-size: 1.1rem; font-weight: 900;
  padding: 17px; border-radius: 18px; margin: 12px 0;
  box-shadow: 0 6px 20px rgba(124,58,237,.5), inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .12s;
}
.action-btn:active { transform: scale(.97); }
.action-btn.secondary { background: rgba(255,255,255,.1); border: 2px solid rgba(196,181,253,.3); box-shadow: none; }
.unlock-bar { font-size: .8rem; color: #a78bfa; font-weight: 700; text-align: center; padding: 0 16px 20px; }

/* ── GAME ─────────────────────────────────────────────────────────── */
#sGame { background: #0f0523; padding: 0; justify-content: flex-start; }
.game-header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px; gap: 8px; flex-shrink: 0;
  background: rgba(15,5,35,.95); border-bottom: 1px solid rgba(124,58,237,.3);
}
.game-hud { display: flex; gap: 7px; flex: 1; justify-content: center; flex-wrap: wrap; }
.hud-pill {
  background: rgba(124,58,237,.3); border: 1.5px solid rgba(196,181,253,.25);
  border-radius: 99px; padding: 6px 12px;
  font-size: .85rem; font-weight: 800; color: #e9d5ff;
  backdrop-filter: blur(6px);
}
.keys-pill { border-color: rgba(251,191,36,.4); color: #fde68a; background: rgba(245,158,11,.15); }
.time-pill { border-color: rgba(52,211,153,.3); color: #a7f3d0; background: rgba(16,185,129,.12); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  background: rgba(255,255,255,.1); color: #e9d5ff; font-size: 1rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255,255,255,.2); }
.game-area {
  flex: 1; width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 8px; overflow: hidden;
}
#mazeCanvas { touch-action: none; max-width: 100%; max-height: 100%; display: block; border-radius: 16px; box-shadow: 0 0 40px rgba(124,58,237,.3); }
.game-msg {
  width: 100%; padding: 12px 16px; text-align: center; font-weight: 800; font-size: .95rem;
  background: rgba(124,58,237,.4); color: #e9d5ff;
  border-top: 1px solid rgba(196,181,253,.2); backdrop-filter: blur(8px);
  flex-shrink: 0;
}

/* ── WIN ──────────────────────────────────────────────────────────── */
.win-screen { background: radial-gradient(ellipse at 50% 0%,#4c1d95,#1a0533 70%); justify-content: center; }
.win-burst { position: absolute; inset: 0; pointer-events: none; }
.win-card { text-align: center; padding: 30px 24px; width: 100%; max-width: 420px; position: relative; z-index: 1; }
.win-pony-emoji { font-size: 3.5rem; margin-bottom: 6px; }
.win-trophy { font-size: 3rem; margin-bottom: 8px; }
.win-title { font-size: 2rem; font-weight: 900; background: linear-gradient(135deg,#fde68a,#f59e0b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 14px; }
.win-stars { font-size: 2.4rem; margin-bottom: 14px; letter-spacing: 4px; }
.win-detail { color: #a78bfa; font-size: .9rem; font-weight: 700; margin-bottom: 18px; line-height: 1.8; }
.new-pony-badge { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #1f2937; border-radius: 16px; padding: 13px 16px; margin-bottom: 18px; font-weight: 900; font-size: .95rem; }
.win-actions { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 600px) {
  .level-grid { grid-template-columns: repeat(2,1fr); }
  .pony-showcase { grid-template-columns: repeat(3,1fr); }
}
