@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d1a;
  --accent: #a78bfa;
  --accent2: #f472b6;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

body {
  font-family: 'Poppins', sans-serif;
  background: radial-gradient(ellipse at 50% 0%, #1a0a2e 0%, var(--bg) 70%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.star {
  position: absolute; border-radius: 50%; background: white;
  animation: twinkle var(--d) ease-in-out infinite alternate; opacity: 0;
}
@keyframes twinkle {
  from { opacity: 0; } to { opacity: 0.85; }
}

.screen {
  position: relative; z-index: 1; width: 100%;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.screen.hidden { display: none; }

.card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(24px);
  border-radius: 2rem;
  padding: 2rem 1.8rem 1.6rem;
  max-width: 460px; width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.07);
  animation: slideUp 0.45s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hat-icon {
  font-size: 3.2rem; display: block; margin-bottom: 0.3rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); }
}

h1 {
  font-size: 1.75rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 0.25rem;
}
.subtitle { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.2rem; }

.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 0.5rem; margin-bottom: 0.8rem;
}
.name-btn {
  background: rgba(167,139,250,0.08);
  border: 1px solid rgba(167,139,250,0.28);
  color: var(--text); border-radius: 0.75rem;
  padding: 0.6rem 0.4rem;
  font-family: 'Poppins', sans-serif; font-size: 0.83rem;
  cursor: pointer; transition: all 0.17s ease;
}
.name-btn:hover {
  background: rgba(167,139,250,0.22); border-color: var(--accent);
  transform: translateY(-2px); box-shadow: 0 5px 18px rgba(167,139,250,0.3);
}

/* Draw card canvas */
.draw-card { padding-bottom: 1.4rem; }

#hat-canvas {
  display: block;
  width: 100%;
  height: 340px;
  border-radius: 1.2rem;
  margin-bottom: 1rem;
  cursor: default;
}

.draw-actions { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }

.btn-shake {
  background: rgba(167,139,250,0.12);
  border: 1px solid rgba(167,139,250,0.35);
  color: var(--text); font-family: 'Poppins', sans-serif;
  font-size: 0.95rem; font-weight: 600;
  padding: 0.6rem 2rem; border-radius: 0.85rem;
  cursor: pointer; transition: all 0.18s ease;
}
.btn-shake:hover {
  background: rgba(167,139,250,0.25); transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(167,139,250,0.3);
}
.btn-shake:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.hint-text { color: var(--muted); font-size: 0.8rem; }
.error-msg { color: #f87171; font-size: 0.82rem; min-height: 1em; }

/* Result */
.result-card h1 { font-size: 1.3rem; margin-bottom: 0.7rem; }
.result-name {
  font-size: 2.6rem; font-weight: 700;
  background: linear-gradient(135deg, #f472b6, #a78bfa, #60a5fa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin: 0.3rem 0 0.9rem;
  animation: pulse 1.8s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { transform: scale(1); } to { transform: scale(1.05); }
}
.result-sub { color: var(--muted); font-size: 0.88rem; }
