:root {
  --ink: #eafaff;
  --muted: #a9d6e8;
  --glass: rgba(6, 30, 58, 0.72);
  --edge: rgba(170, 235, 255, 0.28);
  --gold: #ffd866;
  --coral: #ff6f91;
  --sea: #3fd6c0;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #062a4e; color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hidden { display: none !important; }

#hud-btns {
  position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 6px; z-index: 5;
}
button.icon {
  width: 40px; height: 40px; border-radius: 12px; padding: 8px;
  background: rgba(6, 30, 58, 0.55); border: 1px solid var(--edge); color: var(--ink);
  cursor: pointer; backdrop-filter: blur(6px);
}
button.icon svg { width: 100%; height: 100%; fill: currentColor; display: block; }
button.icon .off { display: none; }
button.icon.muted .on { display: none; }
button.icon.muted .off { display: block; }

.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(4, 30, 60, 0.25), rgba(2, 12, 28, 0.6));
  overflow-y: auto;
  animation: fade .25s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(10, 48, 86, 0.82), rgba(4, 22, 46, 0.88));
  border: 1px solid var(--edge);
  border-radius: 24px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 60px rgba(0, 10, 30, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  text-align: center;
  animation: rise .35s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes rise { from { transform: translateY(18px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.small-card { width: min(380px, 100%); }

.logo { margin: 4px 0 6px; line-height: .9; font-weight: 900; letter-spacing: -0.02em; }
.logo span { display: block; }
.logo .l1 {
  font-size: clamp(44px, 11vw, 72px);
  background: linear-gradient(180deg, #ffffff, #9ff0ff 55%, #3fb6e0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 40, 80, .6));
}
.logo .l2 {
  font-size: clamp(50px, 13vw, 84px);
  background: linear-gradient(180deg, #fff1c4, #ffb36b 50%, #ff5f8a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(80, 10, 40, .55));
}
.tag { color: var(--muted); margin: 6px 0 12px; font-size: 15px; }
.hello { color: var(--gold); margin: 0 0 10px; font-weight: 700; }
h2 { margin: 2px 0 10px; font-size: 28px; font-weight: 900; }
.btns { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin-top: 12px; }
.btns .row { display: flex; gap: 8px; }
.btns .row button { flex: 1; }
button {
  font: inherit; font-weight: 800; font-size: 16px; color: var(--ink);
  touch-action: manipulation;
  padding: 12px 14px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, rgba(60, 150, 200, 0.45), rgba(20, 80, 130, 0.55));
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 3px 0 rgba(0, 20, 40, .5);
  transition: transform .08s, filter .15s;
}
button:hover { filter: brightness(1.15); }
button:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 0 rgba(0, 20, 40, .5); }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.primary {
  font-size: 20px; padding: 14px;
  background: linear-gradient(180deg, #ffd56b, #ff8a5c 60%, #ff5f8a);
  color: #3a0a1e; border-color: rgba(255, 230, 200, .6);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 4px 0 #9b2d4f, 0 10px 24px rgba(255, 100, 120, .3);
}
button.ghost { background: rgba(255, 255, 255, 0.06); }
.how {
  text-align: left; margin: 16px 0 6px; padding: 12px 14px 12px 30px;
  background: rgba(0, 20, 40, .35); border-radius: 14px; border: 1px solid rgba(170, 235, 255, .12);
  color: var(--muted); font-size: 13.5px; line-height: 1.55;
}
.how b { color: var(--ink); }
kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; margin: 0 1px;
  border-radius: 5px; border: 1px solid rgba(170, 235, 255, .35); background: rgba(255, 255, 255, .08);
  font: 700 11.5px/18px system-ui, sans-serif; color: var(--ink); text-align: center;
}
.meta { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.score { font-size: 44px; font-weight: 900; margin: 6px 0 0; color: #fff4c2; text-shadow: 0 3px 0 rgba(0, 30, 60, .6); }

.stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0; min-height: 10px; }
.stars svg { width: 54px; height: 54px; fill: rgba(255, 255, 255, .12); stroke: rgba(255, 255, 255, .25); stroke-width: 1; }
.stars svg.on { fill: var(--gold); stroke: #fff3c0; filter: drop-shadow(0 0 10px rgba(255, 210, 100, .7)); animation: starpop .45s cubic-bezier(.2, 1.8, .4, 1) both; }
.stars svg:nth-child(2) { transform: translateY(-8px); width: 62px; height: 62px; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1); } }
.stars svg:nth-child(2).on { animation-name: starpop2; }
@keyframes starpop2 { from { transform: translateY(-8px) scale(0) rotate(-40deg); } to { transform: translateY(-8px) scale(1); } }

.levels-card { width: min(560px, 100%); }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.level-grid button { padding: 8px 4px 6px; font-size: 18px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.level-grid button small { font-size: 11px; letter-spacing: 1px; color: var(--gold); min-height: 14px; }
.level-grid button.locked { opacity: .38; cursor: not-allowed; }
.level-grid button.current { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 216, 102, .5), 0 3px 0 rgba(0, 20, 40, .5); }

@media (max-height: 640px) {
  .how { font-size: 12px; line-height: 1.4; margin-top: 10px; }
  .card { padding: 14px 16px 12px; }
  .logo .l1 { font-size: 44px; } .logo .l2 { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, .card, .stars svg.on { animation: none !important; }
}
