/* ==========================================================================
   WII PORTAL SYSTEM STYLESHEET
   ========================================================================== */

:root {
  --wii-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wii-bg-radial: radial-gradient(circle at 50% 45%, #ffffff 0%, #e7ecf2 60%, #cfd6df 100%);
  --wii-grid-color: rgba(160, 175, 190, 0.14);
  --wii-text-dark: #2b333c;
  --wii-text-muted: #6b7785;
  --channel-card-bg: radial-gradient(circle at center, #ffffff 45%, #eaf0f6 100%);
  --channel-bezel: linear-gradient(145deg, #f0f3f6, #c5ccd4);
  --channel-border: rgba(120, 130, 140, 0.25);
  --shelf-bg: linear-gradient(180deg, #d6dce3 0%, #b8c1cc 45%, #9da8b6 100%);
  --shelf-border-top: #ffffff;
  --btn-circ-outer: linear-gradient(145deg, #f8fafd, #c4cbd4);
  --btn-circ-inner: radial-gradient(circle at 35% 35%, #ffffff 0%, #d8dfe6 75%, #b4bcc6 100%);
  --wii-blue-glow: #3eb6ea;
  --wii-blue-deep: #1982b6;
  --channel-radius: 14px;
}

/* Dark Mode Theme */
:root.dark-theme,
body.dark-theme {
  --wii-bg-radial: radial-gradient(circle at 50% 45%, #222933 0%, #151a21 60%, #0d1116 100%);
  --wii-grid-color: rgba(255, 255, 255, 0.05);
  --wii-text-dark: #ecf1f7;
  --wii-text-muted: #8d9bb0;
  --channel-card-bg: radial-gradient(circle at center, #262d38 45%, #181d24 100%);
  --channel-bezel: linear-gradient(145deg, #323b49, #1a1f26);
  --channel-border: rgba(255, 255, 255, 0.08);
  --shelf-bg: linear-gradient(180deg, #2b333f 0%, #1c222a 45%, #12161b 100%);
  --shelf-border-top: #424e60;
  --btn-circ-outer: linear-gradient(145deg, #323c4a, #1b2028);
  --btn-circ-inner: radial-gradient(circle at 35% 35%, #384352 0%, #222934 75%, #161b22 100%);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  cursor: none !important; /* Managed by Black Wii cursor */
}

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--wii-font);
  background: var(--wii-bg-radial);
  background-color: #eaf0f6;
  transition: background-color 0.35s ease;
}

:root.dark-theme,
body.dark-theme {
  background-color: #0d1116;
}

/* Authentic Wii System Typography applied to all interactive elements */
button,
input,
select,
textarea,
.btn-label,
.wii-pill-button,
.btn-start-service,
.btn-back-wii,
.wii-auth-input,
.wii-password-input,
.wii-username-input,
.login-title,
.login-subtitle,
.channel-label,
.time-display,
.date-display,
.profile-user-name,
.notification-title,
.notification-body,
.message-item-title,
.active-user-name,
.avatar-picker-title,
.wii-circle-button .btn-label {
  font-family: var(--wii-font) !important;
}

/* Authentic Black Wii Remote Hand Cursor (Player 1) */
#wii-cursor-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 36px;
  height: 52px;
  pointer-events: none !important;
  z-index: 999999;
  transform: translate(-10px, -1px);
  transition: transform 0.04s ease-out;
  will-change: transform, left, top;
}

#wii-cursor-wrapper.open-hand {
  width: 46px;
  height: 52px;
  transform: translate(-23px, -8px);
}

#wii-cursor {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
  display: block;
}

#wii-cursor-wrapper.clicking {
  transform: translate(-10px, -1px) scale(0.92);
}

#wii-cursor-wrapper.open-hand.clicking {
  transform: translate(-23px, -8px) scale(0.92);
}

/* Master Menu Container */
#wii-main-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--wii-bg-radial);
  overflow: hidden;
  transition: transform 0.42s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.42s ease, background 0.35s ease;
}

/* Subtle Wii Grid Overlay */
#wii-main-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(to right, var(--wii-grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--wii-grid-color) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 1;
}

/* Zoom Transition */
body.zooming #wii-main-container {
  transform: scale(2.3);
  opacity: 0;
}

/* Top Bar: Mii Profile & Dark Mode Toggle */
.wii-top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 16px 45px 10px 45px;
  color: var(--wii-text-dark);
}

.wii-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Center Bottom Deck: Date, Clock & Disc Slot */
.wii-bottom-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 20;
}

.wii-date-clock {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
}

.wii-date {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--wii-text-muted);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

body.dark-theme .wii-date {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.wii-clock {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--wii-text-dark);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
  line-height: 1;
}

body.dark-theme .wii-clock {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Dark Mode Button */
.wii-theme-toggle {
  background: none;
  border: none;
  outline: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--btn-circ-outer);
  padding: 3px;
  box-shadow: 
    0 3px 8px rgba(0, 0, 0, 0.18),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

.wii-theme-toggle:hover {
  transform: scale(1.12);
  box-shadow: 0 0 12px rgba(62, 182, 234, 0.8);
}

.wii-theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--btn-circ-inner);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

#theme-toggle-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.wii-theme-toggle:hover #theme-toggle-icon {
  transform: rotate(25deg);
}

/* Wii Music / BGM Toggle Button */
.music-toggle-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wii-music-toggle:hover .music-toggle-icon,
.login-music-toggle:hover .music-toggle-icon {
  transform: scale(1.22) rotate(12deg);
}

.wii-music-toggle.playing,
.login-music-toggle.playing {
  box-shadow: 0 0 12px rgba(62, 182, 234, 0.7);
}

/* 4x3 Channel Grid Container */
.wii-grid-wrapper {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 45px;
}

.wii-channel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 16px 20px;
  width: 100%;
  max-width: 1240px;
  height: 100%;
  max-height: 640px;
}

/* Individual Channel Frame */
.wii-channel {
  position: relative;
  border-radius: var(--channel-radius);
  background: var(--channel-bezel);
  padding: 5px;
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.14),
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(100, 110, 120, 0.35);
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.22s ease;
  overflow: hidden;
}

body.dark-theme .wii-channel {
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.15),
    inset 0 -2px 3px rgba(0, 0, 0, 0.6);
}

.wii-channel:hover {
  transform: scale(1.05);
  box-shadow: 
    0 0 18px rgba(62, 182, 234, 0.85),
    0 8px 24px rgba(0, 0, 0, 0.25),
    inset 0 0 12px rgba(62, 182, 234, 0.45);
  z-index: 25;
}

/* Inner Channel Screen */
.wii-channel-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--channel-radius) - 3px);
  overflow: hidden;
  background: var(--channel-card-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--channel-border);
}

/* Curved Glossy Glass Arc Reflection */
.wii-channel-inner::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.15) 85%, transparent 100%);
  border-radius: calc(var(--channel-radius) - 3px) calc(var(--channel-radius) - 3px) 60% 60% / 20px;
  pointer-events: none;
  z-index: 5;
}

body.dark-theme .wii-channel-inner::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.05) 85%, transparent 100%);
}

/* Channel Card Content */
.channel-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px;
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

.wii-channel:hover .channel-content {
  transform: scale(1.04);
}

.channel-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.16));
  transition: transform 0.2s ease;
}

.wii-channel:hover .channel-icon {
  transform: scale(1.08);
}

.channel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--wii-text-dark);
  letter-spacing: 0.5px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
}

body.dark-theme .channel-title {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.channel-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wii-text-muted);
  margin-top: 3px;
}

/* ==========================================================================
   Wii Animated Channel Tiles (Live Video / Canvas Backgrounds)
   ========================================================================== */
.channel-anim-canvas,
.channel-anim-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  pointer-events: none;
  opacity: 0.96;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.wii-channel:hover .channel-anim-canvas,
.wii-channel:hover .channel-anim-video {
  transform: scale(1.05);
  opacity: 1;
}

/* Gentle Wii Floating / Bobbing Animation for Active Channel Icons */
@keyframes wiiTileIconFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-4px);
  }
}

.wii-channel.active-service .channel-icon {
  animation: wiiTileIconFloat 3.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.wii-channel.active-service:hover .channel-icon {
  animation: none;
  transform: scale(1.12) translateY(-2px);
}

.wii-channel.active-service .channel-title {
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.7);
  z-index: 3;
}

.wii-channel.active-service .channel-subtitle {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  z-index: 3;
}

/* Empty Channels Static Noise Canvas */
.static-noise-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Bottom Bar: Wii Controls, Disc Slot, Message Board */
.wii-bottom-bar {
  position: relative;
  z-index: 15;
  width: 100%;
  height: 100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 45px;
  box-sizing: border-box;
}

/* Curved metallic lower deck background */
.wii-bottom-bar::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--shelf-bg);
  border-top: 3px solid var(--shelf-border-top);
  border-radius: 38px 38px 0 0;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.16);
  z-index: -1;
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* Left controls: Wii button & SD card */
.wii-bottom-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Circular Buttons (Classic 3D Wii & Message Board) */
.wii-circle-button {
  background: none;
  border: none;
  outline: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--btn-circ-outer);
  padding: 4px;
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.22),
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

.wii-circle-button:hover {
  transform: scale(1.08);
  box-shadow: 
    0 0 16px rgba(62, 182, 234, 0.8),
    0 6px 14px rgba(0, 0, 0, 0.25);
}

.wii-circle-button:active {
  transform: scale(0.96);
}

.wii-circle-button-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--btn-circ-inner);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

