:root {
  --bg-color: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.4);
  --secondary: #475569;
  --secondary-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-hover: rgba(255, 255, 255, 0.1);
  --card-selected: #3b82f6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  overflow: hidden; /* Prevent body scroll, handle inside app */
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 1200px;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Utilities */
.hidden { display: none !important; }
.mt-2 { margin-top: 1rem; }
.text-center { text-align: center; }

/* Views */
.view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#view-landing, #view-error {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Glassmorphism */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
}

.card-icon {
  font-size: 2rem;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

h1 {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"], select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: #fff;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  font-family: inherit;
}

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

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

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

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

.btn.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.btn.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Game View */
.glass-header {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

h2#room-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.name-input {
  width: 140px !important;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.9rem !important;
  border-radius: 8px !important;
}

.game-board {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.user-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-card.minority {
  opacity: 0.4;
  filter: grayscale(100%);
  transform: scale(0.95);
}

.user-name {
  font-weight: 500;
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.vote-display {
  width: 60px;
  height: 84px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vote-display.has-voted {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  transform: translateY(-5px);
}

.vote-display.revealed {
  background: #fff;
  color: var(--bg-color);
  border-color: #fff;
  transform: scale(1.05);
}

/* Footer / Controls */
.glass-footer {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 10;
}

.action-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.action-buttons .btn {
  flex: 1;
}

.cards-scroller {
  display: flex;
  overflow-x: auto;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.cards-scroller::-webkit-scrollbar {
  height: 6px;
}
.cards-scroller::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.vote-card {
  flex: 0 0 auto;
  width: 56px;
  height: 80px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.vote-card:hover {
  background: var(--card-hover);
  transform: translateY(-4px);
}

.vote-card.selected {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
  transform: translateY(-8px);
}

/* Animations & Notification */
.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

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

.notification {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-weight: 500;
  z-index: 1000;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from { transform: translate(-50%, -100%); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Mobile optimizations */
@media (max-width: 600px) {
  .glass-panel { padding: 1.5rem; border-radius: 20px; border-left: none; border-right: none;}
  .game-board { padding: 1rem; }
  .users-grid { gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .vote-display { width: 50px; height: 70px; font-size: 1.5rem; }
  .vote-card { width: 50px; height: 70px; font-size: 1.1rem; }
  .name-input { width: 100px !important; }
}
