/* ==========================================================================
   LUDO ROYALE - Modern Colorful Game Styles
   Enhanced with Public Room Browser, Spectator Badges, Join Approval Modals,
   and Mobile Portrait Optimized Ergonomics.
   ========================================================================== */

:root {
  --font-main: 'Outfit', 'Fredoka', system-ui, sans-serif;
  --font-fun: 'Fredoka', 'Outfit', cursive, sans-serif;

  /* Vibrant Colors */
  --c-red: #ff2a5f;
  --c-red-dark: #99002a;
  --c-red-glow: rgba(255, 42, 95, 0.45);

  --c-green: #00e676;
  --c-green-dark: #00803f;
  --c-green-glow: rgba(0, 230, 118, 0.45);

  --c-yellow: #ffc400;
  --c-yellow-dark: #b37700;
  --c-yellow-glow: rgba(255, 196, 0, 0.45);

  --c-blue: #00b0ff;
  --c-blue-dark: #005db3;
  --c-blue-glow: rgba(0, 176, 255, 0.45);

  --c-gold: #ffd700;
  --c-purple: #7c4dff;
  --c-spectator: #a78bfa;

  /* Surfaces & Glassmorphism */
  --bg-deep: #0e0926;
  --bg-panel: rgba(24, 16, 58, 0.78);
  --bg-panel-border: rgba(255, 255, 255, 0.18);
  --bg-panel-glow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-full: 9999px;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  background-color: var(--bg-deep);
  color: #ffffff;
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* ==========================================================================
   Animated Background
   ========================================================================== */
.bg-wrap {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #1e1347 0%, #0a061c 100%);
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-red {
  width: 450px;
  height: 450px;
  background: var(--c-red);
  top: -120px;
  left: -100px;
  animation-duration: 16s;
}

.orb-green {
  width: 420px;
  height: 420px;
  background: var(--c-green);
  top: -80px;
  right: -100px;
  animation-duration: 20s;
  animation-delay: -4s;
}

.orb-yellow {
  width: 480px;
  height: 480px;
  background: var(--c-yellow);
  bottom: -150px;
  right: -50px;
  animation-duration: 22s;
  animation-delay: -8s;
  opacity: 0.25;
}

.orb-blue {
  width: 440px;
  height: 440px;
  background: var(--c-blue);
  bottom: -100px;
  left: -80px;
  animation-duration: 18s;
  animation-delay: -12s;
}

.stars-layer {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 40px 60px, rgba(255,255,255,0.7), transparent),
                    radial-gradient(1.5px 1.5px at 150px 180px, rgba(255,255,255,0.5), transparent),
                    radial-gradient(2px 2px at 280px 90px, rgba(255,255,255,0.8), transparent),
                    radial-gradient(1px 1px at 350px 240px, rgba(255,255,255,0.6), transparent);
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: 0.35;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.15); }
  100% { transform: translate(-40px, 50px) scale(0.95); }
}

/* ==========================================================================
   Screens & Layout Containers
   ========================================================================== */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  padding: 16px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.screen.active {
  display: flex;
  animation: screenFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--bg-panel-glow);
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Home Screen & Branding
   ========================================================================== */
.home-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 10px 0 30px;
}

.game-branding {
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.crown-badge {
  font-size: 44px;
  animation: crownBounce 2.5s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(255, 215, 0, 0.6));
}

@keyframes crownBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

