:root {
  --ink: #f3e9ff;
  --muted: rgba(243, 233, 255, 0.65);
  --panel: rgba(24, 10, 52, 0.82);
  --edge: rgba(200, 170, 255, 0.28);
  --gold: #ffcf5a;
  --gold2: #ff9f43;
  --violet: #8b5cf6;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07051a; color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; cursor: crosshair; }

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 15, 80, 0.35), rgba(5, 2, 15, 0.7)); z-index: 2; overflow-y: auto; }
.screen.on { display: flex; animation: fade 0.25s ease-out; }
#title { background: radial-gradient(ellipse at 50% 35%, rgba(40, 15, 80, 0.15), rgba(5, 2, 15, 0.45)); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--edge); border-radius: 24px;
  padding: 24px 22px; text-align: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; gap: 10px; animation: rise 0.35s cubic-bezier(.2, 1.4, .4, 1); margin: auto; }
@keyframes rise { from { transform: translateY(18px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

h1 { margin: 4px 0 0; font-size: 48px; letter-spacing: 1px; line-height: 1;
  background: linear-gradient(180deg, #fff7d1, #ffb84d 60%, #ff7a59); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(60, 10, 90, 0.9)) drop-shadow(0 0 18px rgba(255, 180, 80, 0.35)); }
h2 { margin: 0 0 4px; font-size: 26px; color: #fff3d1; }
.tag { margin: 0 0 8px; color: var(--muted); }
.fine { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.logo { position: relative; height: 70px; }
.orb { position: absolute; top: 10px; width: 46px; height: 46px; border-radius: 50%;
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, 0.35), inset 6px 6px 12px rgba(255, 255, 255, 0.45), 0 0 24px currentColor;
  animation: bob 3s ease-in-out infinite; }
.orb::after { content: ""; position: absolute; left: 9px; top: 7px; width: 14px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); transform: rotate(-30deg); }
.o1 { left: calc(50% - 72px); background: radial-gradient(circle at 30% 30%, #ffc2cd, #ff3d5e 45%, #7d0a26); color: rgba(255, 61, 94, 0.5); }
.o2 { left: calc(50% - 23px); top: 0; background: radial-gradient(circle at 30% 30%, #fff3c2, #ffc233 45%, #8f5200); color: rgba(255, 194, 51, 0.5); animation-delay: -1s; }
.o3 { left: calc(50% + 26px); background: radial-gradient(circle at 30% 30%, #e9dbff, #a46cff 45%, #3f1a8f); color: rgba(164, 108, 255, 0.5); animation-delay: -2s; }
@keyframes bob { 50% { transform: translateY(-7px); } }

.btn { appearance: none; border: 1px solid var(--edge); border-radius: 16px; padding: 14px 18px; font: inherit; font-size: 18px; font-weight: 700;
  color: var(--ink); background: rgba(255, 255, 255, 0.07); cursor: pointer; transition: transform 0.08s, background 0.2s; min-height: 48px; }
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #2a1240; border-color: rgba(255, 230, 160, 0.8);
  box-shadow: 0 6px 0 #a3501f, 0 10px 24px rgba(255, 150, 60, 0.35); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #a3501f; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 15px; padding: 10px 14px; min-height: 42px; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .lvl:focus-visible { outline: 2px solid #ffe9a8; outline-offset: 2px; }

.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.row .btn { flex: 1; }
.chip { appearance: none; border: 1px solid var(--edge); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px;
  color: var(--ink); background: rgba(255, 255, 255, 0.06); cursor: pointer; min-height: 38px; }
.chip.off { opacity: 0.45; text-decoration: line-through; }
.chip.static { cursor: default; color: #ffe9a8; }

.map-panel { width: min(380px, 100%); }
.map-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.map-head h2 { font-size: 20px; margin: 0; }
#map-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 72px)); justify-content: center; gap: 10px 14px; margin: 8px 0; }
@media (max-height: 640px) { #map-grid { grid-template-columns: repeat(6, minmax(0, 56px)); } .map-panel { width: min(480px, 100%); } .lvl .num { font-size: 16px; } }
.lvl { appearance: none; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); cursor: pointer; font: inherit;
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(circle at 32% 28%, #e9dbff, #8b5cf6 42%, #2b0f66);
  box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.35); transition: transform 0.1s; }
.lvl:hover { transform: scale(1.06); }
.lvl .num { font-size: 20px; font-weight: 800; text-shadow: 0 2px 0 rgba(40, 10, 70, 0.8); }
.lvl .st { font-size: 11px; color: #ffe08a; letter-spacing: 1px; }
.lvl.current { background: radial-gradient(circle at 32% 28%, #fff3c2, #ffb233 42%, #8f4a00); animation: glow 1.6s ease-in-out infinite; }
.lvl.breather:not(.locked):not(.current) { background: radial-gradient(circle at 32% 28%, #ccffe0, #35dd78 42%, #0a5e2d); }
.lvl.locked { background: radial-gradient(circle at 32% 28%, #8a83a0, #3d3650 50%, #1a1526); opacity: 0.6; cursor: default; }
.lvl.locked .num { font-size: 16px; }
@keyframes glow { 50% { box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 190, 80, 0.8); } }

.stars { display: flex; justify-content: center; gap: 6px; font-size: 52px; line-height: 1; }
.stars span { color: rgba(255, 255, 255, 0.15); transform: scale(0.6); animation: pop 0.45s cubic-bezier(.2, 1.8, .4, 1) forwards; }
.stars span.lit { color: #ffd76b; text-shadow: 0 0 18px rgba(255, 200, 80, 0.8), 0 3px 0 #a3501f; }
@keyframes pop { to { transform: scale(1); } }
.score { font-size: 38px; font-weight: 800; color: #fff3d1; }
.reward { margin: 0; min-height: 1.2em; color: #b6ffcf; }
.help-panel ul { text-align: left; padding-left: 20px; margin: 0 0 6px; line-height: 1.45; font-size: 15px; color: #e9dcff; }
.help-panel li { margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { .orb, .lvl.current, .panel, .stars span { animation: none !important; } .stars span { transform: none; } }
