:root {
  --bg: #12062e;
  --panel: #241056;
  --ink: #ffffff;
  --muted: #c9b8ff;
  --yellow: #ffe45c;
  --pink: #ff5fd2;
  --cyan: #4fd8ff;
  --green: #7cff6b;
  --font: "Fredoka", "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #2d1470, var(--bg) 70%);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#hud {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.hud-left { display: flex; flex-direction: column; min-width: 0; }
#hud-alias { font-weight: 700; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud-balls { display: flex; gap: 4px; margin-top: 2px; }
.ball-pip {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #8a93b5);
  box-shadow: 0 0 6px #fff8;
}
.ball-pip.used { opacity: 0.2; box-shadow: none; }
.hud-score { text-align: center; }
#hud-score {
  font-size: 30px; font-weight: 700; line-height: 1;
  text-shadow: 0 0 12px var(--pink), 0 2px 0 #0008;
  font-variant-numeric: tabular-nums;
}
#hud-mult { font-size: 13px; color: var(--muted); font-weight: 700; }
#hud-mult.hot { color: var(--green); text-shadow: 0 0 8px var(--green); }
.hud-right { display: flex; justify-content: flex-end; gap: 6px; }

button { font-family: inherit; cursor: pointer; }
button.icon {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid #ffffff40; background: #ffffff14; color: #fff;
  font-size: 15px; display: grid; place-items: center; padding: 0;
}
button.icon:hover { background: #ffffff2a; }
button.icon.off { opacity: 0.35; text-decoration: line-through; }
button.icon.big { width: 48px; height: 48px; font-size: 22px; flex: 0 0 auto; }

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game {
  display: block;
  border-radius: 18px;
  box-shadow: 0 0 0 3px #ffffff18, 0 0 40px #7b3cff66;
  touch-action: none;
  outline: none;
}

.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: #0b0322b0;
  backdrop-filter: blur(3px);
  overflow-y: auto;
}
.screen.hidden, .hidden { display: none !important; }

.card {
  width: min(400px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #34187a, var(--panel));
  border: 3px solid #ffffff22;
  border-radius: 24px;
  padding: 20px 20px 18px;
  text-align: center;
  box-shadow: 0 10px 40px #0009, inset 0 1px 0 #ffffff30;
  animation: pop 0.35s cubic-bezier(.2, 1.6, .4, 1);
}
.card.small { width: min(300px, 100%); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.logo { margin: 0; line-height: 0.95; font-size: 44px; }
.logo span { display: block; }
.logo span:first-child { color: var(--yellow); text-shadow: 0 0 18px #ffe45c99, 0 4px 0 #c2410c; }
.logo span:last-child { color: var(--pink); text-shadow: 0 0 18px #ff5fd299, 0 4px 0 #7a1561; }
.title { margin: 0; font-size: 38px; color: var(--yellow); text-shadow: 0 0 18px #ffe45c88, 0 4px 0 #c2410c; }
.tag { margin: 6px 0 14px; color: var(--muted); }
.label { display: block; font-weight: 700; margin-bottom: 6px; }

.alias-row { display: flex; gap: 8px; }
#alias {
  flex: 1; min-width: 0;
  font: inherit; font-size: 20px; font-weight: 700;
  padding: 10px 14px; border-radius: 14px;
  border: 3px solid var(--cyan); background: #0d0430; color: #fff;
  outline: none; text-align: center;
  -webkit-user-select: text; user-select: text;
}
#alias:focus { box-shadow: 0 0 14px var(--cyan); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 12px; min-height: 1em; }

.btn {
  font-size: 20px; font-weight: 700;
  padding: 10px 26px; border-radius: 999px;
  border: 3px solid #ffffff40; background: #ffffff18; color: #fff;
  transition: transform 0.1s;
}
.btn:active { transform: scale(0.95); }
.btn.primary {
  font-size: 26px; padding: 12px 44px;
  background: linear-gradient(180deg, #ffe45c, #ff9f2b);
  color: #4a1500; border-color: #fff8;
  box-shadow: 0 5px 0 #b45309, 0 0 24px #ffb54788;
}
.btn.primary:hover { filter: brightness(1.08); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

.howto {
  margin: 16px 0 6px; text-align: left; font-size: 13px; line-height: 1.45;
  background: #0003; border-radius: 14px; padding: 10px 12px; color: #e9e0ff;
}
.howto div + div { margin-top: 4px; }
kbd {
  display: inline-block; padding: 0 5px; border-radius: 5px;
  background: #fff2; border: 1px solid #fff4; font-family: inherit; font-size: 12px;
}

h2 { font-size: 18px; margin: 14px 0 6px; color: var(--cyan); }
.scores { list-style: none; margin: 0; padding: 0; text-align: left; font-size: 15px; }
.scores li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 10px; border-radius: 10px;
}
.scores li:nth-child(odd) { background: #ffffff0d; }
.scores li.me { background: #ffe45c33; color: var(--yellow); font-weight: 700; }
.scores li.empty { justify-content: center; color: var(--muted); }
.scores .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores .pts { font-variant-numeric: tabular-nums; }

.final {
  font-size: 56px; font-weight: 700; line-height: 1.1;
  color: #fff; text-shadow: 0 0 20px var(--pink), 0 4px 0 #0007;
}
.badge {
  display: inline-block; margin-top: 6px; padding: 4px 14px; border-radius: 999px;
  background: var(--green); color: #0b3d06; font-weight: 700;
  animation: wiggle 0.8s ease-in-out infinite alternate;
}
@keyframes wiggle { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.06); } }