.logo-title {
  display: flex;
  gap: 6px;
  font-family: var(--font-fun);
  font-size: clamp(52px, 12vw, 84px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 2px;
}

.l-letter {
  display: inline-block;
  color: var(--c);
  text-shadow: 0 6px 0 var(--cd),
               0 12px 24px rgba(0, 0, 0, 0.5);
  animation: letterPop 3s ease-in-out infinite;
}

.l-letter:nth-child(1) { animation-delay: 0.0s; }
.l-letter:nth-child(2) { animation-delay: 0.15s; }
.l-letter:nth-child(3) { animation-delay: 0.3s; }
.l-letter:nth-child(4) { animation-delay: 0.45s; }

@keyframes letterPop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.logo-subtitle {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #fff;
  background: linear-gradient(90deg, var(--c-red), var(--c-yellow), var(--c-green), var(--c-blue));
  padding: 4px 16px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.home-card {
  width: 100%;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.label-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 6, 30, 0.6);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
  user-select: text;
  -webkit-user-select: text;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 400;
}

input:focus {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 4px rgba(0, 176, 255, 0.25);
  background: rgba(10, 6, 30, 0.8);
}

/* Avatar Picker */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.avatar-choice {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  font-size: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

.avatar-choice:hover {
  transform: translateY(-2px) scale(1.05);
  background: rgba(255, 255, 255, 0.15);
}

.avatar-choice.active {
  border-color: var(--c-gold);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
  transform: scale(1.1);
}

/* Color Picker */
.color-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.cp-btn.red .cp-dot { background-color: var(--c-red); color: var(--c-red); }
.cp-btn.green .cp-dot { background-color: var(--c-green); color: var(--c-green); }
.cp-btn.yellow .cp-dot { background-color: var(--c-yellow); color: var(--c-yellow); }
.cp-btn.blue .cp-dot { background-color: var(--c-blue); color: var(--c-blue); }

.cp-btn.active {
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.cp-btn.red.active { background: var(--c-red-glow); border-color: var(--c-red); }
.cp-btn.green.active { background: var(--c-green-glow); border-color: var(--c-green); }
.cp-btn.yellow.active { background: var(--c-yellow-glow); border-color: var(--c-yellow); }
.cp-btn.blue.active { background: var(--c-blue-glow); border-color: var(--c-blue); }

/* Room Options (Private / Passcode / Approval Toggles) */
.room-options-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.switch-label input[type="checkbox"] {
  display: none;
}

.switch-slider {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-full);
  position: relative;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

.switch-label input:checked + .switch-slider {
  background: var(--c-green);
}

.switch-label input:checked + .switch-slider::after {
  transform: translateX(16px);
}

.passcode-field {
  transition: all 0.3s ease;
}

.passcode-field.hidden {
  display: none;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.3, 1.1);
  color: #ffffff;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #ff2a5f 0%, #ff6b35 100%);
  box-shadow: 0 8px 24px rgba(255, 42, 95, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 42, 95, 0.5);
}

.btn-secondary {
  background: linear-gradient(135deg, #00b0ff 0%, #7c4dff 100%);
  box-shadow: 0 8px 24px rgba(0, 176, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 176, 255, 0.45);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-glow {
  position: relative;
  overflow: hidden;
}

.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent 35%, rgba(255, 255, 255, 0.25) 50%, transparent 65%);
  transform: rotate(25deg);
  animation: btnGleam 4s infinite linear;
}

@keyframes btnGleam {
  0% { transform: translateX(-100%) rotate(25deg); }
  25%, 100% { transform: translateX(100%) rotate(25deg); }
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.join-box {
  display: flex;
  gap: 10px;
}

.join-box input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
}

.separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}

.separator::before, .separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.16);
}

.separator span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.45);
}

.alert-message {
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #ff8099;
  text-align: center;
  transition: all 0.2s ease;
}

/* ==========================================================================
   Public Online Rooms Browser
   ========================================================================== */
.public-rooms-card {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.public-rooms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.public-rooms-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
}

.live-dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-green);
  box-shadow: 0 0 10px var(--c-green);
  animation: liveBlink 1.5s infinite;
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.public-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.public-room-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s ease;
}

.public-room-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.room-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-host-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-purple);
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.room-item-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.room-item-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-code-tag {
  font-family: var(--font-fun);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--c-gold);
}

.room-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.room-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.rooms-loading, .rooms-empty {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
}

/* ==========================================================================
   Player Slots (Lobby & Local Setup)
   ========================================================================== */
.local-card, .lobby-card {
  width: 100%;
  max-width: 760px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-header h2, .lobby-title-area h2 {
  font-size: 26px;
  font-weight: 800;
}

.panel-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
}

.player-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.slot-item {
  --color-theme: var(--c-red);
  position: relative;
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-theme) 22%, transparent), rgba(20, 14, 45, 0.6));
  border: 2px solid color-mix(in srgb, var(--color-theme) 60%, transparent);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.slot-item.vacant {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.slot-item.vacant:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
}

