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

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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222e;
  --border: #2a2a3a;
  --primary: #6c5ce7;
  --primary-hover: #7d6ff0;
  --primary-glow: rgba(108, 92, 231, 0.35);
  --text: #e4e4e8;
  --text-dim: #8888a0;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --radius: 10px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* --- Buttons --- */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7d6ff0);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #8b7ff5);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-admin {
  background: linear-gradient(135deg, var(--warning), #e67e22);
  color: #fff;
}

.btn-admin:hover:not(:disabled) {
  background: linear-gradient(135deg, #e67e22, #d35400);
  box-shadow: 0 4px 20px rgba(243, 156, 18, 0.35);
}

/* --- Forms --- */

.form-group {
  margin-bottom: 14px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--text-dim);
  opacity: 0.7;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
}

/* --- Notices --- */

.notice {
  font-size: 13px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  line-height: 1.5;
}

.notice-warning {
  color: var(--warning);
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.25);
}

/* --- Auth Page --- */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.4s ease;
}

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

.logo {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, var(--primary), #a29bfe, #6c5ce7);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin: 8px 0 24px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
}

.tab.active {
  background: linear-gradient(135deg, var(--primary), #7d6ff0);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.auth-form .btn {
  width: 100%;
  margin-top: 4px;
}

/* --- Navbar --- */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.logo-sm {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#nav-username {
  color: var(--text-dim);
  font-size: 14px;
}

/* --- Lobby --- */

.lobby-container {
  max-width: 700px;
  margin: 60px auto;
  padding: 0 20px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 600px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  animation: fadeIn 0.4s ease;
}

.card:hover {
  border-color: rgba(108, 92, 231, 0.3);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(108, 92, 231, 0.08);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text);
}

.card .btn {
  width: 100%;
}

.room-code {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 4px;
  color: var(--primary);
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin: 12px 0;
  user-select: all;
}

#create-result .btn {
  margin-top: 8px;
}

/* --- Room --- */

.room-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

#room-name-display {
  font-weight: 600;
  font-size: 14px;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--surface2);
  border-radius: 20px;
  color: var(--text-dim);
}

.room-container {
  display: flex;
  height: calc(100vh - 53px);
}

.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.url-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.url-bar input {
  flex: 1;
}

.url-bar .btn {
  flex-shrink: 0;
}

.player-wrapper {
  flex: 1;
  position: relative;
  background: #000;
}

.player-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 16px;
  background: radial-gradient(ellipse at center, rgba(108, 92, 231, 0.05) 0%, transparent 70%);
}

/* --- Chat --- */

.chat-section {
  width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.chat-msg:hover {
  background: rgba(255, 255, 255, 0.03);
}

.chat-msg .author {
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: 6px;
}

.chat-msg.system {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-bar input {
  flex: 1;
}

.chat-input-bar .btn {
  flex-shrink: 0;
}

/* --- Admin Page --- */

.admin-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 700px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

/* Toggle Switch */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.toggle-row label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Admin Table */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.admin-table td {
  color: var(--text);
}

/* Admin status messages */

.admin-status {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-top: 12px;
  text-align: center;
}

.admin-status.success {
  color: var(--success);
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.2);
}

.admin-status.error {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
}

/* --- Scrollbar --- */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .room-container {
    flex-direction: column;
  }

  .chat-section {
    width: 100%;
    height: 300px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .player-section {
    height: 50vh;
  }

  .room-info-bar {
    display: none;
  }
}