/* Official Centered Wii Logo Wordmark inside button */
.wii-btn-logo {
  width: 52px;
  height: auto;
  display: block;
  margin: 0 auto;
  user-select: none;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.25s ease;
}

.wii-btn-logo-light {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.95));
}

.wii-btn-logo-dark {
  display: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 6px rgba(62, 182, 234, 0.45));
}

body.dark-theme .wii-btn-logo-light {
  display: none;
}

body.dark-theme .wii-btn-logo-dark {
  display: block;
}

.wii-circle-button:hover .wii-btn-logo {
  transform: scale(1.08);
}

/* SD Card Button */
.wii-sd-button {
  background: none;
  border: none;
  outline: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--btn-circ-outer);
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease;
}

.wii-sd-button:hover {
  transform: scale(1.1);
}

.wii-sd-button-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--btn-circ-inner);
  display: flex;
  justify-content: center;
  align-items: center;
}

.wii-sd-icon {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 auto;
}

/* Center Disc Slot Glowing LED */
.wii-disc-slot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.wii-disc-slot {
  width: 180px;
  height: 8px;
  background: #252b33;
  border-radius: 4px;
  border: 1px solid #4f5863;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
}

.wii-disc-slot::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(62, 182, 234, 0.9) 50%, transparent 100%);
  animation: wiiDiscPulse 3.5s infinite ease-in-out;
}

@keyframes wiiDiscPulse {
  0%, 100% { opacity: 0.2; transform: scaleX(0.7); }
  50% { opacity: 0.95; transform: scaleX(1); }
}

/* Right Message Board button */
.wii-bottom-right {
  display: flex;
  align-items: center;
}

.wii-mail-icon {
  width: 44px;
  height: 44px;
  display: block;
  margin: 0 auto;
  transition: transform 0.2s ease;
}

.wii-circle-button:hover .wii-mail-icon {
  transform: scale(1.08);
}

/* Notification Active Dot Badge */
.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: #38c1f7;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 8px rgba(56, 193, 247, 0.85);
  display: none;
  font-size: 0.65rem;
  font-weight: 800;
  color: #ffffff;
  text-align: center;
  line-height: 13px;
  animation: badgePulse 2s infinite ease-in-out;
  box-sizing: border-box;
}

.notification-badge.active {
  display: block;
}

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

/* ==========================================================================
   Wii Notification Feedback Toast
   ========================================================================== */
.wii-toast {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: linear-gradient(135deg, #ffffff 0%, #f0f5fa 100%);
  border: 2px solid #3eb6ea;
  border-radius: 20px;
  padding: 14px 28px;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.25),
    0 0 16px rgba(62, 182, 234, 0.4);
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
  pointer-events: none;
}

body.dark-theme .wii-toast {
  background: linear-gradient(135deg, #1e252f 0%, #151a21 100%);
  border-color: #38c1f7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(56, 193, 247, 0.3);
}

.wii-toast.show {
  top: 30px;
  opacity: 1;
}

.toast-envelope-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-envelope-icon img {
  width: 100%;
  height: auto;
}

.toast-body {
  display: flex;
  flex-direction: column;
}

.toast-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1982b6;
  letter-spacing: 0.5px;
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a535e;
  margin-top: 2px;
}

body.dark-theme .toast-message {
  color: #c0c8d4;
}

/* ==========================================================================
   Wii Channel Fullscreen Splash & Preview Modal (Desktop Layout)
   ========================================================================== */
#wii-channel-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #111418;
  transform: scale(0.85);
  transition: opacity 0.35s cubic-bezier(0.2, 0.8, 0.25, 1), transform 0.35s cubic-bezier(0.2, 0.8, 0.25, 1);
  overflow: hidden;
  box-sizing: border-box;
}

#wii-channel-preview-modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.preview-tv-frame {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  border-top: 18px solid #383e46;
  border-bottom: 24px solid #383e46;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.85);
}

.preview-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Central Branding on Desktop: classic top margin & floating animation */
.preview-center-branding {
  position: relative;
  z-index: 15;
  margin-top: 7vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: floatBranding 3s infinite ease-in-out alternate;
}

@keyframes floatBranding {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.preview-logo {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.65));
}

.preview-title {
  margin-top: 18px;
  font-size: 2.8rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 1.5px;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.75);
}

