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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(145deg, #0b1120 0%, #151f2e 40%, #0f1923 100%);
  min-height: 100vh;
  color: #e2e8f0;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.logo-wrapper {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px;
  overflow: hidden;
}

.logo-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.logo-fallback {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.title-main {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.title-sub {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.3;
}

.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.25s ease;
}

.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.15);
}

.class-selector-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 10px 14px;
}

.class-selector-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.class-selector-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.class-tabs-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

.class-tab {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.class-tab:hover {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
}

.class-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.3);
}

.main-grid {
  display: grid;
  grid-template-columns: var(--left-w, 1fr) var(--right-w, 2fr);
  gap: 16px;
  align-items: stretch;
  position: relative;
  height: 100%;
}

.resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  z-index: 10;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transform: translateX(-50%);
}

.resize-handle-line {
  width: 3px;
  height: 50px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  transition: background 0.2s, height 0.2s;
  pointer-events: none;
}

.resize-handle:hover .resize-handle-line,
.resize-handle.active .resize-handle-line {
  background: rgba(59, 130, 246, 0.3);
  height: 90px;
}

.resize-handle.active .resize-handle-line {
  background: rgba(59, 130, 246, 0.5);
}

.left-panel, .right-panel {
  min-width: 0;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .resize-handle {
    display: none !important;
  }
  .class-selector-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .class-selector-label {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-right: 0;
    padding-bottom: 8px;
  }
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.students-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 16px;
}

.students-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.students-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.student-count-badge {
  font-size: 0.7rem;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.edit-toggle-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.25s ease;
}

.edit-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.15);
}

.edit-toggle-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.student-list-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  align-items: flex-start;
  align-content: flex-start;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s ease;
}

.student-list-display:hover {
  scrollbar-color: rgba(100, 116, 139, 0.4) transparent;
}

.student-list-display::-webkit-scrollbar {
  width: 5px;
}

.student-list-display::-webkit-scrollbar-track {
  background: transparent;
}

.student-list-display::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
  transition: background 0.3s ease;
}

.student-list-display:hover::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
}

.student-list-display::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}

.student-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #f1f5f9;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  user-select: none;
}

.student-tag:hover {
  background: rgba(51, 65, 85, 0.8);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.student-tag.used {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(255, 255, 255, 0.02);
  color: #64748b;
  text-decoration: line-through;
  box-shadow: none;
  opacity: 0.6;
}

.student-tag.used:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  text-decoration: line-through;
}

.student-empty-msg {
  color: #475569;
  font-size: 0.8rem;
  font-style: italic;
}

.edit-area {
  margin-top: 10px;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 300px; }
}

textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 70px;
  transition: border-color 0.25s ease;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}

textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

textarea::placeholder {
  color: #475569;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.done-btn {
  padding: 6px 20px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.done-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.right-panel {
  display: flex;
  flex-direction: column;
}

.wheel-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  position: relative;
}

.wheel-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
}

#wheel-canvas {
  display: block;
  margin: 0 auto;
  /* make it take the hight and the width of container, remove the padding and margin */
  width: 60% !important;
  height: auto !important;
  max-width: 900px;
  max-height: 900px;
}

.wheel-canvas-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid #f59e0b;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
}

.wheel-pointer::after {
  content: "";
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #fbbf24;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

#wheel-canvas {
  display: block;
  margin: 0 auto;
}

.spin-btn-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.spin-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border: 3px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.spin-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.55);
}

.spin-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.spin-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.selected-name-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  min-width: 200px;
  justify-content: center;
  order: -1;
  margin-bottom: 5px;
}

.selected-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 600;
}

.selected-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
  transition: all 0.3s ease;
}

.selected-value.highlight {
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  opacity: 0.35;
}

:root {
  --swal-overlay: rgba(0, 0, 0, 0.65);
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
  display: inline-block;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #1e293b;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: #64748b;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: rgba(255, 255, 255, 0.12);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

.glass-dark {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: #475569;
  margin-top: 2px;
}

.keyboard-hint kbd {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

/* ── Floating Action Button: سؤال عشوائي مباشر ─────────────────────────── */
.random-q-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 0 18px;
  height: 54px;
  border-radius: 27px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
  border: none;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  direction: rtl;
  white-space: nowrap;
  box-shadow:
    0 4px 24px rgba(245, 158, 11, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              padding 0.25s ease;
  overflow: hidden;
}

/* Animated pulse ring */
.random-q-fab .fab-glow {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: transparent;
  border: 2px solid rgba(251, 191, 36, 0.55);
  animation: fab-pulse 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes fab-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0; transform: scale(1.18); }
}

.random-q-fab .fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.3s ease;
}

.random-q-fab .fab-label {
  position: relative;
  z-index: 1;
}

.random-q-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 8px 36px rgba(245, 158, 11, 0.6),
    0 4px 14px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.random-q-fab:hover .fab-icon {
  transform: rotate(15deg) scale(1.15);
}

.random-q-fab:active {
  transform: translateY(0) scale(0.97);
  box-shadow:
    0 3px 14px rgba(245, 158, 11, 0.4),
    0 1px 6px rgba(0, 0, 0, 0.3);
}

/* Shimmer sweep on hover */
.random-q-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.random-q-fab:hover::after {
  transform: translateX(100%);
}


.site-footer {
  text-align: center;
  padding: 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 8px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.72rem;
  color: #475569;
  flex-wrap: wrap;
}

.footer-dot {
  color: #334155;
  font-size: 0.5rem;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .class-tab {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  .wheel-section {
    min-height: 360px;
    padding: 14px;
  }
  .wheel-pointer {
    top: -4px;
    border-left-width: 10px;
    border-right-width: 10px;
    border-top-width: 20px;
  }
  .wheel-pointer::after {
    top: -18px;
    width: 8px;
    height: 8px;
  }
}