.slot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.7), transparent 60%), var(--color-theme);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-theme) 60%, transparent);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.slot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slot-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: #ffffff;
  color: #110d29;
}

.slot-meta {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.btn-row, .lobby-footer {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.btn-row .btn, .lobby-footer .btn {
  flex: 1;
}

/* Lobby Details */
.lobby-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.room-share-badge {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
}

#lobbyCodeDisplay {
  font-family: var(--font-fun);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--c-gold);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.lobby-meta-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.lobby-slots-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
}

.lobby-slots-title small {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
}

/* ==========================================================================
   In-Game Screen: Header & Layout
   ========================================================================== */
#screen-game {
  padding: 10px 14px;
  justify-content: flex-start;
  gap: 10px;
}

.game-header {
  width: 100%;
  max-width: 1280px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 10;
}

.btn-icon-round {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon-round:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
}

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

/* Spectator Counter Badge */
.spectator-counter-badge {
  background: rgba(167, 139, 250, 0.18);
  border: 1.5px solid var(--c-spectator);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.35);
}

.spec-eye {
  font-size: 14px;
}

.spectator-notice-bar {
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.2), rgba(0, 176, 255, 0.2));
  border: 1px solid rgba(167, 139, 250, 0.4);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  color: #e0d7ff;
}

.spectator-notice-bar.hidden {
  display: none;
}

/* ==========================================================================
   Next Move Banner (Prominent Turn Indicator)
   ========================================================================== */
.next-move-banner {
  --active-color: var(--c-red);
  flex: 1;
  max-width: 580px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--active-color) 45%, transparent), rgba(15, 10, 40, 0.85));
  border: 2px solid var(--active-color);
  box-shadow: 0 0 30px color-mix(in srgb, var(--active-color) 50%, transparent);
  border-radius: var(--radius-full);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.next-move-banner.pop {
  animation: bannerBounce 0.4s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes bannerBounce {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.banner-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 18px var(--active-color);
  opacity: 0.6;
  pointer-events: none;
  animation: bannerPulse 2s infinite ease-in-out;
}

@keyframes bannerPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

.banner-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.8), transparent 65%), var(--active-color);
  border: 2px solid #ffffff;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.banner-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.banner-status-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--active-color);
  text-shadow: 0 0 8px currentColor;
}

.banner-player-name {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.banner-instruction {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

/* Turn Timer Ring */
.turn-timer-ring {
  width: 38px;
  height: 38px;
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 3.5;
}

.timer-val {
  fill: none;
  stroke: var(--active-color);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s linear, stroke 0.3s ease;
}

.timer-text {
  position: absolute;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

/* ==========================================================================
   Game Arena & 4 Player Corner Docks
   ========================================================================== */
.game-arena {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  display: grid;
  grid-template-columns: minmax(210px, 270px) auto minmax(210px, 270px);
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "dock-red board dock-green"
    "dock-blue board dock-yellow";
  gap: 14px 20px;
  align-items: center;
  justify-content: center;
}

.dock-red { grid-area: dock-red; align-self: start; }
.dock-green { grid-area: dock-green; align-self: start; }
.dock-blue { grid-area: dock-blue; align-self: end; }
.dock-yellow { grid-area: dock-yellow; align-self: end; }

.board-viewport {
  grid-area: board;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Player Docks (Cards) */
.player-dock {
  --dock-color: #888888;
  background: var(--bg-panel);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.2);
  position: relative;
  min-height: 88px;
}

.dock-green, .dock-yellow {
  flex-direction: row-reverse;
  text-align: right;
}

.dock-green .dock-tokens-home, .dock-yellow .dock-tokens-home {
  justify-content: flex-end;
}

.player-dock.active {
  border-color: var(--dock-color);
  background: linear-gradient(135deg, color-mix(in srgb, var(--dock-color) 40%, transparent), rgba(20, 14, 45, 0.7));
  box-shadow: 0 0 35px color-mix(in srgb, var(--dock-color) 60%, transparent);
  transform: scale(1.04);
}

.player-dock.active .dock-avatar {
  animation: avatarPulse 1.4s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--dock-color) 40%, transparent); }
  50% { transform: scale(1.1); box-shadow: 0 0 0 10px color-mix(in srgb, var(--dock-color) 0%, transparent); }
}

