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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --primary: #e94560;
  --primary-glow: rgba(233, 69, 96, 0.3);
  --secondary: #533483;
  --accent: #0f3460;
  --text: #eee;
  --text-dim: #888;
  --success: #00d672;
  --warning: #ffbe0b;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* Title */
.title {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--primary), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 60px var(--primary-glow);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  margin-top: -0.3rem;
  margin-bottom: 0.5rem;
}

.landing-how {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 auto 1.5rem;
  max-width: 300px;
}

.how-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--text-dim);
  text-align: left;
}

.how-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(233, 69, 96, 0.15);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid rgba(233, 69, 96, 0.3);
}

/* Buttons */
.btn {
  border: none;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

.btn-primary {
  background: var(--primary);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--primary-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--secondary);
}

.btn-secondary:hover {
  background: #6b44a0;
}

.btn-large {
  padding: 18px 48px;
  font-size: 1.2rem;
  border-radius: 16px;
}

/* Actions */
.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.divider {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.join-group {
  display: flex;
  gap: 10px;
}

#input-code {
  background: var(--surface);
  border: 2px solid var(--accent);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1.3rem;
  width: 100px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
}

#input-code:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.error {
  color: var(--primary);
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Share buttons */
.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-share {
  padding: 10px 20px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn-sms {
  background: #34a853;
}

.btn-sms:hover {
  background: #2d9249;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
}

.btn-whatsapp:hover {
  background: #1fb855;
}

.btn-copy {
  background: var(--accent);
}

.btn-copy:hover {
  background: #1a4a80;
}

/* Setup / Dare */
.dare-input-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dare-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--warning);
}

.dare-input {
  background: var(--surface);
  border: 2px solid var(--accent);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 1rem;
  width: 100%;
  max-width: 360px;
}

.dare-input:focus {
  outline: none;
  border-color: var(--warning);
  box-shadow: 0 0 20px rgba(255, 190, 11, 0.2);
}

.setup-divider {
  width: 60px;
  height: 2px;
  background: var(--accent);
  margin: 8px 0;
}

/* Code Display */
.code-display {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--warning);
  background: var(--surface);
  padding: 16px 40px;
  border-radius: 16px;
  border: 2px solid rgba(255, 190, 11, 0.3);
  text-shadow: 0 0 30px rgba(255, 190, 11, 0.3);
}

.hint {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* Loader */
.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Lobby */
.lobby-header {
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dare-display,
.dare-display-inline {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--warning);
  background: rgba(255, 190, 11, 0.1);
  border: 1px solid rgba(255, 190, 11, 0.3);
  padding: 10px 20px;
  border-radius: 12px;
  max-width: 100%;
  text-align: center;
}

.dare-display-inline {
  font-size: 0.95rem;
  padding: 8px 16px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover {
  color: var(--text);
}

.role-badge {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.role-badge.challenger {
  background: rgba(233, 69, 96, 0.2);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.role-badge.defender {
  background: rgba(83, 52, 131, 0.3);
  color: #a77bca;
  border: 1px solid var(--secondary);
}

.role-badge.observer {
  background: rgba(100, 130, 200, 0.2);
  color: #8aa4d0;
  border: 1px solid #5a7ab5;
}

.round-info {
  font-size: 1.4rem;
  font-weight: 700;
}

/* Countdown config */
.countdown-config {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.countdown-config label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.countdown-options {
  display: flex;
  gap: 8px;
}

.cd-opt {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cd-opt.selected {
  border-color: var(--primary);
  background: rgba(233, 69, 96, 0.15);
  color: var(--primary);
}

.cd-opt:hover {
  border-color: var(--primary);
}

.expired-msg {
  color: var(--warning);
  font-size: 0.95rem;
  font-weight: 600;
  background: rgba(255, 190, 11, 0.1);
  border: 1px solid rgba(255, 190, 11, 0.3);
  padding: 10px 18px;
  border-radius: 10px;
  text-align: center;
}

/* Game Screen */
.countdown-display {
  font-size: 6rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 40px var(--primary-glow);
  animation: pulse 1s ease-in-out infinite;
  min-height: 100px;
  display: flex;
  align-items: center;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.pick-prompt {
  font-size: 1.1rem;
  color: var(--text-dim);
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.num-btn {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.num-btn:hover {
  border-color: var(--primary);
  background: rgba(233, 69, 96, 0.1);
  transform: scale(1.05);
}

.num-btn.selected {
  border-color: var(--success);
  background: rgba(0, 214, 114, 0.15);
  color: var(--success);
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0, 214, 114, 0.3);
}

.num-btn.disabled {
  pointer-events: none;
  opacity: 0.4;
}

.locked-msg {
  font-size: 1.1rem;
  color: var(--success);
  font-weight: 600;
}

/* Result Screen */
.result-numbers {
  display: flex;
  align-items: center;
  gap: 24px;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-num {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 900;
  background: var(--surface);
  border: 3px solid var(--accent);
}

.result-num.match {
  border-color: var(--success);
  color: var(--success);
  box-shadow: 0 0 30px rgba(0, 214, 114, 0.3);
}

.result-num.no-match {
  border-color: var(--text-dim);
}

.result-vs {
  font-size: 1.2rem;
  color: var(--text-dim);
  font-weight: 600;
}

.result-text {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.result-text.win {
  color: var(--success);
}

.result-text.lose {
  color: var(--primary);
}

.result-text.safe {
  color: var(--warning);
}

.next-challenger-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Game Over */
.gameover-title {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulse 1s ease-in-out infinite;
}

.gameover-title.win {
  background: linear-gradient(135deg, var(--success), #4ecdc4);
  -webkit-background-clip: text;
}

.gameover-title.lose {
  background: linear-gradient(135deg, var(--primary), #ff6b6b);
  -webkit-background-clip: text;
}

.gameover-dare {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--warning);
  background: rgba(255, 190, 11, 0.1);
  border: 2px solid rgba(255, 190, 11, 0.4);
  padding: 14px 24px;
  border-radius: 14px;
  text-align: center;
  max-width: 100%;
}

.gameover-actions {
  display: flex;
  gap: 12px;
}

.share-result-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--accent);
  width: 100%;
}

.share-result-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Disconnected */
#screen-disconnected h2 {
  color: var(--primary);
}

/* Memorial */
.memorial {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 10;
}

.memorial a {
  font-size: 0.75rem;
  text-decoration: none;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(136, 136, 136, 0.3);
  padding-bottom: 2px;
  background: linear-gradient(90deg, #ffbe0b, #e94560, #a77bca, #00d672, #ffbe0b);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: memorial-colors 10s linear infinite;
}

@keyframes memorial-colors {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.memorial a:hover {
  border-bottom-color: rgba(255, 190, 11, 0.4);
}

/* Mobile */
@media (max-width: 400px) {
  .title { font-size: 3rem; }
  .code-display { font-size: 2.5rem; padding: 12px 28px; }
  .number-grid { gap: 8px; max-width: 280px; }
  .num-btn { font-size: 1.2rem; }
  .countdown-display { font-size: 4.5rem; }
  .gameover-title { font-size: 2.5rem; }
}