.preview-subtitle {
  font-size: 1.2rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 6px;
  letter-spacing: 0.8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

/* Bottom Controls Bar on Desktop: generous padding and height */
.preview-controls-bar {
  position: relative;
  z-index: 50;
  width: 100%;
  height: 120px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 80px 24px 80px;
  box-sizing: border-box;
}

.wii-pill-button {
  min-width: 220px;
  height: 64px;
  border-radius: 36px;
  padding: 4px;
  box-shadow: 
    0 6px 18px rgba(0, 0, 0, 0.4),
    inset 0 2px 3px rgba(255, 255, 255, 0.9);
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.22s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.wii-pill-button:hover {
  transform: scale(1.06);
}

.wii-pill-button:active {
  transform: scale(0.96);
}

.wii-pill-button .pill-inner {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.wii-pill-button .btn-label {
  background: transparent !important;
}

.btn-back-wii {
  background: linear-gradient(180deg, #f0f3f6 0%, #c4cbd4 100%);
  border: 1px solid #9aa5b2;
}

.btn-back-wii:hover {
  box-shadow: 
    0 0 20px rgba(255, 255, 255, 0.8),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.btn-back-wii .pill-inner {
  width: 100%;
  height: 100%;
  border-radius: 32px;
  background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, #d5dce4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
}

.btn-back-wii .btn-label {
  font-size: 1.35rem;
  font-weight: 700;
  color: #4b5460;
  letter-spacing: 0.5px;
  background: transparent !important;
}

body.dark-theme .btn-back-wii {
  background: linear-gradient(180deg, #323d4c 0%, #1c242f 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 
    0 4px 14px rgba(0, 0, 0, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

body.dark-theme .btn-back-wii:hover {
  box-shadow: 
    0 0 20px rgba(62, 182, 234, 0.8),
    0 8px 24px rgba(0, 0, 0, 0.6);
  border-color: #3eb6ea;
}

body.dark-theme .btn-back-wii .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #3a4758 0%, #202a36 100%);
}

body.dark-theme .btn-back-wii .btn-label {
  color: #ecf2f8;
  background: transparent !important;
}

.btn-start-service {
  background: linear-gradient(180deg, #e6f6fd 0%, #76cef5 40%, #1a95cd 100%);
  border: 1px solid #3eb6ea;
  box-shadow: 
    0 6px 20px rgba(26, 149, 205, 0.45),
    inset 0 2px 4px rgba(255, 255, 255, 0.95);
}

.btn-start-service:hover {
  box-shadow: 
    0 0 26px rgba(62, 182, 234, 0.95),
    0 8px 28px rgba(0, 0, 0, 0.5);
}

.btn-start-service .pill-inner {
  width: 100%;
  height: 100%;
  border-radius: 32px;
  background: radial-gradient(ellipse at 50% 25%, #ffffff 0%, #e2f4fd 40%, #90d8f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 34px;
}

.btn-start-service .btn-label {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0b5982;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: transparent !important;
}

body.dark-theme .btn-start-service {
  background: linear-gradient(180deg, #1e3b4f 0%, #0d202e 100%);
  border: 1.5px solid #3eb6ea;
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.55),
    0 0 18px rgba(62, 182, 234, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

body.dark-theme .btn-start-service:hover {
  box-shadow: 
    0 0 30px rgba(62, 182, 234, 0.95),
    0 8px 28px rgba(0, 0, 0, 0.7);
  border-color: #55c7f7;
}

body.dark-theme .btn-start-service .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #25465e 0%, #12222e 100%);
}

body.dark-theme .btn-start-service .btn-label {
  color: #55c7f7;
  text-shadow: 0 0 14px rgba(62, 182, 234, 0.6);
  background: transparent !important;
}

/* ==========================================================================
   Mobile & Responsive Adaptations (Smartphones & Tablets)
   ========================================================================== */

/* 1. Touch Devices: Hide custom floating cursor & enable native touch interaction */
@media (hover: none) and (pointer: coarse) {
  #wii-cursor-wrapper {
    display: none !important;
  }
  * {
    cursor: auto !important;
  }
  .wii-channel, .wii-circle-button, .wii-sd-button, .wii-pill-button, .wii-theme-toggle {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
  }
}

/* 2. Portrait Smartphones (max-width: 768px) */
@media (max-width: 768px) {
  .wii-top-bar {
    padding: 12px 18px 6px 18px;
    justify-content: flex-end;
  }

  .wii-header-right {
    gap: 10px;
  }

  .wii-bottom-center {
    gap: 3px;
  }

  .wii-date-clock {
    gap: 8px;
  }

  .wii-date {
    font-size: 0.88rem;
  }

  .wii-clock {
    font-size: 1.45rem;
  }

  .wii-theme-toggle {
    width: 36px;
    height: 36px;
  }

  #theme-toggle-icon {
    width: 18px;
    height: 18px;
  }

  /* 2-Column Scrollable Grid for Mobile */
  .wii-grid-wrapper {
    padding: 8px 16px 105px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
  }

  .wii-channel-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    grid-auto-rows: minmax(118px, 132px);
    gap: 12px 14px;
    max-width: 100%;
    height: auto;
    max-height: none;
  }

  .wii-channel {
    min-height: 118px;
  }

  .wii-channel-inner::after {
    height: 45%;
  }

  .channel-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
  }

  .channel-title {
    font-size: 0.95rem;
  }

  .channel-subtitle {
    font-size: 0.7rem;
    margin-top: 1px;
  }

  /* Fixed Bottom Bar on Mobile */
  .wii-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 84px;
    padding: 0 18px env(safe-area-inset-bottom, 0px) 18px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
  }

  .wii-bottom-bar::before {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    border-radius: 28px 28px 0 0;
  }

  .wii-bottom-left {
    gap: 10px;
  }

  .wii-circle-button {
    width: 62px;
    height: 62px;
  }

  .wii-btn-logo {
    width: 44px;
  }

  .wii-sd-button {
    width: 36px;
    height: 36px;
  }

  .wii-sd-icon {
    width: 20px;
    height: 20px;
  }

  .wii-mail-icon {
    width: 36px;
    height: 36px;
  }

  .wii-disc-slot {
    width: 85px;
    height: 6px;
  }

  /* Preview Screen on Mobile: perfectly elevated above bottom bar */
  .preview-tv-frame {
    border-top: 10px solid #2e343c;
    border-bottom: 12px solid #2e343c;
  }

  .preview-center-branding {
    margin-top: 0;
    padding: 12px 16px 0 16px;
    flex: 1;
  }

  .preview-logo {
    width: 78px;
    height: 78px;
  }

  .preview-title {
    font-size: 1.85rem;
    margin-top: 8px;
  }

  .preview-subtitle {
    font-size: 0.95rem;
    margin-top: 2px;
  }

  .preview-controls-bar {
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    min-height: 70px;
    padding: 8px 16px max(24px, env(safe-area-inset-bottom, 24px)) 16px;
    margin-bottom: 10px;
    gap: 12px;
    z-index: 999;
  }

  .wii-pill-button {
    min-width: 0;
    width: 100%;
    height: 52px;
    flex: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer !important;
    z-index: 1000;
  }

  .btn-back-wii .btn-label,
  .btn-start-service .btn-label {
    font-size: 1.05rem;
  }
}

/* 3. Extra Small Screens (iPhone SE - max-width: 380px) */
@media (max-width: 380px) {
  .wii-top-bar {
    padding: 10px 14px 4px 14px;
  }

  .wii-date {
    font-size: 1rem;
  }

  .wii-clock {
    font-size: 1.5rem;
  }

  .wii-circle-button {
    width: 54px;
    height: 54px;
  }

  .wii-btn-logo {
    width: 38px;
  }

  .wii-disc-slot {
    width: 50px;
  }

  .wii-bottom-bar {
    padding: 0 10px 6px 10px;
  }

  .preview-logo {
    width: 68px;
    height: 68px;
  }

  .preview-title {
    font-size: 1.6rem;
  }

  .preview-controls-bar {
    padding: 6px 12px max(20px, env(safe-area-inset-bottom, 20px)) 12px;
  }

  .wii-pill-button {
    height: 48px;
  }

  .btn-back-wii .btn-label,
  .btn-start-service .btn-label {
    font-size: 0.95rem;
  }
}

/* 4. Landscape Smartphones (max-height: 500px) */
@media (orientation: landscape) and (max-height: 500px) {
  .wii-top-bar {
    padding: 6px 24px 4px 24px;
  }

  .wii-clock {
    font-size: 1.6rem;
  }

  .wii-date {
    font-size: 1.05rem;
  }

  .wii-grid-wrapper {
    padding: 4px 24px 74px 24px;
    overflow-y: auto;
  }

  .wii-channel-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    grid-auto-rows: minmax(80px, 92px);
    gap: 8px 12px;
    height: auto;
  }

  .channel-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 2px;
  }

  .channel-title {
    font-size: 0.85rem;
  }

  .channel-subtitle {
    font-size: 0.65rem;
  }

  .wii-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .wii-bottom-bar::before {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
  }

  .wii-circle-button {
    width: 52px;
    height: 52px;
  }

  .wii-btn-logo {
    width: 36px;
  }

  .wii-sd-button {
    width: 32px;
    height: 32px;
  }

  .wii-mail-icon {
    width: 30px;
    height: 30px;
  }

  .preview-center-branding {
    margin-top: 0;
    padding: 6px;
    flex: 1;
  }

  .preview-logo {
    width: 54px;
    height: 54px;
  }

  .preview-title {
    font-size: 1.6rem;
    margin-top: 4px;
  }

  .preview-subtitle {
    font-size: 0.9rem;
  }

  .preview-controls-bar {
    height: auto;
    padding: 6px 35px 8px 35px;
  }

  .wii-pill-button {
    height: 44px;
    min-width: 130px;
  }
}

/* ==========================================================================
   MII PROFILE BUTTON & LOGIN SYSTEM
   ========================================================================== */

.wii-profile-button {
  background: var(--btn-circ-outer);
  border: none;
  outline: none;
  border-radius: 20px;
  padding: 3px 12px 3px 4px;
  box-shadow: 
    0 3px 8px rgba(0, 0, 0, 0.16),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
  display: flex;
  align-items: center;
}

.wii-profile-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 14px rgba(62, 182, 234, 0.85);
}

.wii-profile-button:active {
  transform: scale(0.96);
}

.profile-button-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #3eb6ea;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.profile-user-name {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--wii-text-dark);
  letter-spacing: 0.5px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   WII LOGIN / MII SELECTOR MODAL
   ========================================================================== */

.wii-login-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.wii-login-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.login-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s ease;
}

body.dark-theme .login-modal-backdrop {
  background: rgba(10, 16, 24, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-theme-toggle {
  position: absolute;
  top: 14px;
  left: 18px;
  z-index: 10;
}

.login-music-toggle {
  position: absolute;
  top: 14px;
  left: 68px;
  z-index: 10;
}

.login-tv-frame {
  position: relative;
  width: 90%;
  max-width: 480px;
  background: linear-gradient(180deg, #fbfbfb 0%, #ececec 100%);
  border: 3px solid #ffffff;
  border-radius: 28px;
  padding: 28px 24px 24px 24px;
  box-shadow: 
    0 16px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              max-width 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.28s ease;
}

.login-tv-frame.stage-active-mode,
#wii-login-modal:has(#login-stage-active.active) .login-tv-frame {
  max-width: 680px;
  padding: 62px 26px 22px 26px;
}

body.dark-theme .login-tv-frame {
  background: linear-gradient(180deg, #252e39 0%, #171e27 100%);
  border-color: #384556;
  box-shadow: 
    0 16px 40px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 20px rgba(62, 182, 234, 0.2);
}

.wii-login-modal.active .login-tv-frame {
  transform: scale(1);
}

.login-close-x {
  top: 16px;
  right: 18px;
}

.login-header {
  text-align: center;
  margin-bottom: 18px;
}

.login-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #3eb6ea;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  margin: 0 0 4px 0;
}

.login-subtitle {
  font-size: 0.88rem;
  color: var(--wii-text-muted);
  margin: 0;
}

.login-stage {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
}

.login-stage.active {
  display: flex;
}

/* Stage 1: Manual Credentials Login Form */
.login-avatar-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

.login-form-avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #3eb6ea;
  box-shadow: 0 4px 14px rgba(62, 182, 234, 0.35);
  background: #f0f4f8;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.2s, box-shadow 0.2s;
}

body.dark-theme .login-form-avatar {
  background: #1b232e;
  border-color: #55c7f7;
  box-shadow: 0 4px 16px rgba(85, 199, 247, 0.4);
}

.wii-login-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wii-input-group {
  display: flex;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border: 2px solid #b2c0cc;
  border-radius: 28px;
  padding: 4px 12px 4px 16px;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.dark-theme .wii-input-group {
  background: #1b222a;
  border-color: #384556;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.wii-input-group:focus-within {
  border-color: #3eb6ea;
  box-shadow: 0 0 16px rgba(62, 182, 234, 0.6), inset 0 1px 2px rgba(0, 0, 0, 0.08);
  transform: scale(1.02);
}

body.dark-theme .wii-input-group:focus-within {
  border-color: #55c7f7;
  box-shadow: 0 0 16px rgba(85, 199, 247, 0.5), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.wii-input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3eb6ea;
  margin-right: 10px;
  flex-shrink: 0;
}

body.dark-theme .wii-input-icon {
  color: #55c7f7;
}

.wii-auth-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--wii-font) !important;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--wii-text-dark);
  padding: 10px 4px;
}

.wii-auth-input::placeholder {
  color: #8c9ba5;
  font-weight: 400;
  font-size: 0.95rem;
}

body.dark-theme .wii-auth-input::placeholder {
  color: #637588;
}

.btn-toggle-pwd {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: #7b8b98;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.15s, transform 0.15s;
}

.btn-toggle-pwd:hover {
  color: #3eb6ea;
  transform: scale(1.15);
}

body.dark-theme .btn-toggle-pwd:hover {
  color: #55c7f7;
}

.wii-pwd-hint {
  font-size: 0.82rem;
  color: #768593;
  margin-top: 8px;
  text-align: center;
  font-weight: 500;
}

body.dark-theme .wii-pwd-hint {
  color: #8f9ea8;
}

.login-error-msg {
  color: #ff4757;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 20px;
  margin-bottom: 8px;
  text-align: center;
}

.shake-anim {
  animation: wiiShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes wiiShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}

.login-controls-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-top: 10px;
}

.btn-login-back {
  min-width: 130px;
}