.player-dock.hidden-dock {
  visibility: hidden;
  pointer-events: none;
}

.dock-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.8), transparent 60%), var(--dock-color);
  border: 3px solid #ffffff;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.dock-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dock-name {
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dock-status {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.dock-tokens-home {
  display: flex;
  gap: 5px;
  margin-top: 3px;
}

.home-pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.3);
}

.home-pip.filled {
  background: var(--dock-color);
  box-shadow: 0 0 10px var(--dock-color);
  border-color: #fff;
  transform: scale(1.15);
}

.dock-dice-cage {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ==========================================================================
   The Ludo Board
   ========================================================================== */
.ludo-board-wrapper {
  --board-dim: min(calc(100vh - 140px), calc(100vw - 580px), 720px);
  width: var(--board-dim);
  height: var(--board-dim);
  min-width: 300px;
  min-height: 300px;
  position: relative;
  border-radius: 26px;
  background: #fbf9ff;
  box-shadow:
    0 0 0 8px rgba(255, 255, 255, 0.15),
    0 0 0 10px rgba(255, 255, 255, 0.28),
    0 25px 80px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

#boardSvgCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.tokens-layer, .indicators-layer, .reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Board SVG Base Glow */
.base-active-glow {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.active-quadrant .base-active-glow {
  opacity: 1;
  animation: basePulseGlow 1.6s ease-in-out infinite;
}

@keyframes basePulseGlow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ==========================================================================
   3D Tokens (Pawns)
   ========================================================================== */
.pawn-token {
  --token-color: var(--c-red);
  --token-dark: var(--c-red-dark);
  --token-scale: 1;
  position: absolute;
  width: calc(100% / 15 * 0.88);
  height: calc(100% / 15 * 0.88);
  transform: translate(-50%, -50%) scale(var(--token-scale));
  transition: left 0.18s cubic-bezier(0.2, 0.8, 0.4, 1),
              top 0.18s cubic-bezier(0.2, 0.8, 0.4, 1),
              transform 0.2s ease;
  pointer-events: none;
  cursor: default;
}

.pawn-token::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.3) 25%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--token-color) 0%, var(--token-dark) 100%);
  border: 2.5px solid #ffffff;
  box-shadow:
    0 4px 0 var(--token-dark),
    0 8px 14px rgba(0, 0, 0, 0.5);
}

.pawn-token::after {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.65), transparent 70%);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
}

.pawn-token.movable {
  pointer-events: auto;
  cursor: pointer;
  animation: pawnBounce 0.75s ease-in-out infinite;
  z-index: 600 !important;
}

.pawn-token.movable::before {
  border-color: #ffffff;
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 25px 8px var(--token-color),
    0 6px 14px rgba(0, 0, 0, 0.5);
}

.pawn-token.movable:hover {
  filter: brightness(1.2);
}

.pawn-arrow {
  display: none;
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  animation: arrowHover 0.75s ease-in-out infinite;
  pointer-events: none;
}

.pawn-token.movable .pawn-arrow {
  display: block;
}

@keyframes pawnBounce {
  0%, 100% { transform: translate(-50%, -50%) scale(var(--token-scale)); }
  50% { transform: translate(-50%, -70%) scale(calc(var(--token-scale) * 1.08)); }
}

@keyframes arrowHover {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

.pawn-token.hop {
  animation: pawnHop 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes pawnHop {
  50% { transform: translate(-50%, -85%) scale(calc(var(--token-scale) * 1.25)); }
}

.pawn-token.flight-back {
  transition:
    left 0.6s cubic-bezier(0.3, -0.3, 0.2, 1.3),
    top 0.6s cubic-bezier(0.3, -0.3, 0.2, 1.3),
    transform 0.6s cubic-bezier(0.3, -0.3, 0.2, 1.3);
}

/* ==========================================================================
   3D Rolling Dice
   ========================================================================== */
.dice-cube-wrap {
  --dice-sz: 54px;
  width: var(--dice-sz);
  height: var(--dice-sz);
  perspective: 500px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  transition: opacity 0.3s ease;
}

.dice-cube-wrap.idle {
  opacity: 0.6;
}

.dice-cube-wrap.clickable {
  cursor: pointer;
  animation: dicePromptPulse 1.1s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.8)) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}

