:root {
  --ink: #f4eefc;
  --muted: #c9b8e8;
  --accent: #ff7eb6;
  --gold: #ffd76a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Jua", system-ui, sans-serif;
  background: #0d0a18;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 0.557));
  height: min(100dvh, calc(100vw / 0.557));
  max-width: 420px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  background: #1a1630;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}

.panel {
  background: rgba(18, 12, 36, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--muted);
  min-width: 96px;
}

.panel.right {
  align-items: flex-end;
}

.panel b {
  color: #fff;
  font-size: 16px;
}

.lives {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.life {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.28);
}

.life.empty {
  background: rgba(255, 255, 255, 0.18);
}

.goal-meter {
  position: absolute;
  top: 72px;
  left: 12px;
  right: 12px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

.goal-meter i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ad7ff, #ff7eb6, #ffd76a);
  transition: width 0.15s ease;
}

.pad {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr 0.9fr 1fr;
  gap: 8px;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pad.show {
  opacity: 1;
  pointer-events: auto;
}

.pad-btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 8px;
  font-family: inherit;
  font-size: 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.pad-btn:active,
.pad-btn.held {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  background: rgba(255, 126, 182, 0.35);
}

.pad-btn.slash {
  background: rgba(255, 215, 106, 0.28);
  color: #ffe9a8;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 22px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 240, 200, 0.22), transparent 45%),
    linear-gradient(180deg, rgba(12, 10, 40, 0.82), rgba(28, 16, 55, 0.92));
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.hero-art {
  width: min(42vw, 168px);
  height: min(42vw, 168px);
  object-fit: cover;
  border-radius: 28px;
  margin-bottom: 6px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.5),
    0 0 0 3px rgba(255, 180, 220, 0.3);
}

.badge {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #ffb4d4;
  background: rgba(255, 126, 182, 0.18);
  border: 1px solid rgba(255, 126, 182, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
}

.badge.soft {
  color: #ffe9a8;
  background: rgba(255, 215, 106, 0.16);
  border-color: rgba(255, 215, 106, 0.35);
}

.overlay h1 {
  margin: 4px 0 0;
  font-family: "Bagel Fat One", "Jua", sans-serif;
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 400;
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 4px 0 rgba(120, 60, 160, 0.35);
}

.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.rank-form {
  width: min(280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.rank-form label {
  font-size: 13px;
  color: var(--muted);
}

.rank-form input {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.85);
  color: #2a1438;
}

.rank-msg {
  min-height: 1.2em;
  font-size: 13px !important;
  color: #b8f0c8 !important;
}

.title-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 8px;
  font-size: 13px;
  color: #e8d8ff;
  opacity: 0.9;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  font-family: inherit;
  font-size: 18px;
  color: #2a1438;
  background: linear-gradient(180deg, #ffe08a, #ffb4d4);
  box-shadow: 0 5px 0 #c86a9a;
  cursor: pointer;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #c86a9a;
}

.btn.soft {
  color: #fff;
  background: linear-gradient(180deg, #c9a8ff, #7a5cff);
  box-shadow: 0 5px 0 #4a38a0;
}

.btn.soft:active {
  box-shadow: 0 2px 0 #4a38a0;
}

.overlay a {
  color: #dcc8ff;
  text-decoration: none;
  font-size: 14px;
  margin-top: 4px;
}