.btn-login-submit {
  background: linear-gradient(180deg, #e6f6fd 0%, #76cef5 40%, #1a95cd 100%);
  border: 1px solid #3eb6ea;
  box-shadow: 
    0 4px 14px rgba(26, 149, 205, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
  min-width: 130px;
}

.btn-login-submit:hover {
  box-shadow: 
    0 0 18px rgba(62, 182, 234, 0.9),
    0 6px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px) scale(1.03);
}

.btn-login-submit .pill-inner {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: radial-gradient(ellipse at 50% 25%, #ffffff 0%, #e2f4fd 40%, #90d8f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
}

body.dark-theme .btn-login-submit {
  background: linear-gradient(180deg, #3eb6ea 0%, #1a82b6 100%);
  border-color: #55c7f7;
  box-shadow: 0 4px 16px rgba(62, 182, 234, 0.45);
}

body.dark-theme .btn-login-submit .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #2488b7 0%, #0d5c88 100%);
}

.btn-login-submit .btn-label {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0b5982;
  letter-spacing: 0.5px;
  background: transparent !important;
}

body.dark-theme .btn-login-submit .btn-label {
  color: #ffffff;
  background: transparent !important;
}

#btn-login-submit.loading-state {
  opacity: 0.75;
  pointer-events: none;
  cursor: wait;
  transform: none !important;
}

#btn-login-submit.loading-state .pill-inner {
  animation: pulseSubmitting 1.2s infinite ease-in-out;
}

@keyframes pulseSubmitting {
  0%, 100% { opacity: 0.85; filter: brightness(1); }
  50% { opacity: 0.5; filter: brightness(0.9); }
}

/* Stage 3: Active User Options (Multi-Column Layout) */
#login-stage-active {
  width: 100%;
}

.active-profile-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

/* Columna Izquierda: Tarjeta Mii */
.active-profile-card {
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid #dce4ec;
  border-radius: 22px;
  padding: 18px 14px 16px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

body.dark-theme .active-profile-card {
  background: rgba(22, 30, 41, 0.8);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.active-user-avatar-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 8px;
}

.active-user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  aspect-ratio: 1/1;
  border: 3.5px solid #3eb6ea;
  box-shadow: 0 6px 16px rgba(62, 182, 234, 0.35);
  background: #f0f4f8;
  display: block;
}

body.dark-theme .active-user-avatar {
  background: #141b24;
  border-color: #55c7f7;
  box-shadow: 0 6px 16px rgba(85, 199, 247, 0.3);
}

.active-user-online-dot {
  position: absolute;
  bottom: 2px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2ed573;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 8px rgba(46, 213, 115, 0.7);
}

body.dark-theme .active-user-online-dot {
  border-color: #161e29;
}

.active-user-badge-wrap {
  margin-bottom: 6px;
}

.active-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.active-user-badge.badge-admin {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.25), rgba(255, 152, 0, 0.3));
  border: 1px solid #ff9800;
  color: #e65100;
}

body.dark-theme .active-user-badge.badge-admin {
  color: #ffb74d;
  border-color: #ffb74d;
}

.active-user-badge.badge-user {
  background: rgba(62, 182, 234, 0.12);
  border: 1px solid #3eb6ea;
  color: #0288d1;
}

body.dark-theme .active-user-badge.badge-user {
  background: rgba(85, 199, 247, 0.15);
  border-color: #55c7f7;
  color: #55c7f7;
}

.active-user-name {
  font-size: 1.22rem;
  font-weight: 800;
  margin: 0 0 2px 0;
  color: var(--wii-text-dark);
  word-break: break-word;
  line-height: 1.25;
}

.active-user-handle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--wii-text-muted);
  margin-bottom: 8px;
}

.active-user-services-box {
  width: 100%;
  margin: 6px 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(160, 175, 190, 0.3);
}

body.dark-theme .active-user-services-box {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.active-user-services-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--wii-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.active-user-services-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.active-svc-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  background: #ffffff;
  border: 1.2px solid #3eb6ea;
  color: #0288d1;
}

body.dark-theme .active-svc-pill {
  background: #19222d;
  border-color: #55c7f7;
  color: #55c7f7;
}

.active-svc-pill.none {
  border-color: #cbd5e1;
  color: var(--wii-text-muted);
  background: transparent;
  font-weight: 600;
}

.active-user-status {
  font-size: 0.76rem;
  color: #2ed573;
  font-weight: 700;
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.status-pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ed573;
  box-shadow: 0 0 6px #2ed573;
}

/* Columna Derecha: Panel de Ajustes y Acciones */
.active-user-settings-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.active-settings-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid rgba(160, 175, 190, 0.2);
}

body.dark-theme .active-settings-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.active-settings-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--wii-text-dark);
  margin: 0 0 3px 0;
  letter-spacing: 0.3px;
}

.active-settings-subtitle {
  font-size: 0.78rem;
  color: var(--wii-text-muted);
  font-weight: 600;
  margin: 0;
}

.active-user-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.active-user-actions-grid .wii-pill-button {
  width: 100%;
  height: 52px;
  min-width: unset;
  border-radius: 26px;
  padding: 3px;
  margin: 0;
}

.active-user-actions-grid .wii-pill-button .pill-inner {
  width: 100%;
  height: 100%;
  border-radius: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.active-user-actions-grid .btn-label {
  font-family: var(--wii-font) !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.2px;
  background: transparent !important;
  white-space: nowrap;
}

/* Authentic Wii theme button styling for profile actions */
.active-user-actions-grid .btn-active-action {
  background: linear-gradient(180deg, #f0f3f6 0%, #c4cbd4 100%);
  border: 1.5px solid #9aa5b2;
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.12),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.active-user-actions-grid .btn-active-action .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, #dbe2ea 100%);
}

.active-user-actions-grid .btn-active-action .btn-label {
  color: #2c3844 !important;
}

.active-user-actions-grid .btn-active-action:hover {
  box-shadow: 
    0 0 18px rgba(62, 182, 234, 0.8),
    0 6px 18px rgba(0, 0, 0, 0.22);
  border-color: #3eb6ea !important;
  transform: translateY(-2px) scale(1.02);
}

/* Dark theme active profile actions */
body.dark-theme .active-user-actions-grid .btn-active-action {
  background: linear-gradient(180deg, #323d4c 0%, #1c242f 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: 
    0 4px 14px rgba(0, 0, 0, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

body.dark-theme .active-user-actions-grid .btn-active-action .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #3a4758 0%, #202a36 100%);
}

body.dark-theme .active-user-actions-grid .btn-active-action .btn-label {
  color: #ecf2f8 !important;
}

body.dark-theme .active-user-actions-grid .btn-active-action:hover {
  box-shadow: 
    0 0 20px rgba(62, 182, 234, 0.85),
    0 6px 20px rgba(0, 0, 0, 0.6);
  border-color: #55c7f7 !important;
  transform: translateY(-2px) scale(1.02);
}

/* Admin button spans 2 columns with prestigious golden Wii accent */
.active-user-actions-grid .btn-action-admin {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 40%, #ff9800 100%) !important;
  border: 1.5px solid #ff9800 !important;
  box-shadow: 0 4px 14px rgba(255, 152, 0, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.95) !important;
}

.active-user-actions-grid .btn-action-admin .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #ffffff 0%, #fff8e1 40%, #ffe082 100%) !important;
}

.active-user-actions-grid .btn-action-admin .btn-label {
  color: #b26a00 !important;
  font-size: 0.95rem !important;
  font-weight: 800 !important;
}

.active-user-actions-grid .btn-action-admin:hover {
  box-shadow: 0 0 22px rgba(255, 152, 0, 0.85), 0 6px 18px rgba(0, 0, 0, 0.3) !important;
  border-color: #ffa726 !important;
  transform: translateY(-2px) scale(1.02);
}

body.dark-theme .active-user-actions-grid .btn-action-admin {
  background: linear-gradient(180deg, #ffb74d 0%, #f57c00 100%) !important;
  border: 1.5px solid #ffa726 !important;
  box-shadow: 0 4px 16px rgba(255, 183, 77, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.15) !important;
}

body.dark-theme .active-user-actions-grid .btn-action-admin .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #5a3003 0%, #2c1500 100%) !important;
}

body.dark-theme .active-user-actions-grid .btn-action-admin .btn-label {
  color: #ffe082 !important;
  font-size: 0.95rem !important;
  font-weight: 800 !important;
}

body.dark-theme .active-user-actions-grid .btn-action-admin:hover {
  box-shadow: 0 0 24px rgba(255, 183, 77, 0.85), 0 6px 20px rgba(0, 0, 0, 0.6) !important;
  border-color: #ffb74d !important;
  transform: translateY(-2px) scale(1.02);
}

/* Logout danger button */
.active-user-actions-grid .btn-logout {
  border-color: rgba(229, 57, 53, 0.4) !important;
}

.active-user-actions-grid .btn-logout .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, #ffebee 100%) !important;
}

.active-user-actions-grid .btn-logout .btn-label {
  color: #d32f2f !important;
}

.active-user-actions-grid .btn-logout:hover {
  box-shadow: 0 0 18px rgba(229, 57, 53, 0.6), 0 6px 18px rgba(0, 0, 0, 0.22) !important;
  border-color: #e53935 !important;
}

body.dark-theme .active-user-actions-grid .btn-logout {
  background: linear-gradient(180deg, #3d2328 0%, #241317 100%) !important;
  border: 1.5px solid rgba(255, 107, 129, 0.35) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.08) !important;
}

body.dark-theme .active-user-actions-grid .btn-logout .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #4a2930 0%, #261418 100%) !important;
}

body.dark-theme .active-user-actions-grid .btn-logout .btn-label {
  color: #ff6b81 !important;
}