@keyframes dicePromptPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.08); }
}

.dice-cube-wrap.rolling {
  animation: diceTossPhysics 0.95s ease-out;
}

@keyframes diceTossPhysics {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-30px) scale(1.25); }
  65% { transform: translateY(0) scale(1); }
  85% { transform: translateY(-8px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

.cube-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.2, 0.95, 0.3, 1.05);
}

.cube-face {
  position: absolute;
  inset: 0;
  border-radius: 22%;
  background: linear-gradient(145deg, #ffffff 0%, #ebe6f7 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 13%;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.08),
    inset 0 -5px 10px rgba(0, 0, 0, 0.16);
  backface-visibility: hidden;
}

.face-1 { transform: rotateY(0deg) translateZ(calc(var(--dice-sz) / 2)); }
.face-2 { transform: rotateY(90deg) translateZ(calc(var(--dice-sz) / 2)); }
.face-3 { transform: rotateX(90deg) translateZ(calc(var(--dice-sz) / 2)); }
.face-4 { transform: rotateX(-90deg) translateZ(calc(var(--dice-sz) / 2)); }
.face-5 { transform: rotateY(-90deg) translateZ(calc(var(--dice-sz) / 2)); }
.face-6 { transform: rotateY(180deg) translateZ(calc(var(--dice-sz) / 2)); }

.face-pip {
  width: 78%;
  height: 78%;
  margin: auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #524775, #140d30);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6);
}

.face-1 .face-pip {
  width: 95%;
  height: 95%;
  background: radial-gradient(circle at 35% 30%, #ff5277, #d60036);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 8px rgba(255, 42, 95, 0.4);
}

/* Mobile Big Thumb Roll Button */
.mobile-roll-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.mobile-roll-container.hidden {
  display: none !important;
}

.mobile-roll-btn {
  width: 100%;
  padding: 16px 24px;
  font-size: 19px;
  font-weight: 800;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: mobileRollPulse 1.2s infinite ease-in-out;
}

@keyframes mobileRollPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(255, 42, 95, 0.4); }
  50% { transform: scale(1.03); box-shadow: 0 12px 32px rgba(255, 42, 95, 0.6); }
}

/* ==========================================================================
   Quick Reactions & Floating Emotes
   ========================================================================== */
.quick-reactions-bar {
  display: flex;
  gap: 8px;
  background: rgba(18, 12, 45, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
  justify-content: center;
}

.emote-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  padding: 6px 10px;
  font-size: 15px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.emote-btn:hover {
  transform: translateY(-3px) scale(1.15);
  background: rgba(255, 255, 255, 0.2);
}

.floating-reaction {
  position: absolute;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: rgba(15, 10, 40, 0.92);
  border: 2px solid var(--bubble-c, #ffffff);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  animation: floatReaction 3s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  pointer-events: none;
  z-index: 800;
  white-space: nowrap;
}

@keyframes floatReaction {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { transform: translateY(-20px) scale(1.15); opacity: 1; }
  30% { transform: translateY(-30px) scale(1); opacity: 1; }
  80% { transform: translateY(-70px) scale(1); opacity: 0.9; }
  100% { transform: translateY(-110px) scale(0.8); opacity: 0; }
}

/* ==========================================================================
   Toasts & Modals
   ========================================================================== */
.toasts-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
  align-items: center;
  max-width: 90vw;
}

.toast-msg {
  --toast-c: var(--c-blue);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: rgba(18, 12, 45, 0.95);
  border: 2px solid var(--toast-c);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 24px color-mix(in srgb, var(--toast-c) 50%, transparent);
  font-size: 15px;
  font-weight: 700;
  backdrop-filter: blur(14px);
  animation: toastEntrance 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-msg.leave {
  opacity: 0;
  transform: translateY(-15px) scale(0.9);
}

@keyframes toastEntrance {
  from { opacity: 0; transform: translateY(-20px) scale(0.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 4, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  z-index: 1200;
  padding: 18px;
  animation: modalFade 0.3s ease;
}

.modal-backdrop.hidden {
  display: none !important;
}

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

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1);
  text-align: center;
}

@keyframes modalPop {
  from { transform: scale(0.75); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Approval Modal */
.approval-icon, .passcode-icon {
  font-size: 52px;
  margin-bottom: 6px;
}

.approval-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 14px;
}

.requester-info-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.approval-actions {
  display: flex;
  gap: 12px;
}

.approval-actions .btn {
  flex: 1;
}

/* Waiting Spinner Modal */
.waiting-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--c-blue);
  border-radius: 50%;
  animation: spinLoader 0.9s infinite linear;
  margin: 0 auto 16px;
}

@keyframes spinLoader {
  to { transform: rotate(360deg); }
}

/* Victory Modal */
.victory-card {
  text-align: center;
}

.victory-trophy {
  font-size: 74px;
  animation: trophyFloat 2s ease-in-out infinite;
  filter: drop-shadow(0 10px 20px rgba(255, 215, 0, 0.5));
}

@keyframes trophyFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.08); }
}

