:root {
  --bg-color: #0f172a;
  --text-color: #ffffff;
  --text-muted: #94a3b8;
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #1e293b;
  --secondary-hover: #334155;
  --accent-color: #10b981;
  --danger-color: #ef4444;
  --card-bg: rgba(30, 41, 59, 0.5);
  --border-color: rgba(255, 255, 255, 0.1);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Utilities */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.w-full {
  width: 100%;
}

.text-center {
  text-align: center;
}

.uppercase {
  text-transform: uppercase;
}

.font-bold {
  font-weight: 700;
}

.gap-2 {
  gap: 0.5rem;
}

/* Layout */
.app-container {
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  position: relative;
}

/* Loading Screen */
#view-loading {
  position: absolute;
  inset: 0;
  z-index: 50;
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

/* Typography */
h1 {
  font-size: 1.25rem;
  font-weight: 800;
  opacity: 0.9;
}

h2 {
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

/* Components */
.btn {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1.125rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.btn-primary:not(:disabled):hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: #cbd5e1;
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background-color: var(--danger-color);
  color: white;
  box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
}

.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(-5%);
  }

  50% {
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* View Specific */
.view-section {
  display: flex;
  /* Changed from none to flex to ensure visibility when .hidden is removed */
  width: 100%;
  flex: 1;
  flex-direction: column;
}

/* Landing */
.landing-icon {
  font-size: 5rem;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  width: 12rem;
  height: 12rem;
  border-radius: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2rem auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Inputs */
.slider-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

input[type=range] {
  width: 100%;
  height: 0.5rem;
  background: var(--secondary-hover);
  border-radius: 0.5rem;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-color);
}

/* Setup Grid */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.category-card {
  background: var(--secondary-color);
  border: 2px solid transparent;
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.category-card.selected {
  border-color: var(--primary-color);
  background: rgba(79, 70, 229, 0.1);
}

.category-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.category-name {
  font-weight: 700;
  font-size: 0.9rem;
}

/* Role Reveal */
.role-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 2rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.secret-word {
  font-size: 2.5rem;
  font-weight: 900;
  margin: 1.5rem 0;
  word-break: break-all;
}

/* Timer */
.timer-container {
  position: relative;
  width: 16rem;
  height: 16rem;
  margin: 2rem auto;
}

.timer-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.timer-circle-bg {
  stroke: var(--secondary-color);
}

.timer-circle-fg {
  stroke: var(--primary-color);
  transition: stroke-dashoffset 1s linear;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.timer-digits {
  font-size: 3rem;
  font-weight: 900;
  font-family: monospace;
  display: block;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--secondary-hover);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary-color);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
  transform: translateX(26px);
}

/* High Contrast & Category Adjustments */
.category-card {
  border: 2px solid var(--border-color);
  background: var(--bg-color);
  /* Darker contrast */
}

.category-card .category-icon {
  display: none;
  /* Hide icons as requested */
}

.category-card.selected {
  background-color: var(--primary-color);
  border-color: white;
  color: white;
}

.input-name {
  width: 100%;
  padding: 0.75rem;
  background: var(--secondary-color);
  border: 1px solid var(--border-color);
  color: white;
  border-radius: 0.5rem;
  font-size: 1rem;
}

.input-name:focus {
  border-color: var(--primary-color);
  outline: none;
}

/* ========== SETUP PAGE STYLES ========== */

/* Section Cards */
.section-card {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title i {
  color: var(--primary-color);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Category Carousel */
.category-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.category-carousel::-webkit-scrollbar {
  height: 4px;
}

.category-carousel::-webkit-scrollbar-track {
  background: var(--secondary-color);
  border-radius: 2px;
}

.category-carousel::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 2px;
}

.category-card {
  min-width: 120px;
  flex-shrink: 0;
  background: var(--secondary-color);
  border: 2px solid var(--border-color);
  border-radius: 1rem;
  padding: 1rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  scroll-snap-align: start;
  color: white;
}

.category-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.category-card.selected {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.category-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.category-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Players List */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--secondary-color);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
}

.player-item .player-input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 1rem;
  font-weight: 500;
  padding: 0;
}

.player-item .player-input:focus {
  outline: none;
}

.player-item .btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  transition: color 0.2s;
}

.player-item .btn-icon:hover {
  color: white;
}

.player-item .btn-icon.btn-remove:hover {
  color: var(--danger-color);
}

.btn-add-player {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  font-size: 0.95rem;
  margin-bottom: 0;
}

/* Timer Settings */
.timer-settings-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.timer-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.select-styled {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--secondary-color);
  color: white;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5L8 12l6.5-6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px;
}

.select-styled:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Start Button */
.btn-start {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  padding: 1rem;
}

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}