body.dark-theme .active-user-actions-grid .btn-logout:hover {
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.75), 0 6px 20px rgba(0, 0, 0, 0.6) !important;
  border-color: #ff4757 !important;
}

/* Session info footer in active settings column */
.active-user-session-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(62, 182, 234, 0.08);
  border: 1px solid rgba(62, 182, 234, 0.2);
  margin-top: 8px;
}

body.dark-theme .active-user-session-info {
  background: rgba(85, 199, 247, 0.06);
  border-color: rgba(85, 199, 247, 0.15);
}

.session-info-icon {
  font-size: 0.88rem;
  line-height: 1;
}

.session-info-text {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--wii-text-muted);
  letter-spacing: 0.2px;
}


/* Stage 4: Avatar Customizer */
.avatar-picker-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 380px;
  margin-bottom: 14px;
}

.avatar-picker-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--wii-text-dark);
  margin: 0 0 10px 0;
}

.avatar-live-preview {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  aspect-ratio: 1/1;
  border: 3px solid #3eb6ea;
  box-shadow: 0 4px 14px rgba(62, 182, 234, 0.5);
  margin-bottom: 14px;
  background: #f0f4f8;
}

body.dark-theme .avatar-live-preview {
  background: #1b232e;
  border-color: #55c7f7;
}

.avatar-upload-row {
  margin-bottom: 12px;
}

.wii-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #e6f2fa 100%);
  border: 2px solid #3eb6ea;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: #0b5982;
  box-shadow: 0 3px 8px rgba(62, 182, 234, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

body.dark-theme .wii-upload-btn {
  background: linear-gradient(180deg, #2b3644 0%, #1f2732 100%);
  color: #55c7f7;
  border-color: #55c7f7;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.wii-upload-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 16px rgba(62, 182, 234, 0.7);
}

.avatar-url-group {
  display: flex;
  width: 100%;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
}

.btn-preview-url {
  min-width: 65px;
  height: 40px;
}

.btn-preview-url .pill-inner {
  padding: 0 14px;
}

@media (max-width: 600px) {
  .profile-user-name {
    display: none;
  }
  .wii-profile-button {
    padding: 3px;
    border-radius: 50%;
  }
  .mii-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .login-tv-frame {
    padding: 22px 14px 18px 14px;
    max-height: 90dvh;
    overflow-y: auto;
  }
}

/* ==========================================================================
   WII MESSAGE BOARD & NOTIFICATION FLYOUT (WINDOWS 11 STYLE)
   ========================================================================== */

.wii-messages-flyout,
.wii-messages-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.28s ease;
}

.wii-messages-flyout.active,
.wii-messages-modal.active {
  pointer-events: auto;
  visibility: visible;
}

/* Semi-transparent Backdrop for click-outside dismissal */
.messages-flyout-backdrop,
.messages-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

body.dark-theme .messages-flyout-backdrop,
body.dark-theme .messages-modal-backdrop {
  background: rgba(0, 0, 0, 0.26);
}

.wii-messages-flyout.active .messages-flyout-backdrop,
.wii-messages-modal.active .messages-modal-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Windows 11 style Flyout Frame anchored directly above the bottom-right mail button */
.messages-flyout-frame,
.messages-board-frame {
  position: fixed;
  bottom: 96px;
  right: 32px;
  width: 384px;
  max-width: calc(100vw - 40px);
  max-height: min(560px, calc(100dvh - 120px));
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(240, 244, 250, 0.94) 100%);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 22px;
  padding: 18px 18px 14px 18px;
  box-shadow: 
    0 18px 45px rgba(22, 36, 56, 0.26),
    0 4px 14px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  transform-origin: bottom right;
  transform: translateY(22px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), 
              opacity 0.22s ease,
              background 0.3s ease,
              border-color 0.3s ease;
}

body.dark-theme .messages-flyout-frame,
body.dark-theme .messages-board-frame {
  background: linear-gradient(180deg, rgba(32, 41, 54, 0.96) 0%, rgba(18, 24, 33, 0.96) 100%);
  border-color: rgba(62, 182, 234, 0.26);
  box-shadow: 
    0 22px 52px rgba(0, 0, 0, 0.72),
    0 0 26px rgba(62, 182, 234, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.wii-messages-flyout.active .messages-flyout-frame,
.wii-messages-modal.active .messages-board-frame {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.messages-close-x {
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
}

.messages-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  padding-right: 48px; /* Safe space to prevent overlapping with close button */
  border-bottom: 1.5px solid rgba(0, 0, 0, 0.06);
}

body.dark-theme .messages-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.messages-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messages-board-icon {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 4px rgba(62, 182, 234, 0.4));
}

.messages-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.messages-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #3eb6ea;
  margin: 0;
  line-height: 1.2;
}

.messages-count-pill {
  font-size: 0.7rem;
  font-weight: 800;
  color: #ffffff;
  background: #3eb6ea;
  padding: 1px 7px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(62, 182, 234, 0.4);
}

.messages-subtitle {
  font-size: 0.74rem;
  color: var(--wii-text-muted);
  margin: 2px 0 0 0;
}

.messages-clear-btn {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--wii-border-subtle);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--wii-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

body.dark-theme .messages-clear-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: #9ab0c4;
}

.messages-clear-btn:hover,
body.dark-theme .messages-clear-btn:hover {
  border-color: #ff4757 !important;
  color: #ffffff !important;
  background: #ff4757 !important;
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.4);
}

.messages-list-container {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 140px;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 6px 4px 2px;
  margin-bottom: 12px;
}

/* Custom Wii Scrollbar */
.messages-list-container::-webkit-scrollbar {
  width: 6px;
}
.messages-list-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  margin: 4px 0;
}
body.dark-theme .messages-list-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}
.messages-list-container::-webkit-scrollbar-thumb {
  background: rgba(62, 182, 234, 0.6);
  border-radius: 6px;
}
.messages-list-container::-webkit-scrollbar-thumb:hover {
  background: #3eb6ea;
}

/* Individual Wii Letter / Notice Card */
.wii-letter-card {
  flex-shrink: 0 !important;
  min-height: 60px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fa 100%);
  border: 1.5px solid #dce4eb;
  border-radius: 14px;
  padding: 11px 13px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  box-sizing: border-box;
}

body.dark-theme .wii-letter-card {
  background: linear-gradient(180deg, #283341 0%, #1a222c 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.wii-letter-card:hover {
  transform: translateY(-2px);
  border-color: #3eb6ea;
  box-shadow: 0 6px 16px rgba(62, 182, 234, 0.25);
}

body.dark-theme .wii-letter-card:hover {
  border-color: #55c7f7;
  box-shadow: 0 6px 18px rgba(62, 182, 234, 0.35), 0 0 14px rgba(85, 199, 247, 0.2);
}

/* Dismiss single notification button */
.letter-dismiss-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  color: var(--wii-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease, color 0.18s ease;
  z-index: 3;
}

.wii-letter-card:hover .letter-dismiss-btn {
  opacity: 1;
  transform: scale(1);
}

body.dark-theme .letter-dismiss-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #b0c2d4;
}

.letter-dismiss-btn:hover {
  background: #ff4757 !important;
  color: #ffffff !important;
  transform: scale(1.15) !important;
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

.letter-icon-wrapper {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(62, 182, 234, 0.12);
  border: 1.5px solid rgba(62, 182, 234, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

body.dark-theme .letter-icon-wrapper {
  background: rgba(85, 199, 247, 0.14);
  border-color: rgba(85, 199, 247, 0.28);
}

.letter-icon-wrapper img {
  width: 17px;
  height: 17px;
  object-fit: contain;
}

.letter-content {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 16px;
}

.letter-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
  gap: 6px;
}

.letter-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--wii-text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-theme .letter-title {
  color: #ecf2f8;
}

.letter-time {
  font-size: 0.72rem;
  color: #3eb6ea;
  font-weight: 700;
  flex-shrink: 0;
}

body.dark-theme .letter-time {
  color: #55c7f7;
}

.letter-body {
  font-size: 0.79rem;
  color: var(--wii-text-muted);
  line-height: 1.38;
  margin: 0;
  word-break: break-word;
}

body.dark-theme .letter-body {
  color: #b2c2d4;
}

.messages-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 10px;
  color: var(--wii-text-muted);
  text-align: center;
}

.messages-empty-icon {
  width: 42px;
  height: 42px;
  opacity: 0.35;
  margin-bottom: 8px;
}

.messages-empty-text {
  font-size: 0.88rem;
  font-weight: 600;
}

.messages-footer {
  display: flex;
  justify-content: center;
  width: 100%;
  padding-top: 4px;
}

.btn-messages-footer-btn {
  min-width: 120px;
  height: 38px;
  border-radius: 19px;
  padding: 2px;
}

.btn-messages-footer-btn .pill-inner {
  border-radius: 17px;
  padding: 0 20px;
}

.btn-messages-footer-btn .btn-label {
  font-size: 0.86rem;
  font-weight: 700;
}

body.dark-theme .btn-messages-footer-btn {
  background: linear-gradient(180deg, #323d4c 0%, #1c242f 100%) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.1) !important;
}

body.dark-theme .btn-messages-footer-btn .pill-inner {
  background: radial-gradient(ellipse at 50% 30%, #3a4758 0%, #202a36 100%) !important;
}

body.dark-theme .btn-messages-footer-btn .btn-label {
  color: #ecf2f8 !important;
}

body.dark-theme .btn-messages-footer-btn:hover {
  box-shadow: 0 0 18px rgba(62, 182, 234, 0.85), 0 4px 14px rgba(0, 0, 0, 0.5) !important;
  border-color: #55c7f7 !important;
  transform: translateY(-2px) scale(1.02);
}

/* ==========================================================================
   SERVICE BADGES & UNIFIED MII PROFILES
   ========================================================================== */

.mii-card-services {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.service-badge-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  background: transparent !important;
  color: #0288d1;
  border: 1px solid #3eb6ea;
}

body.dark-theme .service-badge-pill {
  background: transparent !important;
  color: #38c1f7;
  border-color: #55c7f7;
}

.service-badge-pill.unified {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.25), rgba(255, 112, 67, 0.25));
  color: #e65100;
  border-color: rgba(255, 152, 0, 0.5);
  animation: unifiedGlow 2.5s infinite ease-in-out;
}

body.dark-theme .service-badge-pill.unified {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.3), rgba(255, 112, 67, 0.3));
  color: #ffb74d;
  border-color: rgba(255, 152, 0, 0.6);
}