.victory-title {
  font-size: 32px;
  font-weight: 800;
  margin-top: 10px;
  color: var(--c-gold);
}

.victory-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 20px;
}

.podium-rankings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, color-mix(in srgb, var(--rank-c) 35%, transparent), rgba(255, 255, 255, 0.05));
  border: 1px solid color-mix(in srgb, var(--rank-c) 60%, transparent);
}

.ranking-medal {
  font-size: 24px;
  width: 32px;
}

.ranking-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--rank-c);
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  font-size: 18px;
}

.ranking-name {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  text-align: left;
}

.victory-actions {
  display: flex;
  gap: 12px;
}

.victory-actions .btn {
  flex: 1;
}

/* Rules Modal */
.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.rules-header h3 {
  font-size: 22px;
  font-weight: 800;
}

.btn-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

.btn-close:hover {
  color: #fff;
}

.rules-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 6px;
  text-align: left;
}

.rule-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.rule-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.rule-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 3px;
  color: #fff;
}

.rule-text p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.4;
}

/* Confetti particles */
.confetti-particle {
  position: fixed;
  top: -20px;
  z-index: 2000;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(800deg); }
}

/* ==========================================================================
   MOBILE PORTRAIT & RESPONSIVE OPTIMIZATION
   ========================================================================== */
