:root {
  --bg: #1a0b1f;
  --bg2: #2a1233;
  --panel: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --text: #fbeefd;
  --muted: #b99ac2;
  --pink: #ff4fa3;
  --hot: #ff2e7e;
  --gold: #ffd34d;
  --mint: #5cf2b4;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% -10%, #4a1650 0%, transparent 60%),
    radial-gradient(80% 50% at 100% 110%, #3b0f3a 0%, transparent 60%),
    var(--bg);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  font-size: 26px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), #9b3dff);
  box-shadow: 0 6px 20px rgba(255, 79, 163, 0.35);
}
h1 { font-size: 20px; letter-spacing: -0.02em; font-weight: 800; }
.tag { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; transition: opacity .3s; }

.scores { display: flex; gap: 8px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 58px;
}
.label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.val.bump { animation: bump .3s ease; }
@keyframes bump { 50% { transform: scale(1.3); color: var(--pink); } }

.meter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px 12px;
}
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.level { font-weight: 800; font-size: 14px; color: var(--gold); transition: transform .3s; }
.level.pop { animation: pop .5s ease; }
@keyframes pop { 40% { transform: scale(1.25) rotate(-3deg); } }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  box-shadow: 0 0 12px rgba(255, 211, 77, .6);
  transition: width .35s cubic-bezier(.2,.9,.3,1.2);
}

.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 9px;
  font-size: 12px;
}
.health { font-size: 14px; letter-spacing: 2px; }
.shield {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: color .2s, background .2s, border-color .2s;
}
.shield.on {
  color: var(--mint);
  font-weight: 700;
  background: rgba(92, 242, 180, .1);
  border-color: rgba(92, 242, 180, .35);
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,79,163,.08);
}
.board-wrap.shake { animation: shake .4s ease; }
@keyframes shake {
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-3px, 3px); }
  80% { transform: translate(2px, -1px); }
}
canvas { width: 100%; height: 100%; display: block; }

.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(26, 11, 31, .85);
  border: 1px solid rgba(255, 79, 163, .5);
  color: var(--text);
  animation: floatUp 1.6s ease forwards;
  max-width: 90%;
}
.floater.gold { border-color: var(--gold); color: var(--gold); }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(.95); }
}

.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(20, 6, 24, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
  padding: 20px;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.card { text-align: center; max-width: 290px; transform: translateY(8px); transition: transform .3s ease; }
.overlay.show .card { transform: none; }
.big-emoji { font-size: 54px; margin-bottom: 8px; animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.05); } }
.card h2 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.btn {
  margin: 18px 0 10px;
  font: inherit; font-weight: 800; font-size: 16px;
  color: #fff;
  border: 0;
  border-radius: 99px;
  padding: 13px 28px;
  background: linear-gradient(135deg, var(--pink), #9b3dff);
  box-shadow: 0 10px 26px rgba(255, 79, 163, .4);
  cursor: pointer;
  transition: transform .12s ease;
}
.btn:active { transform: scale(.95); }
.hint { font-size: 12px !important; opacity: .7; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
  justify-content: center;
  margin-top: auto;
}
.key {
  font-size: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .08s ease, background .15s;
}
.key:active, .key.hit { transform: scale(.92); background: rgba(255, 79, 163, .25); }
.up { grid-area: 1 / 2; }
.left { grid-area: 2 / 1; }
.mid { grid-area: 2 / 2; font-size: 13px; color: var(--muted); }
.right { grid-area: 2 / 3; }
.down { grid-area: 3 / 2; }

@media (min-width: 700px) {
  .app { padding-top: 40px; }
}
@media (max-height: 720px) {
  .pad { grid-template-rows: repeat(3, 44px); }
}