@keyframes unifiedGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 152, 0, 0.4); }
  50% { box-shadow: 0 0 10px rgba(255, 152, 0, 0.85); }
}

/* ==========================================================================
   INITIAL LOGIN GATE (SHOW BEFORE MENU)
   ========================================================================== */

body.menu-locked #wii-main-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.wii-login-modal.gate-mode {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  background: var(--wii-bg-radial) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.35s ease;
}

.wii-login-modal.gate-mode::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(to right, var(--wii-grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--wii-grid-color) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.wii-login-modal.gate-mode .login-modal-backdrop {
  display: none !important;
}

.wii-login-modal.gate-mode .login-close-x {
  display: none !important;
}

.wii-login-modal.gate-mode .login-tv-frame {
  position: relative;
  z-index: 1;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32), inset 0 2px 4px rgba(255, 255, 255, 0.95);
}

:root.dark-theme .wii-login-modal.gate-mode .login-tv-frame,
body.dark-theme .wii-login-modal.gate-mode .login-tv-frame {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 0 24px rgba(62, 182, 234, 0.25);
}

/* ==========================================================================
   WII ADMIN PANEL & USER MANAGEMENT
   ========================================================================== */

.wii-admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.wii-admin-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 24, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.admin-tv-frame {
  position: relative;
  width: 94%;
  max-width: 900px;
  max-height: 88vh;
  background: linear-gradient(180deg, #fbfbfb 0%, #edf1f5 100%);
  border: 3px solid #ffffff;
  border-radius: 28px;
  padding: 24px 28px;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

body.dark-theme .admin-tv-frame {
  background: linear-gradient(180deg, #1d2531 0%, #111720 100%);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Authentic Wii Circular Close Button with Smooth Rotation & Glow */
.wii-modal-close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  outline: none;
  background: linear-gradient(180deg, #ffffff 0%, #e6edf5 100%);
  border: 1.5px solid #cbd5e1;
  color: #64748b;
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.12),
    inset 0 1px 1px rgba(255, 255, 255, 0.95);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              box-shadow 0.25s ease, 
              color 0.18s ease, 
              border-color 0.18s ease,
              background 0.2s ease;
}

body.dark-theme .wii-modal-close-btn {
  background: linear-gradient(180deg, #283344 0%, #17212e 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  color: #94a3b8;
  box-shadow: 
    0 3px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

.wii-modal-close-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
  transition: transform 0.25s ease;
}

.wii-modal-close-btn:hover {
  transform: scale(1.14) rotate(90deg);
  border-color: #3eb6ea;
  color: #0288d1;
  box-shadow: 
    0 0 16px rgba(62, 182, 234, 0.8),
    0 4px 12px rgba(0, 0, 0, 0.25);
}

body.dark-theme .wii-modal-close-btn:hover {
  border-color: #55c7f7;
  color: #55c7f7;
  box-shadow: 
    0 0 18px rgba(85, 199, 247, 0.85),
    0 4px 14px rgba(0, 0, 0, 0.6);
}

.wii-modal-close-btn:active {
  transform: scale(0.92) rotate(90deg);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  padding-right: 58px; /* Safe space to prevent overlapping with close button */
  border-bottom: 1.5px solid rgba(160, 175, 190, 0.2);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.admin-header-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-header-badge {
  font-size: 2rem;
  filter: drop-shadow(0 2px 6px rgba(255, 183, 77, 0.4));
}

.admin-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--wii-text-dark);
  letter-spacing: 0.5px;
  margin: 0;
}

.admin-subtitle {
  font-size: 0.85rem;
  color: var(--wii-text-muted);
  font-weight: 600;
  margin: 2px 0 0 0;
}

.btn-admin-add-pill {
  min-width: 160px;
  height: 44px;
  border-radius: 22px;
  padding: 3px;
  background: linear-gradient(180deg, #e6f6fd 0%, #76cef5 40%, #1a95cd 100%);
  border: 1px solid #3eb6ea;
  box-shadow: 0 4px 12px rgba(26, 149, 205, 0.35);
}

.btn-admin-add-pill .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #ffffff 0%, #e2f4fd 40%, #90d8f7 100%);
  padding: 0 16px;
}

.btn-admin-add-pill .btn-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0b5982;
  background: transparent !important;
}

body.dark-theme .btn-admin-add-pill {
  background: linear-gradient(180deg, #3eb6ea 0%, #1a82b6 100%);
  border-color: #55c7f7;
}

body.dark-theme .btn-admin-add-pill .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #2284b2 0%, #0d5c88 100%);
}

body.dark-theme .btn-admin-add-pill .btn-label {
  color: #ffffff;
}

/* Toolbar & Search */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-search-group {
  position: relative;
  flex: 1;
  max-width: 450px;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #c8d3de;
  border-radius: 20px;
  padding: 6px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

body.dark-theme .admin-search-group {
  background: #161e28;
  border-color: rgba(255, 255, 255, 0.12);
}

.admin-search-group:focus-within {
  border-color: #3eb6ea;
  box-shadow: 0 0 10px rgba(62, 182, 234, 0.4);
}

.admin-search-icon {
  font-size: 0.95rem;
  margin-right: 8px;
  opacity: 0.7;
}

.admin-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--wii-font);
  font-size: 0.92rem;
  color: var(--wii-text-dark);
}

.admin-user-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--wii-text-muted);
}

/* Users List (2-Column Grid) */
.admin-users-list {
  flex: 1;
  overflow-y: auto;
  max-height: 54vh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-right: 6px;
  margin-bottom: 14px;
  min-width: 0;
}

.admin-user-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  border: 1.5px solid #dce4ec;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.18s ease, 
              box-shadow 0.18s ease;
  box-sizing: border-box;
  min-width: 0;
}

body.dark-theme .admin-user-card {
  background: #19222d;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.admin-user-card:hover {
  transform: translateY(-2px);
  border-color: #3eb6ea;
  box-shadow: 0 6px 18px rgba(62, 182, 234, 0.25);
}

body.dark-theme .admin-user-card:hover {
  border-color: #55c7f7;
  box-shadow: 0 6px 18px rgba(85, 199, 247, 0.2);
}

.admin-user-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.admin-user-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.admin-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  aspect-ratio: 1/1;
  border: 2px solid #3eb6ea;
  background: #ffffff;
  flex-shrink: 0;
}

body.dark-theme .admin-user-avatar {
  background: #141b24;
  border-color: #55c7f7;
}

.admin-user-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-user-display {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--wii-text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-you-badge {
  font-size: 0.72rem;
  color: #2ed573;
  font-weight: 700;
  margin-left: 4px;
}

.admin-user-handle {
  font-size: 0.76rem;
  color: var(--wii-text-muted);
  font-weight: 600;
}

.admin-user-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-user-mid {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid rgba(160, 175, 190, 0.18);
}

body.dark-theme .admin-user-mid {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.admin-service-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: transparent;
  border: 1.5px solid #3eb6ea;
  color: #0288d1;
}

body.dark-theme .admin-service-pill {
  border-color: #55c7f7;
  color: #55c7f7;
}

/* Admin Role Toggle Button */
.btn-toggle-admin-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1.5px solid #c8d3de;
  background: #f0f4f8;
  color: #6b7785;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-toggle-admin-role.active {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.25), rgba(255, 152, 0, 0.3));
  border-color: #ff9800;
  color: #e65100;
}

body.dark-theme .btn-toggle-admin-role {
  background: #141c26;
  border-color: rgba(255, 255, 255, 0.15);
  color: #8d9bb0;
}

body.dark-theme .btn-toggle-admin-role.active {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.25), rgba(255, 152, 0, 0.25));
  border-color: #ffa726;
  color: #ffb74d;
}

.btn-toggle-admin-role:hover {
  transform: scale(1.04);
}

/* Action Icons */
.btn-admin-action {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: transform 0.15s, background 0.15s;
}

.btn-admin-action:hover {
  transform: scale(1.2);
  background: rgba(62, 182, 234, 0.15);
}

.btn-admin-action.delete:hover {
  background: rgba(255, 71, 87, 0.15);
}

/* Footer */
.admin-footer {
  display: flex;
  justify-content: center;
  padding-top: 10px;
}

.admin-footer .wii-pill-button {
  min-width: 180px;
  height: 48px;
}

/* ==========================================================================
   ADMIN SUB-MODALS (Create/Edit & Confirm Delete)
   ========================================================================== */

.wii-admin-submodal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.wii-admin-submodal.active {
  opacity: 1;
  pointer-events: auto;
}

.submodal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 18, 0.65);
  backdrop-filter: blur(8px);
}