@media (max-width: 990px) {
  .game-arena {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "dock-red dock-green"
      "board board"
      "dock-blue dock-yellow";
    gap: 8px 12px;
  }

  .ludo-board-wrapper {
    --board-dim: min(94vw, calc(100vh - 290px));
  }

  .player-dock {
    min-height: 68px;
    padding: 8px 10px;
  }

  .dock-avatar {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .dock-name {
    font-size: 15px;
  }

  .dock-dice-cage {
    width: 48px;
    height: 48px;
  }

  .dice-cube-wrap {
    --dice-sz: 42px;
  }
}

/* Dedicated Mobile Portrait Screen Rules (< 640px) */
@media (max-width: 640px), (orientation: portrait) and (max-width: 800px) {
  #screen-game {
    padding: 6px 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .game-header {
    gap: 8px;
  }

  .btn-icon-round {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .spectator-counter-badge {
    padding: 4px 8px;
    font-size: 12px;
  }

  .next-move-banner {
    padding: 6px 12px;
    gap: 8px;
  }

  .banner-avatar {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .banner-player-name {
    font-size: 15px;
  }

  .banner-instruction {
    font-size: 11px;
  }

  .turn-timer-ring {
    width: 32px;
    height: 32px;
  }

  .timer-text {
    font-size: 10px;
  }

  .game-arena {
    width: 100%;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "dock-red dock-green"
      "board board"
      "dock-blue dock-yellow";
    gap: 6px 8px;
  }

  .ludo-board-wrapper {
    --board-dim: min(96vw, calc(100vh - 275px));
    border-radius: 20px;
  }

  .player-dock {
    min-height: 58px;
    padding: 6px 8px;
    gap: 6px;
    border-radius: 12px;
  }

  .dock-avatar {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-width: 2px;
  }

  .dock-name {
    font-size: 13px;
  }

  .dock-status {
    font-size: 10px;
  }

  .home-pip {
    width: 9px;
    height: 9px;
  }

  .dock-dice-cage {
    width: 38px;
    height: 38px;
  }

  .dice-cube-wrap {
    --dice-sz: 36px;
  }

  .player-slots-grid {
    grid-template-columns: 1fr;
  }

  .home-card, .local-card, .lobby-card, .public-rooms-card {
    padding: 16px;
    border-radius: 20px;
  }

  .quick-reactions-bar {
    padding: 4px 6px;
    gap: 4px;
  }

  .emote-btn {
    padding: 4px 7px;
    font-size: 12px;
  }

  .mobile-roll-btn {
    padding: 14px 20px;
    font-size: 17px;
  }
}

/* ==========================================================================
   Crazy Ludo & Game Mode Styling
   ========================================================================== */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.mode-btn .mode-icon {
  font-size: 26px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.mode-btn .mode-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-btn .mode-title {
  font-family: var(--font-fun);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.mode-btn .mode-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.25;
}

.mode-btn.active {
  border-color: var(--c-gold);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 107, 107, 0.15));
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), inset 0 0 12px rgba(255, 215, 0, 0.1);
  transform: translateY(-2px);
}

.mode-btn[data-mode="crazy"].active {
  border-color: #ff007f;
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.25), rgba(121, 40, 202, 0.2));
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.4), inset 0 0 12px rgba(255, 0, 127, 0.15);
}

.mode-btn.active .mode-title {
  color: #fff;
  text-shadow: 0 0 8px currentColor;
}

/* Room Mode Tag in Public Rooms Browser */
.room-mode-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.room-mode-tag.mode-classic {
  background: rgba(0, 230, 118, 0.15);
  border: 1px solid rgba(0, 230, 118, 0.4);
  color: #00e676;
}

.room-mode-tag.mode-crazy {
  background: rgba(255, 0, 128, 0.2);
  border: 1px solid rgba(255, 0, 128, 0.5);
  color: #ff40a0;
  animation: pulseCrazyTag 2s infinite ease-in-out;
}

@keyframes pulseCrazyTag {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 0, 128, 0); }
  50% { box-shadow: 0 0 8px rgba(255, 0, 128, 0.6); }
}

/* In-Game Header Mode Indicator */
.game-mode-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.game-mode-indicator.crazy-mode {
  background: linear-gradient(135deg, rgba(255, 0, 128, 0.25), rgba(121, 40, 202, 0.25));
  border-color: rgba(255, 64, 160, 0.6);
  color: #ff80c0;
  box-shadow: 0 0 10px rgba(255, 0, 128, 0.3);
}

/* Meta Mode Badge in Lobby */
.meta-mode-badge {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: var(--c-gold);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.meta-mode-badge:hover {
  background: rgba(255, 215, 0, 0.25);
  transform: scale(1.05);
}

.meta-mode-badge.crazy {
  background: rgba(255, 0, 128, 0.2);
  border-color: rgba(255, 0, 128, 0.5);
  color: #ff66b2;
}

/* Shield Effect on Pawn Token */
.pawn-token.has-shield {
  filter: drop-shadow(0 0 8px #00e5ff) drop-shadow(0 0 14px #00b0ff);
}

.pawn-token.has-shield::after {
  content: '🛡️';
  position: absolute;
  top: -12px;
  right: -8px;
  font-size: 14px;
  filter: drop-shadow(0 0 5px #00e5ff);
  animation: shieldFloat 1.8s infinite ease-in-out;
  pointer-events: none;
}

@keyframes shieldFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.15); }
}

/* Rules Divider */
.rule-divider {
  display: flex;
  align-items: center;
  margin: 16px 0 10px;
  font-family: var(--font-fun);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--c-gold);
}

.rule-divider::before, .rule-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.4), transparent);
  margin: 0 10px;
}


