/* ==========================================================================
   Ludo Pro - Modern Glassmorphic Dark/Light Mobile-First Theme
   ========================================================================== */

:root {
  --bg-primary: #070a12;
  --bg-surface: #101726;
  --bg-surface-elevated: #172033;
  --bg-glass: rgba(16, 23, 38, 0.88);
  --border-glass: rgba(255, 255, 255, 0.09);
  --border-glass-light: rgba(255, 255, 255, 0.16);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);

  --color-red: #ff2e63;
  --color-red-glow: rgba(255, 46, 99, 0.6);
  --color-green: #00e676;
  --color-green-glow: rgba(0, 230, 118, 0.6);
  --color-yellow: #ffb703;
  --color-yellow-glow: rgba(255, 183, 3, 0.6);
  --color-blue: #00d2ff;
  --color-blue-glow: rgba(0, 210, 255, 0.6);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.4);

  --board-max-size: min(92vw, 86vh, 620px);
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(255, 46, 99, 0.14) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(0, 230, 118, 0.14) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(0, 210, 255, 0.14) 0px, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  position: relative;
}

/* App Header */
.app-header {
  width: 100%;
  max-width: 1100px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 50;
  position: sticky;
  top: 0;
  background: rgba(7, 10, 18, 0.88);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
}

.brand-icon-wrapper {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-svg {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

.brand-text {
  font-weight: 800;
  font-size: 1.38rem;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand-highlight {
  color: #818cf8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-glass-light);
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.6);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glass-light);
}

.btn-secondary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Screen Management */
.screen-container {
  width: 100%;
  max-width: 1200px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 16px 36px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 900px;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.25s ease-out forwards;
}

.screen.active {
  display: flex;
}

/* Setup Containers & Title Bars */
.setup-container {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 8px;
}

.screen-title-bar h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.setup-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.online-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
}

/* Home / Menu Screen */
.hero-section {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 28px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  color: #ffffff;
  margin-bottom: 8px;
  text-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 520px;
  margin: 0 auto;
}

.mode-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 860px;
  margin-bottom: 24px;
}

.mode-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.mode-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-glass-light);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.mode-card:hover::before {
  opacity: 1;
}

.mode-card-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
  width: 56px;
  height: 56px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.mode-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.mode-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 16px;
  flex: 1;
}

.mode-card-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Modal and Panels (Victory Celebration) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: scaleUp 0.25s ease-out;
  position: relative;
}

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.color-picker-group {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.color-option {
  flex: 1;
  height: 52px;
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.color-option:hover {
  transform: translateY(-2px) scale(1.06);
}

.color-option.selected {
  border-color: #ffffff;
  transform: scale(1.12);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.7);
}

.color-option.red {
  background: radial-gradient(circle at 35% 35%, #ff7597, #ff2e63, #990026);
}
.color-option.green {
  background: radial-gradient(circle at 35% 35%, #69f0ae, #00e676, #005a22);
}
.color-option.yellow {
  background: radial-gradient(circle at 35% 35%, #ffe082, #ffb703, #9e5b00);
}
.color-option.blue {
  background: radial-gradient(circle at 35% 35%, #80e5ff, #00d2ff, #004085);
}

.player-count-buttons {
  display: flex;
  gap: 10px;
}

.count-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.count-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   Game Screen Layout & Player HUDs
   ========================================================================== */

.game-arena {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.game-status-bar {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  max-width: 90%;
  text-align: center;
}

.game-main-row {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
}

/* Side Player Cards for Desktop / Tablet */
.players-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 180px;
}

.player-hud-card {
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.player-hud-card.active-turn {
  border-color: #ffffff;
  transform: scale(1.05);
}

.player-hud-card.red.active-turn {
  border-color: var(--color-red);
  box-shadow: 0 0 28px var(--color-red-glow), inset 0 0 12px rgba(255, 46, 99, 0.2);
}
.player-hud-card.green.active-turn {
  border-color: var(--color-green);
  box-shadow: 0 0 28px var(--color-green-glow), inset 0 0 12px rgba(0, 230, 118, 0.2);
}
.player-hud-card.yellow.active-turn {
  border-color: var(--color-yellow);
  box-shadow: 0 0 28px var(--color-yellow-glow), inset 0 0 12px rgba(255, 183, 3, 0.2);
}
.player-hud-card.blue.active-turn {
  border-color: var(--color-blue);
  box-shadow: 0 0 28px var(--color-blue-glow), inset 0 0 12px rgba(0, 210, 255, 0.2);
}

.player-hud-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-avatar {
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-sm);
}

.player-info {
  flex: 1;
  overflow: hidden;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.player-tokens-status {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
}

/* Live Goti Progress Trackers */
.goti-progress-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.goti-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.goti-progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.red .goti-progress-bar-fill {
  background: linear-gradient(90deg, #ff7597, #ff2e63);
  box-shadow: 0 0 8px rgba(255, 46, 99, 0.8);
}
.green .goti-progress-bar-fill {
  background: linear-gradient(90deg, #69f0ae, #00e676);
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.8);
}
.yellow .goti-progress-bar-fill {
  background: linear-gradient(90deg, #ffe082, #ffb703);
  box-shadow: 0 0 8px rgba(255, 183, 3, 0.8);
}
.blue .goti-progress-bar-fill {
  background: linear-gradient(90deg, #80e5ff, #00d2ff);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.8);
}

.goti-chips-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.goti-chip {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.60rem;
  font-weight: 800;
  line-height: 1.1;
  transition: all 0.2s;
}

.goti-chip-title {
  color: var(--text-muted);
  font-size: 0.55rem;
}

.goti-chip.in-yard {
  color: var(--text-muted);
  opacity: 0.6;
}

.goti-chip.in-track {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.goti-chip.in-home {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.5);
  background: rgba(234, 179, 8, 0.15);
}

.goti-chip.finished {
  color: #4ade80;
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.25);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.hud-dice-area {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

/* Interactive Center Dice Hub */
.dice-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.roll-prompt-badge {
  position: absolute;
  top: -32px;
  background: linear-gradient(135deg, #facc15, #f59e0b);
  color: #0f172a;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.7);
  white-space: nowrap;
  animation: floatBounce 1.2s infinite alternate;
}

/* In-Game Bottom Action Bar */
.game-bottom-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.emoji-bar {
  display: flex;
  gap: 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 2px 5px;
}

.emoji-btn:hover {
  transform: scale(1.35);
}

/* Floating Emoji Reactions */
.floating-emoji {
  position: absolute;
  font-size: 2.4rem;
  z-index: 100;
  pointer-events: none;
  animation: emojiFloat 2.5s ease-out forwards;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast-message {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass-light);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInRight 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { border-left: 4px solid var(--color-green); }
.toast-warning { border-left: 4px solid var(--color-yellow); }
.toast-info { border-left: 4px solid var(--accent-primary); }

.toast-fade-out {
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.3s ease-in;
}

/* Responsive Mobile Rules */
@media (max-width: 900px) {
  .players-column {
    display: none;
  }
  .game-main-row {
    flex-direction: column;
  }
  .app-header {
    padding: 10px 14px;
  }
  .brand-text {
    font-size: 1.2rem;
  }
  .screen-title-bar h2 {
    font-size: 1.2rem;
  }
  .setup-card {
    padding: 18px;
  }
}