.submodal-frame {
  position: relative;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fbfbfb 0%, #edf1f5 100%);
  border: 3px solid #ffffff;
  border-radius: 26px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

body.dark-theme .submodal-frame {
  background: linear-gradient(180deg, #1f2734 0%, #121822 100%);
  border-color: rgba(255, 255, 255, 0.14);
}

.submodal-header {
  text-align: center;
  margin-bottom: 16px;
}

.submodal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--wii-text-dark);
}

.submodal-subtitle {
  font-size: 0.85rem;
  color: var(--wii-text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.editor-field-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.editor-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wii-text-dark);
}

.editor-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1.5px solid #c8d3de;
  background: #ffffff;
  font-family: var(--wii-font);
  font-size: 0.95rem;
  color: var(--wii-text-dark);
  outline: none;
  box-sizing: border-box;
}

body.dark-theme .editor-input {
  background: #151c26;
  border-color: rgba(255, 255, 255, 0.12);
}

.editor-input:focus {
  border-color: #3eb6ea;
  box-shadow: 0 0 8px rgba(62, 182, 234, 0.4);
}

.editor-hint {
  font-size: 0.75rem;
  color: var(--wii-text-muted);
}

.editor-services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.service-checkbox-card {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.service-checkbox-card input[type="checkbox"] {
  display: none;
}

.service-chk-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid #c8d3de;
  background: #ffffff;
  color: var(--wii-text-dark);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.18s ease;
}

body.dark-theme .service-chk-pill {
  background: #161e28;
  border-color: rgba(255, 255, 255, 0.12);
}

.service-checkbox-card input[type="checkbox"]:checked + .service-chk-pill {
  border-color: #3eb6ea;
  background: rgba(62, 182, 234, 0.12);
  color: #0288d1;
  font-weight: 700;
}

body.dark-theme .service-checkbox-card input[type="checkbox"]:checked + .service-chk-pill {
  background: rgba(62, 182, 234, 0.2);
  color: #55c7f7;
  border-color: #55c7f7;
}

/* Dynamic Jellyfin Libraries Group */
.jellyfin-libs-group {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(62, 182, 234, 0.06);
  border: 1.5px dashed rgba(62, 182, 234, 0.4);
  animation: fadeInDown 0.22s ease;
}

body.dark-theme .jellyfin-libs-group {
  background: rgba(62, 182, 234, 0.08);
  border-color: rgba(85, 199, 247, 0.35);
}

.editor-libs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.libs-toggle-all-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0288d1;
  background: rgba(62, 182, 234, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
  transition: all 0.16s ease;
}

body.dark-theme .libs-toggle-all-label {
  color: #55c7f7;
  background: rgba(62, 182, 234, 0.18);
}

.libs-toggle-all-label input[type="checkbox"] {
  accent-color: #0288d1;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.editor-libs-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.lib-checkbox-card {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.lib-checkbox-card input[type="checkbox"] {
  display: none;
}

.lib-chk-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #c8d3de;
  background: #ffffff;
  color: var(--wii-text-dark);
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.16s ease;
}

body.dark-theme .lib-chk-pill {
  background: #192432;
  border-color: rgba(255, 255, 255, 0.12);
}

.lib-checkbox-card input[type="checkbox"]:checked + .lib-chk-pill {
  border-color: #3eb6ea;
  background: rgba(62, 182, 234, 0.14);
  color: #0288d1;
  font-weight: 700;
}

body.dark-theme .lib-checkbox-card input[type="checkbox"]:checked + .lib-chk-pill {
  border-color: #55c7f7;
  background: rgba(62, 182, 234, 0.22);
  color: #55c7f7;
}

.lib-checkbox-card.disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Admin Role Checkbox Card */
.admin-perm-checkbox-card {
  display: flex;
  cursor: pointer;
}

.admin-perm-checkbox-card input[type="checkbox"] {
  display: none;
}

.admin-perm-content {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1.5px solid #c8d3de;
  background: #ffffff;
  transition: all 0.18s ease;
}

body.dark-theme .admin-perm-content {
  background: #161e28;
  border-color: rgba(255, 255, 255, 0.12);
}

.admin-perm-icon {
  font-size: 1.4rem;
}

.admin-perm-text {
  display: flex;
  flex-direction: column;
}

.admin-perm-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--wii-text-dark);
}

.admin-perm-desc {
  font-size: 0.75rem;
  color: var(--wii-text-muted);
}

.admin-perm-checkbox-card input[type="checkbox"]:checked + .admin-perm-content {
  border-color: #ff9800;
  background: rgba(255, 152, 0, 0.1);
}

.admin-perm-checkbox-card input[type="checkbox"]:checked + .admin-perm-content .admin-perm-title {
  color: #e65100;
}

body.dark-theme .admin-perm-checkbox-card input[type="checkbox"]:checked + .admin-perm-content .admin-perm-title {
  color: #ffb74d;
}

/* Editor Actions */
.editor-actions-bar {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.editor-actions-bar .wii-pill-button {
  min-width: 130px;
  height: 48px;
  border-radius: 26px;
  padding: 3px;
}

.editor-actions-bar .btn-label {
  font-size: 1rem !important;
  font-weight: 700 !important;
}

/* Delete confirmation modal */
.confirm-delete-frame {
  max-width: 420px;
  text-align: center;
  align-items: center;
}

.confirm-delete-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: wiiShake 0.6s ease;
}

.btn-danger-delete {
  background: linear-gradient(180deg, #ff7675 0%, #d63031 100%);
  border: 1px solid #d63031;
  box-shadow: 0 4px 14px rgba(214, 48, 49, 0.4);
}

.btn-danger-delete .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #ff7675 0%, #c0392b 100%);
}

.btn-danger-delete .btn-label {
  color: #ffffff;
  background: transparent !important;
}

/* ==========================================================================
   WII OPTIONS & SYSTEM SETTINGS MODAL (Authentic Nintendo Wii UI)
   ========================================================================== */
.wii-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.wii-settings-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings-tv-frame {
  position: relative;
  z-index: 2;
  width: 90%;
  max-width: 860px;
  max-height: 88vh;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, #fbfcfe 0%, #edf1f6 100%);
  border: 4px solid #ffffff;
  border-radius: 28px;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.35),
    inset 0 2px 4px rgba(255, 255, 255, 0.9),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  padding: 26px 32px;
  box-sizing: border-box;
  animation: wiiModalPop 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}

body.dark-theme .settings-tv-frame {
  background: radial-gradient(circle at 50% 30%, #222933 0%, #151a22 100%);
  border-color: #313a46;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.7),
    inset 0 1px 3px rgba(255, 255, 255, 0.1),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.settings-close-x {
  top: 18px;
  right: 22px;
}

/* Header */
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  padding-right: 58px; /* Safe space to prevent overlapping with close button */
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

body.dark-theme .settings-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.settings-header-title-box {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-header-logo-container {
  width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-wii-logo {
  width: 100%;
  height: auto;
  user-select: none;
}

.settings-logo-light {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.9));
}

.settings-logo-dark {
  display: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 6px rgba(62, 182, 234, 0.4));
}

body.dark-theme .settings-logo-light {
  display: none;
}

body.dark-theme .settings-logo-dark {
  display: block;
}

.settings-title {
  font-family: 'WiiFont', 'Continuum Medium', 'Helvetica Neue', sans-serif;
  font-size: 1.45rem;
  letter-spacing: 1px;
  color: #2c3e50;
  margin: 0 0 4px 0;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

body.dark-theme .settings-title {
  color: #edf2f7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.settings-subtitle {
  font-size: 0.85rem;
  color: #7f8c8d;
  margin: 0;
}

body.dark-theme .settings-subtitle {
  color: #a0aec0;
}

.settings-version-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #3eb6ea;
  background: rgba(62, 182, 234, 0.12);
  border: 1px solid rgba(62, 182, 234, 0.35);
  border-radius: 16px;
  padding: 4px 14px;
  letter-spacing: 0.5px;
}

/* Grid layout */
.settings-content-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .settings-content-grid {
    grid-template-columns: 1fr;
  }
}

.settings-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

body.dark-theme .settings-card {
  background: #1c222c;
  border-color: #2e3846;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 14px;
}

body.dark-theme .settings-card-header {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

.settings-card-icon {
  font-size: 1.25rem;
}

.settings-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2d3748;
  margin: 0;
}

body.dark-theme .settings-card-title {
  color: #edf2f7;
}

.settings-items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}

body.dark-theme .settings-item {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 12px;
}

.settings-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #2d3748;
}

body.dark-theme .settings-item-title {
  color: #e2e8f0;
}

.settings-item-desc {
  font-size: 0.75rem;
  color: #718096;
}

body.dark-theme .settings-item-desc {
  color: #a0aec0;
}

/* Button groups */
.settings-theme-buttons,
.settings-bgm-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.settings-choice-btn,
.settings-bgm-choice-btn {
  background: #edf2f7;
  border: 1.5px solid #cbd5e0;
  border-radius: 12px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
  white-space: nowrap;
}

.settings-choice-btn:hover,
.settings-bgm-choice-btn:hover {
  transform: translateY(-1px);
  border-color: #3eb6ea;
  color: #3eb6ea;
}

