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

:root {
  --bg: #1a1035;
  --bg-gradient: linear-gradient(180deg, #1a1035 0%, #0d0b1a 100%);
  --card-bg: rgba(255,255,255,0.08);
  --card-bg-hover: rgba(255,255,255,0.12);
  --text: #f0eef5;
  --text-secondary: #9b95b0;
  --accent: #7c4dff;
  --accent-hover: #651fff;
  --green: #00e676;
  --red: #ff5252;
  --orange: #ffab40;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

#app {
  height: 100%;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  flex-direction: column;
}
.view.active {
  display: flex;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: rgba(124,77,255,0.15);
  color: var(--accent);
}
.btn-secondary:hover {
  background: rgba(124,77,255,0.25);
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,8,20,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}
.overlay.hidden {
  display: none;
}

.result-card, .modal-card {
  background: #2a2045;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  width: 90%;
}
.result-card h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text);
}
.result-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.result-actions .btn {
  flex: 1;
}
#rematch-waiting {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-card h3 {
  margin-bottom: 16px;
  color: var(--text);
}
.modal-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.modal-card input:focus {
  border-color: var(--accent);
}
.modal-card input::placeholder {
  color: var(--text-secondary);
}

/* Mode selection */
.mode-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.mode-btn-group .btn {
  width: 100%;
}

.difficulty-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.difficulty-btn {
  width: 100%;
  padding: 14px 24px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.difficulty-btn:hover {
  background: rgba(124,77,255,0.2);
  border-color: var(--accent);
}

/* Pass device overlay */
#pass-device-overlay .modal-card {
  background: linear-gradient(135deg, #2a2045, #1a1035);
}
#pass-device-overlay h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
#pass-device-overlay p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}