.settings-choice-btn.active,
.settings-bgm-choice-btn.active {
  background: linear-gradient(135deg, #3eb6ea 0%, #0096e6 100%);
  color: #ffffff !important;
  border-color: #0080c6;
  box-shadow: 0 2px 8px rgba(62, 182, 234, 0.4);
}

body.dark-theme .settings-choice-btn,
body.dark-theme .settings-bgm-choice-btn {
  background: #28313e;
  border-color: #3d495a;
  color: #cbd5e0;
}

body.dark-theme .settings-choice-btn.active,
body.dark-theme .settings-bgm-choice-btn.active {
  background: linear-gradient(135deg, #3eb6ea 0%, #0096e6 100%);
  color: #ffffff !important;
  border-color: #0080c6;
}

/* Volume Slider */
.settings-volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wii-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 105px;
  height: 6px;
  border-radius: 3px;
  background: #cbd5e0;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

body.dark-theme .wii-range-slider {
  background: #3d495a;
}

.wii-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3eb6ea;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.wii-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.settings-volume-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: #3eb6ea;
  min-width: 34px;
  text-align: right;
}

/* Wii Toggle Switch */
.wii-switch-label {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 25px;
  flex-shrink: 0;
}

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

.wii-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e0;
  border-radius: 25px;
  transition: 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.dark-theme .wii-switch-slider {
  background-color: #3d495a;
}

.wii-switch-slider::before {
  position: absolute;
  content: "";
  height: 19px;
  width: 19px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.wii-switch-label input:checked + .wii-switch-slider {
  background-color: #3eb6ea;
}

.wii-switch-label input:checked + .wii-switch-slider::before {
  transform: translateX(23px);
}

/* Card 2: Homelab Services Status */
.settings-services-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.service-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 12px;
}

body.dark-theme .service-status-row {
  background: #161c24;
  border-color: #27303d;
}

.service-status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-status-icon {
  font-size: 1.1rem;
}

.service-status-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #2d3748;
}

body.dark-theme .service-status-name {
  color: #edf2f7;
}

.service-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
}

.service-status-badge.online {
  background: rgba(46, 213, 115, 0.14);
  color: #2ed573;
}

.service-status-badge.offline {
  background: rgba(235, 77, 75, 0.14);
  color: #eb4d4b;
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Server Info Box */
.settings-server-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.78rem;
}

body.dark-theme .settings-server-info {
  background: #141920;
  border-color: #252e3b;
}

.server-info-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  color: #718096;
}

body.dark-theme .info-label {
  color: #a0aec0;
}

.info-value {
  font-weight: 600;
  color: #2d3748;
  font-family: monospace;
}

body.dark-theme .info-value {
  color: #e2e8f0;
}

/* Admin shortcut */
.settings-admin-box {
  margin-top: 6px;
}

.btn-settings-admin {
  width: 100%;
  height: 42px;
  border-radius: 21px;
  padding: 3px;
  background: linear-gradient(180deg, #ffd32a 0%, #ffa801 100%);
  border: 1px solid #f39c12;
  box-shadow: 0 3px 10px rgba(243, 156, 18, 0.35);
}

.btn-settings-admin .pill-inner {
  background: radial-gradient(ellipse at 50% 25%, #ffeaa7 0%, #f39c12 100%);
}

.btn-settings-admin .btn-label {
  color: #2c3e50;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  background: transparent !important;
}

/* Settings Footer */
.settings-footer {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.settings-footer .btn-back-wii {
  min-width: 190px;
  height: 48px;
}

/* ==========================================================================
   MOBILE & PHONE OPTIMIZATIONS (Smartphones, iOS, Android)
   ========================================================================== */
@media (max-width: 768px) {
  .admin-users-list {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 680px) {
  /* Active Profile Multi-Column on Mobile */
  .login-tv-frame.stage-active-mode,
  #wii-login-modal:has(#login-stage-active.active) .login-tv-frame {
    width: calc(100% - 20px) !important;
    max-width: 440px !important;
    padding: 60px 14px 16px 14px !important;
    max-height: 90dvh !important;
    overflow-y: auto !important;
    border-radius: 22px !important;
    box-sizing: border-box !important;
  }

  .active-profile-layout {
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .active-profile-card {
    flex: none !important;
    width: 100% !important;
    padding: 12px 10px !important;
    border-radius: 18px !important;
    box-sizing: border-box !important;
  }

  .active-user-avatar-wrap {
    width: 72px !important;
    height: 72px !important;
    margin-bottom: 6px !important;
  }

  .active-user-name {
    font-size: 1.15rem !important;
  }

  .active-user-handle {
    font-size: 0.75rem !important;
    margin-bottom: 6px !important;
  }

  .active-user-services-box {
    margin: 4px 0 !important;
    padding-top: 6px !important;
  }

  .active-user-services-pills {
    gap: 4px !important;
  }

  .active-svc-pill {
    font-size: 0.68rem !important;
    padding: 2px 7px !important;
  }

  .active-user-status {
    font-size: 0.72rem !important;
    padding-top: 6px !important;
  }

  .active-settings-header {
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
    text-align: center !important;
  }

  .active-settings-title {
    font-size: 1.05rem !important;
  }

  .active-settings-subtitle {
    font-size: 0.74rem !important;
  }

  .active-user-actions-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .active-user-actions-grid .wii-pill-button {
    height: 48px !important;
    padding: 2px !important;
    min-width: 0 !important;
  }

  .active-user-actions-grid .wii-pill-button .pill-inner {
    padding: 0 6px !important;
  }

  .active-user-actions-grid .btn-label {
    font-size: 0.78rem !important;
    letter-spacing: -0.1px !important;
    white-space: normal !important;
    line-height: 1.15 !important;
    text-align: center !important;
  }

  .active-user-actions-grid .btn-action-admin {
    grid-column: 1 / -1 !important;
  }

  .active-user-session-info {
    margin-top: 6px !important;
    padding: 6px 10px !important;
  }

  .session-info-text {
    font-size: 0.7rem !important;
  }

  /* Admin Modal on Mobile */
  .admin-tv-frame {
    width: 96% !important;
    padding: 18px 14px !important;
    max-height: 94vh !important;
    border-radius: 20px !important;
  }

  .admin-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding-right: 48px !important;
  }

  .admin-header-title-box {
    gap: 10px !important;
  }

  .admin-title {
    font-size: 1.15rem !important;
  }

  .admin-subtitle {
    font-size: 0.76rem !important;
  }

  .btn-admin-add-pill {
    width: 100% !important;
    min-width: 0 !important;
    height: 40px !important;
  }

  .admin-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .admin-search-box {
    width: 100% !important;
  }

  .admin-user-count {
    text-align: right;
    font-size: 0.78rem;
  }

  .admin-users-list {
    grid-template-columns: 1fr !important;
    max-height: 52vh !important;
    gap: 8px !important;
    padding-right: 4px !important;
  }

  .admin-user-card {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 12px 14px !important;
    gap: 8px !important;
  }

  .admin-user-top-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .admin-user-left {
    width: 100% !important;
    justify-content: flex-start;
  }

  .admin-user-mid {
    padding-left: 0 !important;
    width: 100% !important;
    gap: 5px !important;
  }

  .admin-user-right {
    width: 100% !important;
    justify-content: flex-end;
    gap: 8px !important;
  }

  /* Settings Modal on Mobile */
  .settings-tv-frame {
    width: 96% !important;
    padding: 18px 14px !important;
    max-height: 94vh !important;
    border-radius: 20px !important;
  }

  .settings-header {
    padding-right: 48px !important;
  }

  .settings-title {
    font-size: 1.15rem !important;
  }

  .settings-subtitle {
    font-size: 0.75rem !important;
  }

  .settings-version-badge {
    font-size: 0.72rem !important;
    padding: 2px 10px !important;
  }

  .settings-content-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    margin-top: 14px !important;
  }

  .settings-card {
    padding: 14px 12px !important;
    border-radius: 16px !important;
  }

  .settings-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .settings-theme-buttons,
  .settings-bgm-buttons {
    width: 100% !important;
    display: flex !important;
    gap: 6px !important;
  }

  .settings-choice-btn,
  .settings-bgm-choice-btn {
    flex: 1 !important;
    text-align: center !important;
    padding: 8px 4px !important;
    font-size: 0.76rem !important;
  }

  .settings-volume-row {
    width: 100% !important;
  }

  /* User Editor Modal on Mobile */
  .submodal-box {
    width: 96% !important;
    max-width: 96% !important;
    padding: 18px 14px !important;
    max-height: 92vh !important;
    border-radius: 20px !important;
  }

  .editor-services-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .editor-actions-bar {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .editor-actions-bar .wii-pill-button {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Messages Flyout on Mobile */
  .messages-flyout-frame,
  .messages-board-frame {
    bottom: 80px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 78dvh !important;
    border-radius: 20px !important;
    padding: 16px 14px 12px 14px !important;
    transform-origin: bottom center !important;
  }

  .messages-header {
    padding-right: 48px !important;
  }

  .messages-list-container {
    max-height: calc(78dvh - 125px) !important;
  }

  /* Preview Screen Controls Bar on Mobile */
  .preview-controls-bar {
    padding: 0 20px 24px 20px !important;
    gap: 12px !important;
  }

  .preview-controls-bar .wii-pill-button {
    min-width: 140px !important;
    height: 52px !important;
  }

  .preview-title {
    font-size: 2.2rem !important;
  }

  .preview-subtitle {
    font-size: 0.95rem !important;
    padding: 0 16px;
    text-align: center;
  }
}

@media (max-width: 440px) {
  .active-user-actions-grid {
    grid-template-columns: 1fr !important;
    gap: 7px !important;
  }
  .active-user-actions-grid .wii-pill-button {
    height: 46px !important;
  }
  .active-user-actions-grid .btn-label {
    font-size: 0.85rem !important;
    white-space: nowrap !important;
  }
}

