/* Eroi in Viaggio - Main Theme Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Julius+Sans+One&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Tokens */
  --bg-deep: #060913;
  --bg-dark: #0d1326;
  --bg-panel: rgba(13, 19, 38, 0.85);
  --gold: #d4af37;
  --gold-glow: rgba(212, 175, 55, 0.4);
  --gold-dark: #aa8412;
  --bronze: #cd7f32;
  --silver: #c0c0c0;
  --text-light: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #1f2937;
  --parchment: #f4edd4;
  --parchment-border: #d4c8a8;
  --danger: #ef4444;
  --success: #10b981;
  --common: #9ca3af;
  --rare: #3b82f6;
  --epic: #a855f7;
  --legendary: #eab308;
  
  /* Fonts */
  --font-heading: 'Julius Sans One', sans-serif;
  --font-body: 'Julius Sans One', sans-serif;
  
  /* Layout */
  --sidebar-width: 260px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Julius Sans One', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  font-family: 'Julius Sans One', sans-serif;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg-deep);
  color: var(--text-light);
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(212, 175, 55, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* Locked Card Style for Inventory */
.card.card-locked {
  opacity: 0.55;
  filter: grayscale(60%);
  border: 1.5px dashed rgba(212, 175, 55, 0.35) !important;
  background: rgba(0, 0, 0, 0.3) !important;
}
.card.card-locked .card-title {
  color: #94a3b8 !important;
}
.card.card-locked:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* View Map Container */
#view-map .glass-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-bottom: 20px;
}

/* ==========================================================================
   UNIFIED DASHBOARD STYLES (STILE PALESTRA DI RIFLESSIONE)
   ========================================================================== */
#view-teacher-dashboard, #view-admin-dashboard {
  background: #f8fafc !important;
  color: #1e293b !important;
  border-radius: 24px !important;
  padding: 1rem 2rem 2rem 2rem !important;
  margin: 0 !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06) !important;
}

/* Blocchi visibili solo all'admin: nascosti di default via CSS.
   JS li rivela solo se l'utente è admin (più robusto degli inline style) */
[data-admin-only="true"] {
  display: none !important;
}

#view-teacher-dashboard .glass-panel, #view-admin-dashboard .glass-panel {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid #e8ecf0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 20px 0 !important;
  margin-bottom: 0 !important;
  color: #1e293b !important;
}

#view-teacher-dashboard .glass-panel:last-child,
#view-admin-dashboard .glass-panel:last-child {
  border-bottom: none !important;
}

#view-teacher-dashboard .stat-card-interactive, 
#view-admin-dashboard .admin-stat-card,
.stat-card-interactive, .admin-stat-card {
  background: #ffffff !important;
  border-radius: 20px !important;
  padding: 1.2rem !important;
  text-align: center !important;
  border: 2px solid transparent !important;
  cursor: pointer !important;
  transition: all 0.25s ease !important;
  box-shadow: 0 10px 20px rgba(0,0,0,0.04) !important;
}

#view-teacher-dashboard .stat-card-interactive:hover,
#view-admin-dashboard .admin-stat-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 15px 30px rgba(0,0,0,0.08) !important;
  border-color: #cbd5e1 !important;
}

#view-teacher-dashboard .stat-card-interactive.active,
#view-admin-dashboard .admin-stat-card.active {
  border-color: var(--gold) !important;
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.18) !important;
  transform: translateY(-3px) !important;
}

#view-teacher-dashboard .stat-card-interactive h4,
#view-admin-dashboard .admin-stat-card h4 {
  color: var(--gold) !important;
  font-weight: 900 !important;
}

#view-teacher-dashboard .stat-card-interactive span,
#view-admin-dashboard .admin-stat-card span {
  color: #64748b !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
}

/* Titoli e testi leggibili sul dashboard chiaro */
#view-teacher-dashboard h3.panel-title,
#view-admin-dashboard h3.panel-title {
  color: #0f172a !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  margin-bottom: 12px !important;
  padding-bottom: 8px !important;
}

#view-teacher-dashboard .panel-title i,
#view-admin-dashboard .panel-title i {
  color: var(--gold) !important;
}

#view-teacher-dashboard label,
#view-admin-dashboard label {
  color: #374151 !important;
}

#view-teacher-dashboard .form-control,
#view-admin-dashboard .form-control {
  color: #1e293b !important;
  background: #f8fafc !important;
  border-color: #d1d5db !important;
}


/* Layout SPA Wrapper */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* OCCUPA SEMPRE TUTTO LO SCHERMO */
  background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
  color: var(--text-light);
  font-family: 'Cinzel', serif;
  /* IMPORTANTE: Allinea in alto per evitare spazi vuoti su schermi alti */
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0a0d18 0%, #04060c 100%);
  border-right: 3px double var(--gold-dark);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 5px 0 30px rgba(0, 0, 0, 0.85), inset -1px 0 0 rgba(212, 175, 55, 0.15);
}

.logo-container {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.logo-shield {
  font-size: 1.8rem;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  margin-bottom: 8px;
  animation: float-logo 4s ease-in-out infinite;
}

@keyframes float-logo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-container h1 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  letter-spacing: 1.5px;
}

.logo-container p {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-top: 4px;
}

/* RPG Player Card / Character Frame in Sidebar */
.sidebar-player-card {
  margin-bottom: 20px;
  padding: 2px;
  background: linear-gradient(135deg, var(--gold-dark) 0%, rgba(212,175,55,0.2) 50%, var(--gold-dark) 100%);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.sidebar-student-card {
  background: #0d1222;
  padding: 10px 8px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.sidebar-avatar-wrapper {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px var(--gold-glow);
}

.sidebar-avatar-emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.sidebar-card-info {
  flex: 1;
  min-width: 0;
}

.sidebar-card-name {
  font-family: var(--font-heading);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-card-level-title {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 500;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-card-level-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.level-num {
  font-weight: bold;
  color: var(--text-light);
}

.sidebar-xp-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.sidebar-xp-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold) 100%);
  box-shadow: 0 0 6px var(--gold-glow);
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.sidebar-dracme {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 5px;
  font-weight: 500;
}

.sidebar-dracme i.gold-coin {
  color: #f59e0b;
  filter: drop-shadow(0 0 2px rgba(245,158,11,0.5));
  animation: spin-coin 8s linear infinite;
}

@keyframes spin-coin {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

/* Master Card Style */
.sidebar-master-card {
  background: linear-gradient(135deg, #161e38 0%, #080c18 100%);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: inset 0 0 8px rgba(212, 175, 55, 0.15);
}

.master-icon-wrapper {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1rem;
  box-shadow: 0 0 6px var(--gold-glow);
}

.master-info {
  flex: 1;
  min-width: 0;
}

.master-name {
  font-family: var(--font-heading);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.master-title {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: bold;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.menu-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  font-weight: 600;
  border-left: 3px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  transition: var(--transition-smooth);
}

.menu-link i {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  color: var(--gold-dark);
  transition: var(--transition-smooth);
}

.menu-link:hover, .menu-link.active {
  color: var(--text-light);
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.12) 0%, rgba(212, 175, 55, 0.02) 100%);
  border-left-color: var(--gold);
  border-top-color: rgba(212, 175, 55, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.menu-link:hover i, .menu-link.active i {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
  transform: scale(1.1);
}

.user-badge {
  background: rgba(13, 19, 38, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.2);
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.user-badge-info {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.user-badge-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge-role {
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-logout-small {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 8px 16px;
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}

.btn-logout-small:hover {
  transform: scale(1.15);
  text-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

.main-content {
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
  overflow: hidden;       /* Il contenuto principale NON scrolla, scrollano le view */
  height: 100dvh;
  flex: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

body.logged-in .main-content {
  margin-top: 70px;       /* sotto l'header fisso */
  height: calc(100dvh - 70px - 64px);
}

/* View Terminal Footer (Opzione 2: in coda allo scroll naturale di ciascuna vista) */
.view-footer-copyright {
  margin-top: 35px;
  padding: 14px 0 18px 0;
  border-top: 1px solid rgba(212, 175, 55, 0.18);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.view-footer-copyright .footer-copy {
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-muted);
  opacity: 0.9;
  flex: 1;
  text-align: justify;
  margin: 0;
}

.patamu-footer-badge {
  height: 52px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0px 0px 8px rgba(255, 255, 255, 0.3));
  margin: 0;
}

/* SPA Views */
.view {
  display: none;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
  flex: 1;
  min-height: 0;
  padding: 0 30px 20px 30px;
  box-sizing: border-box;
  overflow: visible; /* ogni view è nel flusso scroll del main-content */
}

.view.active {
  display: flex;
}

.view > .glass-panel > p {
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
  margin-bottom: 12px !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Panels */
.glass-panel {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin-bottom: 24px;
}

/* Titles */
h2.section-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
  margin-top: 0;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--gold-dark);
  padding-bottom: 8px;
}

h3.panel-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 100%);
  color: var(--bg-deep);
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--gold-glow);
  filter: brightness(1.1);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  background: var(--common);
  color: rgba(255, 255, 255, 0.5);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  box-shadow: none;
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.1);
  color: var(--text-light);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-light);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
  background: #dc2626;
}

/* Form inputs */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
  background: rgba(255, 255, 255, 0.08);
}

/* Login View Styling */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 120px);
  width: 100%;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dark) 50%, var(--gold) 100%);
}

.login-header h2 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 2rem;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Student Dashboard View */
.student-header {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.student-avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: 0 0 15px var(--gold-glow);
}

.student-name-level h3 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
}

.student-name-level p {
  color: var(--text-muted);
  font-size: 1rem;
}

.student-currency {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.dracme-count {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dracme-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Progress and Stats */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-content: start;
  align-items: start;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 10px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.stat-value {
  font-weight: bold;
  color: var(--gold);
}

.progress-container {
  margin-bottom: 20px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-bar-bg {
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold) 100%);
  border-radius: 6px;
  transition: width 0.8s ease-out;
  box-shadow: 0 0 10px var(--gold-glow);
}

/* Cards (Unified Glass Card) */
.admin-stat-card {
  position: relative;
  cursor: pointer;
}
.admin-stat-card::after {
  content: attr(data-title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(13, 19, 38, 0.95);
  color: var(--gold);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
  border: 1px solid var(--gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  margin-bottom: 5px;
}
.admin-stat-card:hover::after,
.admin-stat-card:active::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.card {
  background: rgba(13, 19, 38, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  max-width: 380px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
  transition: var(--transition-smooth);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: auto;
  max-width: 320px;
  margin: 0 auto;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  border-color: var(--gold);
}

/* Card Rarity Borders */
.card.rarity-comune { border-left: 4px solid var(--common); }
.card.rarity-raro { border-left: 4px solid var(--rare); }
.card.rarity-epico { border-left: 4px solid var(--epic); }
.card.rarity-leggendario { border-left: 4px solid var(--legendary); }

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-grow: 1;
}

.card-meta {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.card-rarity-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 10px;
  align-self: center;
}

.rarity-comune .card-rarity-badge { background: rgba(156, 163, 175, 0.2); color: var(--common); }
.rarity-raro .card-rarity-badge { background: rgba(59, 130, 246, 0.2); color: var(--rare); }
.rarity-epico .card-rarity-badge { background: rgba(168, 85, 247, 0.2); color: var(--epic); }
.rarity-leggendario .card-rarity-badge { background: rgba(234, 179, 8, 0.2); color: var(--legendary); }

/* Interactive Map SVG Wrapper */
.map-viewport {
  position: relative;
  width: 100%;
  max-width: min(1000px, calc(72vh * 900 / 550));
  aspect-ratio: 900 / 550; /* Forza il contenitore a mantenere le proporzioni dell'SVG ed evitare il collasso dell'altezza */
  margin: 0 auto;
  border: 3px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  background-color: #1a1510; /* Color pergamena bruciata di sfondo */
}

/* Stili specifici per la mappa a schermo intero senza scroll */
#view-map {
  padding: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  display: none;
}

#view-map.active {
  display: flex !important;
}

#view-map .glass-panel {
  padding: 0 40px 30px 40px !important; /* Gap in basso per non toccare la linea */
  margin-bottom: 20px !important;
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
  background: rgba(13, 19, 38, 0.4) !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

#view-map .section-title {
  margin-top: 0;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 10px;
}

#view-map p {
  margin-top: 0;
  margin-bottom: 16px;
  padding: 0;
}

#view-map .map-viewport {
  flex-grow: 1;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: none !important;
  border-top: none !important;
  background-color: #1a1510;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#view-map .map-svg-overlay {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  max-width: 100% !important;
}

/* Background image of the map (fantasy map style) */
.map-bg {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0.6;
}

.map-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

.map-node {
  cursor: pointer;
  transition: var(--transition-smooth);
}

.map-node circle {
  fill: #110903;
  stroke: var(--gold-dark);
  stroke-width: 2.5;
  transition: var(--transition-smooth);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.map-node:hover circle {
  stroke: var(--gold);
  fill: #1e1106;
  filter: drop-shadow(0 0 12px var(--gold)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}

.map-node text {
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: bold;
  fill: var(--text-light);
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 5px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.5px;
  transition: var(--transition-smooth);
}

.map-node:hover text {
  fill: var(--gold);
}

.map-node-emoji {
  font-size: 42px !important;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

.map-node.locked {
  cursor: not-allowed;
  opacity: 0.45;
}

.map-node.locked circle {
  stroke: #374151 !important;
  fill: #1f2937 !important;
  filter: none !important;
}

.map-node.locked:hover circle {
  filter: none !important;
}

.map-node.locked text {
  fill: #9ca3af;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.map-path {
  fill: none;
  stroke: var(--gold-dark);
  stroke-width: 1.5;
  stroke-dasharray: 5, 5;
  opacity: 0.4;
  transition: var(--transition-smooth);
}

.map-path.unlocked {
  stroke: var(--gold);
  stroke-width: 2.5;
  stroke-dasharray: none;
  opacity: 0.9;
  filter: drop-shadow(0 0 3px var(--gold));
}

/* Study Guides Layout */
#view-guides {
  overflow: hidden;
  max-height: 100%;
  flex-direction: column;
}

#view-guides.active {
  display: flex;
}

#view-guides {
  overflow: hidden;
  padding: 15px; /* Riduco padding per fare spazio */
}

#view-guides > div {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#view-diario {
  overflow: hidden;
  padding: 15px;
}

#view-diario > .glass-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#view-diario .grid-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

#diario-nodes-list {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 10px; /* Spazio per la scrollbar */
}

.cards-grid .card {
  max-width: 400px;
  margin: 0 auto;
}

#diario-reflection-panel {
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

#diario-active-state {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#diario-tasks-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 10px;
}

.guides-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.guides-sidebar {
  background: rgba(13, 19, 38, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 100%;
  overflow-y: auto;
}

.guide-category-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  text-transform: none;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.guide-list-item {
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.guide-list-item:hover, .guide-list-item.active {
  color: var(--text-light);
  background: rgba(212, 175, 55, 0.1);
  padding-left: 16px;
}

.guides-reader {
  max-height: 100%;
  overflow-y: auto;
  padding-right: 10px;
}

.btn-back-to-guides {
  display: none;
}

.parchment-sheet {
  background-color: var(--parchment);
  color: var(--text-dark);
  border: 2px solid var(--parchment-border);
  border-radius: 8px;
  padding: 30px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0,0,0,0.1);
  background-image: radial-gradient(var(--parchment-border) 1px, transparent 0);
  background-size: 24px 24px;
}

.parchment-sheet h3 {
  font-family: var(--font-heading);
  color: #78350f; /* marrone scuro */
  font-size: 1.6rem;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--parchment-border);
  padding-bottom: 8px;
  text-transform: uppercase;
}

.parchment-sheet .category-badge {
  display: inline-block;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #b45309;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 15px;
}

.parchment-sheet .sheet-body {
  font-size: 1.05rem;
  line-height: 1.65;
  color: #1e1503;
  text-align: justify;
  text-transform: uppercase;
}

/* Video Game Character Portrait Layout */
.guide-game-portrait-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-top: 20px;
  flex-wrap: wrap;
}

.guide-portrait-container {
  flex: 0 0 240px;
  max-width: 240px;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-game-portrait-layout:hover .guide-portrait-container {
  transform: translateY(-8px) scale(1.02);
}

.guide-portrait-img {
  width: 100%;
  height: auto;
  display: block;
  filter: sepia(0.12) contrast(1.1) drop-shadow(0 15px 30px rgba(0, 0, 0, 0.5));
  /* Fading gradient to make it look like a video game character selection or cutout */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 65%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 65%, rgba(0,0,0,0) 100%);
}

.guide-game-portrait-layout .sheet-body {
  flex: 1;
  min-width: 280px;
  font-size: 1.25rem;
  line-height: 1.7;
  text-align: justify;
}

/* Modals (Legal & Interactive popups) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(5px);
}

.pausa-video-container {
  margin: 0 auto 20px;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
}

.pausa-video-container .pausa-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
  display: block;
}

@media (max-width: 768px) {
  .desktop-timer {
    display: none !important;
  }
}

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

.modal-container {
  background: var(--bg-dark);
  border: 2px solid var(--gold);
  border-radius: 12px;
  width: 100%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 1.3rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-close-btn:hover {
  color: var(--gold);
  transform: scale(1.1);
}

.modal-body {
  padding: 24px;
  flex-grow: 1;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-light);
}

/* Stili specifici per il contenuto della privacy e dei termini */
.modal-body h2 {
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 16px;
}
.modal-body h3 {
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin: 16px 0 6px 0;
  border-bottom: 1px solid rgba(212,175,55,0.2);
  padding-bottom: 4px;
}
.modal-body p {
  color: var(--text-light);
  margin-bottom: 10px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(212, 175, 55, 0.2);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Dashboard Tabs */
.tabs-header {
  display: flex;
  gap: 10px;
  border-bottom: 2px solid rgba(212, 175, 55, 0.2);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: bold;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--gold);
}

.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Tables style */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table.game-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

table.game-table th {
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold);
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  text-transform: uppercase;
  border-bottom: 2px solid rgba(212, 175, 55, 0.3);
}

table.game-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

table.game-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Quiz Interface */
.quiz-question-box {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quiz-question-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 6px;
  padding: 14px 18px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-option:hover {
  background: rgba(212, 175, 55, 0.08);
  border-color: var(--gold);
}

.quiz-option.selected {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
}

.quiz-radio {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold-dark);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-option.selected .quiz-radio::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-dark);
  border: 1px solid var(--gold);
  color: var(--text-light);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  min-width: 250px;
  animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), fadeOut 0.5s ease 4.5s forwards;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast.toast-level { border-left: 4px solid var(--gold); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* Bottom Bar / Dock per Mobile e Desktop */
/* Bottom nav mobile: senza !important così il JS può nasconderla con style.display */
.mobile-bottom-nav {
  display: flex; /* NO !important: il JS usa style.display='flex'/'none' */
  position: fixed;
  bottom: 0;
  left: 0;
  transform: none;
  width: 100%;
  max-width: none;
  height: calc(70px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(13, 19, 38, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 2px solid var(--gold-dark);
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  z-index: 99;
  box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.5);
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  justify-content: space-evenly;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px;
  gap: 5px;
  scrollbar-width: none;
}

.mobile-bottom-nav::-webkit-scrollbar {
  display: none;
}

/* Bottom nav visibile su TUTTI gli schermi (desktop e mobile)
   Il JS controlla la visibilità con style.display */

.mobile-nav-item {
  flex: 1;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.58rem;
  text-transform: lowercase;
  white-space: normal;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  gap: 4px;
  transition: var(--transition-smooth);
  border-radius: 20px;
  margin: 4px 0;
  padding: 0 2px;
  text-align: center;
}

.mobile-nav-item i {
  font-size: 1.15rem;
  color: var(--gold-dark);
  transition: var(--transition-smooth);
}

.mobile-nav-item:hover {
  color: var(--text-light);
  background: rgba(212, 175, 55, 0.05);
}

.mobile-nav-item.active {
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
}

.mobile-nav-item.active i {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
  transform: scale(1.1);
}

/* Media Queries & Responsive Design */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .guides-container {
    display: block;
  }
  #view-guides:not(.detail-active) .guides-sidebar {
    display: flex;
    max-height: none;
  }
  #view-guides:not(.detail-active) .guides-reader {
    display: none;
  }
  #view-guides.detail-active .guides-sidebar {
    display: none;
  }
  #view-guides.detail-active .guides-reader {
    display: block;
  }
  #view-guides.detail-active #guides-back-btn {
    display: flex !important;
  }
  .btn-back-to-guides {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    margin: 0;
    padding: 4px 12px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: bold;
    color: #78350f !important;
    background: #fef3c7 !important;
    border: 2px solid #b45309 !important;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: var(--transition-smooth);
  }
  .btn-back-to-guides:hover {
    background: #fde68a !important;
    transform: translateY(-2px);
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  /* Mobile: main-content con margin-top corretto per header 60px */
  .main-content {
    margin-left: 0;
  }
  
  body.logged-in .main-content {
    margin-top: 60px !important;
  }

  /* View mobile: padding ridotto per avvicinare i titoli e il fondo */
  .view {
    padding: 5px 12px 5px 12px !important;
    overflow: visible;
  }

  /* Titoli pagina: più piccoli su mobile */
  h2.section-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
    padding-bottom: 6px;
    gap: 8px;
    flex-shrink: 0;
    margin-top: 0;
  }
  h3.panel-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  .main-footer {
    left: 0;
    flex-direction: column;
    height: auto;
    padding: 16px 16px 80px 16px; /* Aggiunto padding inferiore extra per schermi mobile */
    gap: 10px;
    position: relative;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
  }

  .student-header {
    grid-template-columns: 100px 1fr auto;
  }
  
  .student-avatar-img {
    width: 100px;
    height: 100px;
    font-size: 3rem;
  }
  
  .student-currency {
    grid-column: auto;
    text-align: right;
    margin-top: 0;
  }
  
  .dracme-count {
    justify-content: flex-end;
  }
}

/* Regole Mobile (Media Query max-width 768px) per la Navigazione */
@media (max-width: 768px) {
  /* .mobile-bottom-nav ereditato da regole globali */

  .student-header {
    grid-template-columns: 80px 1fr;
  }
  
  .student-avatar-img {
    width: 80px;
    height: 100px;
  }
  
  .student-currency {
    grid-column: 1 / -1;
    text-align: left;
    margin-top: 10px;
  }
  
  .dracme-count {
    justify-content: flex-start;
  }
}

/* ==========================================
   STILI PER LA TOP HEADER E DROPDOWN UTENTE
   ========================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: linear-gradient(180deg, #0a0d18 0%, rgba(13, 19, 38, 0.95) 100%);
  border-bottom: 2px double var(--gold-dark);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.header-logo-container:hover {
  filter: brightness(1.15);
}

.header-center-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.header-prof-logo-wrapper {
  background: transparent;
  border-radius: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: none;
  pointer-events: auto;
  transition: transform 0.3s ease;
}

.header-prof-logo-wrapper:hover {
  transform: scale(1.05);
  box-shadow: none;
}

.header-prof-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  opacity: 0.95;
  filter: none; /* Rimosso l'alone sull'intero avatar (ora nitido) */
  transition: opacity 0.3s ease;
}

.header-prof-logo-wrapper:hover .header-prof-logo {
  opacity: 1;
}

.header-logo-container .logo-shield {
  font-size: 1.6rem;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
}

.header-logo-container h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: 1px;
}

.header-logo-container p {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.header-profile-container {
  position: relative;
}

.header-profile-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: inset 0 0 5px rgba(212, 175, 55, 0.1);
}

.header-profile-widget:hover {
  background: rgba(212, 175, 55, 0.06);
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.header-avatar-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-user-info {
  display: flex;
  flex-direction: column;
}

.header-user-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
}

.header-user-level {
  font-size: 0.65rem;
  color: var(--gold);
  font-weight: bold;
}

.dropdown-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Dropdown: position FIXED così non esce mai dalla finestra */
.profile-dropdown-card {
  position: fixed;
  top: 70px;
  right: 10px;
  width: 280px;
  max-width: calc(100vw - 20px);
  background: rgba(13, 19, 38, 0.98);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1.5px solid var(--gold-dark);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(212, 175, 55, 0.15);
  animation: dropdownFadeIn 0.3s ease;
  z-index: 1001;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-class-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}

.dropdown-xp-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.dropdown-xp-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 5px;
}

.dropdown-xp-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.dropdown-xp-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold) 100%);
  box-shadow: 0 0 6px var(--gold-glow);
}

.dropdown-xp-needed {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 5px;
  text-align: center;
}

.dropdown-dracme {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 5px var(--gold-glow);
  margin: 10px 0;
}

.dropdown-divider {
  height: 1px;
  background: rgba(212, 175, 55, 0.2);
  margin: 12px 0;
}

.dropdown-legal-btns {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.dropdown-actions {
  display: flex;
  gap: 5px;
  justify-content: center;
}

/* Bottoni piccoli nel dropdown */
.dropdown-sm-btn {
  font-size: 0.58rem !important;
  padding: 3px 7px !important;
  min-width: 0 !important;
  white-space: nowrap;
  letter-spacing: 0;
}

.dropdown-actions .btn {
  /* Eredita da dropdown-sm-btn */
}

/* Su schermi molto piccoli (< 400px): mostra solo icona */
@media (max-width: 400px) {
  .dropdown-sm-btn span.btn-label { display: none; }
  .dropdown-sm-btn {
    font-size: 0.58rem !important;
    padding: 4px 6px !important;
  }
}

/* ==========================================
   STILI PER AVATAR ANIMATI E EFFETTO 3D
   ========================================== */

/* Frame del personaggio nel Dashboard */
.dashboard-avatar-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dashboard-avatar-img {
  width: auto;
  height: 100%;
  object-fit: cover;
  transition: transform 0.1s ease-out;
}

/* Frame del personaggio nell'Area Studio (Guide) */
.guide-portrait-container {
  width: auto;
  max-width: 280px;
  height: auto;
  background: none;
  border: none;
  border-radius: 0;
  overflow: visible;
  position: relative;
  box-shadow: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.guide-portrait-img {
  width: 100% !important;
  max-width: 280px !important;
  height: auto !important;
  max-height: 420px !important;
  object-fit: contain !important;
  object-position: top center !important;
  z-index: 2;
  transition: transform 0.1s ease-out;
  transform-style: preserve-3d;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35)); /* Aggiunge un'ombra morbida all'avatar senza sfondo */
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

/* Forza altezza uniforme solo per i ritratti verticali dei personaggi */
.guide-game-portrait-layout:not(.horizontal-layout) .guide-portrait-img {
  width: auto !important;
  max-width: 100% !important;
  height: 350px !important;
  object-fit: contain !important;
  object-position: bottom center !important;
}

/* Modifiche al layout per posizionare l'avatar centrato sopra la descrizione */
.guide-game-portrait-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-top: 15px;
  width: 100%;
}

@media (max-width: 600px) {
  .guide-game-portrait-layout {
    flex-direction: column;
    align-items: center;
  }
}

.sheet-body {
  flex: 1;
  text-align: justify;
}

/* Animazione di fluttuazione a tutto busto */
.animated-3d-avatar {
  animation: avatarFloat 4s ease-in-out infinite;
}

@keyframes avatarFloat {
  0%, 100% {
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5)) drop-shadow(0 0 8px rgba(212,175,55,0.2));
    margin-top: 0px;
  }
  50% {
    filter: drop-shadow(0 15px 20px rgba(0,0,0,0.3)) drop-shadow(0 0 15px rgba(212,175,55,0.4));
    margin-top: -6px;
  }
}

/* Contenitore delle particelle */
.portrait-particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  transform: translateZ(-20px);
  transition: transform 0.1s ease-out;
}

/* Singola particella sparkle */
.sparkle {
  position: absolute;
  background: radial-gradient(circle, rgba(255,223,0,0.8) 0%, rgba(212,175,55,0) 70%);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: sparkleFloat 5s linear infinite;
}

@keyframes sparkleFloat {
  0% {
    transform: translateY(100%) scale(0.5);
    opacity: 0;
  }
  20% {
    opacity: 0.8;
  }
  80% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(-20%) scale(1.2);
    opacity: 0;
  }
}

/* Stile per layout avatar a sviluppo orizzontale */
.guide-game-portrait-layout.horizontal-layout {
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 5px;
  margin-left: -30px;
  margin-right: -30px;
  width: calc(100% + 60px);
}

.guide-game-portrait-layout.horizontal-layout .guide-portrait-container {
  flex: 0 0 auto;
  max-width: none;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: visible;
}

.guide-game-portrait-layout.horizontal-layout .guide-portrait-img {
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none;
  -webkit-mask-image: none !important;
  mask-image: none !important;
  border: none;
}

.guide-game-portrait-layout.horizontal-layout .sheet-body {
  width: 100%;
  padding: 0 30px;
  box-sizing: border-box;
  margin-top: 20px;
}

/* Stile per le card statistiche cliccabili/interattive */
.stat-card-interactive {
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.stat-card-interactive:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 175, 55, 0.5) !important;
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.15) !important;
}
.stat-card-interactive.active {
  transform: translateY(-3px);
  border-color: var(--gold) !important;
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.35) !important;
  background: rgba(212, 175, 55, 0.08) !important;
}
.stat-card-interactive.active h4 {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

/* Pannelli dinamici sub-panoramica */
.panoramica-sub-panel {
  display: none;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Switch Toggle style for teacher dashboard */
.switch-container input:checked + .slider {
  background-color: var(--gold) !important;
}

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

.switch-container input:checked + .slider:before {
  transform: translateX(22px);
}
/* --- LOGIN OVERLAY --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: flex-start; /* Permette lo scroll se il contenuto è lungo */
    justify-content: center;
    overflow-y: auto;
    padding: 2rem 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.login-overlay.hidden {
    display: none;
}

.login-overlay:not(.hidden) {
    display: flex;
    opacity: 1 !important;
    visibility: visible !important;
}

.login-card {
    background: white;
    width: 90%;
    max-width: 450px;
    padding: 3rem;
    border-radius: 40px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    transform: translateY(30px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-overlay:not(.hidden) .login-card {
    transform: translateY(0);
}

.login-logo {
    width: 100px;
    margin-bottom: 1.5rem;
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #666;
    margin-bottom: 2rem;
}

#user-name-input {
    width: 100%;
    padding: 1.2rem;
    border-radius: 15px;
    border: 2px solid #eee;
    font-size: 1.1rem;
    font-family: inherit;
    margin-bottom: 1.5rem;
    outline: none;
    transition: border-color 0.3s;
    text-align: center;
}

#user-name-input:focus {
    border-color: var(--primary-color);
}

.avatar-selector {
    margin-bottom: 2rem;
}

.avatar-selector p {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.avatar-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.avatar-opt {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.avatar-opt:hover {
    background: #eee;
}

.avatar-opt.active {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.login-submit {
    width: 100%;
    padding: 1.2rem;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.btn-guest {
    background: none;
    border: none;
    color: #888;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

/* --- PROFILE DASHBOARD --- */
.profile-header {
    background: white;
    padding: 2.5rem;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
    overflow: hidden;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 5px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: #f8f9fa;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex-grow: 1;
}

.profile-name {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.profile-badges {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.4rem 1.2rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge.rank { background: var(--primary-color); color: white; }
.badge.role { background: #f1f2f6; color: #57606f; }

.guest-notice {
    color: #ffa502;
    font-size: 0.8rem;
    margin-top: 0.8rem;
    font-weight: 700;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.btn-edit {
    background: rgba(93, 95, 239, 0.1) !important;
    color: var(--primary-color) !important;
    border: 1.5px solid var(--primary-color) !important;
}

.btn-logout {
    background: #fff5f5 !important;
    color: #e74c3c !important;
    border: 1.5px solid #feb2b2 !important;
}

.teacher-area {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f7ff;
    border-radius: 12px;
}

.stat-info h4 {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.stat-info p {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
}

.profile-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.profile-card {
    background: white;
    padding: 2rem;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

.profile-card-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.vocab-list {
    max-height: 300px;
    overflow-y: auto;
}

.vocab-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item {
    padding: 1rem;
    border-radius: 12px;
    background: #f8f9fa;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: translateX(5px);
    background: #f0f7ff;
}

@media (max-width: 768px) {
    .profile-sections, .teacher-area > div {
        grid-template-columns: 1fr !important;
    }
}

/* --- ROLE SELECTOR --- */
.role-selector {
    margin-bottom: 1.5rem;
}

.role-selector p {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.role-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.role-opt {
    flex: 1;
    padding: 0.8rem;
    border-radius: 15px;
    border: 2px solid #eee;
    background: white;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    font-family: inherit;
}

.profile-setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 600px) {
    .profile-setup-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.role-opt.active {
    border-color: var(--primary-color);
    background: #f0f7ff;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.1);
}

/* --- LEGAL CHECKS --- */
.legal-checks {
    text-align: left;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.check-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.4;
    user-select: none;
    color: #666;
}

.check-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: #eee;
    border-radius: 6px;
    transition: all 0.2s;
}

.check-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.check-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.check-container input:checked ~ .checkmark:after {
    display: block;
}

.check-container .checkmark:after {
    left: 8px;
    top: 4px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.check-text a {
    color: var(--primary-color);
    text-decoration: underline;
}

/* --- LEGAL MODAL --- */
.legal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.legal-modal:not(.hidden) {
    opacity: 1 !important;
    visibility: visible !important;
}

.legal-modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    padding: 3rem;
    border-radius: 30px;
    position: relative;
    overflow-y: auto;
}

.close-legal {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2rem;
    cursor: pointer;
    color: #888;
}

#legal-text-container h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: 800;
}

#legal-text-container h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--primary-color);
}

#legal-text-container p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #555;
    font-size: 0.95rem;
}


/* LOGIN OVERLAY CSS COPIATO */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: flex-start; /* Permette lo scroll se il contenuto è lungo */
    justify-content: center;
    overflow-y: auto;
    padding: 2rem 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.login-overlay.hidden {
    display: none;
}

.login-overlay:not(.hidden) {
    display: flex;
    opacity: 1 !important;
    visibility: visible !important;
}

.login-card {
    background: white;
    width: 90%;
    max-width: 450px;
    padding: 3rem;
    border-radius: 40px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    transform: translateY(30px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-overlay:not(.hidden) .login-card {
    transform: translateY(0);
}

.login-logo {
    width: 100px;
    margin-bottom: 1.5rem;
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #666;
    margin-bottom: 2rem;
}

#user-name-input {
    width: 100%;
    padding: 1.2rem;
    border-radius: 15px;
    border: 2px solid #eee;
    font-size: 1.1rem;
    font-family: inherit;
    margin-bottom: 1.5rem;
    outline: none;
    transition: border-color 0.3s;
    text-align: center;
}

#user-name-input:focus {
    border-color: var(--primary-color);
}

.avatar-selector {
    margin-bottom: 2rem;
}

.avatar-selector p {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.avatar-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.avatar-opt {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.avatar-opt:hover {
    background: #eee;
}

.avatar-opt.active {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.login-submit {
    width: 100%;
    padding: 1.2rem;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.btn-guest {
    background: none;
    border: none;
    color: #888;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

/* --- PROFILE DASHBOARD --- */
.profile-header {
    background: white;
    padding: 2.5rem;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
    overflow: hidden;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 5px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: #f8f9fa;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex-grow: 1;
}

.profile-name {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.profile-badges {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.4rem 1.2rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge.rank { background: var(--primary-color); color: white; }
.badge.role { background: #f1f2f6; color: #57606f; }

.guest-notice {
    color: #ffa502;
    font-size: 0.8rem;
    margin-top: 0.8rem;
    font-weight: 700;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.btn-edit {
    background: rgba(93, 95, 239, 0.1) !important;
    color: var(--primary-color) !important;
    border: 1.5px solid var(--primary-color) !important;
}

.btn-logout {
    background: #fff5f5 !important;
    color: #e74c3c !important;
    border: 1.5px solid #feb2b2 !important;
}

.teacher-area {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f7ff;
    border-radius: 12px;
}

.stat-info h4 {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.stat-info p {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
}

.profile-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.profile-card {
    background: white;
    padding: 2rem;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

.profile-card-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.vocab-list {
    max-height: 300px;
    overflow-y: auto;
}

.vocab-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item {
    padding: 1rem;
    border-radius: 12px;
    background: #f8f9fa;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: translateX(5px);
    background: #f0f7ff;
}

@media (max-width: 768px) {
    .profile-sections, .teacher-area > div {
        grid-template-columns: 1fr !important;
    }
}

/* --- ROLE SELECTOR --- */
.role-selector {
    margin-bottom: 1.5rem;
}

.role-selector p {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.role-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.role-opt {
    flex: 1;
    padding: 0.8rem;
    border-radius: 15px;
    border: 2px solid #eee;
    background: white;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    font-family: inherit;
}

.profile-setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 600px) {
    .profile-setup-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.role-opt.active {
    border-color: var(--primary-color);
    background: #f0f7ff;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.1);
}

/* --- LEGAL CHECKS --- */
.legal-checks {
    text-align: left;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.check-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.4;
    user-select: none;
    color: #666;
}

.check-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: #eee;
    border-radius: 6px;
    transition: all 0.2s;
}

.check-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.check-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.check-container input:checked ~ .checkmark:after {
    display: block;
}

.check-container .checkmark:after {
    left: 8px;
    top: 4px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.check-text a {
    color: var(--primary-color);
    text-decoration: underline;
}

/* --- LEGAL MODAL --- */
.legal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.legal-modal:not(.hidden) {
    opacity: 1 !important;
    visibility: visible !important;
}

.legal-modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    padding: 3rem;
    border-radius: 30px;
    position: relative;
    overflow-y: auto;
}

.close-legal {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2rem;
    cursor: pointer;
    color: #888;
}

#legal-text-container h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: 800;
}

#legal-text-container h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--primary-color);
}

#legal-text-container p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #555;
    font-size: 0.95rem;
}

/* --- SHARE DROPDOWN --- */
.teacher-share-container {
    position: relative;
    display: inline-block;
}

.share-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 250px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    padding: 1.5rem;
    z-index: 1000;
    margin-top: 10px;
    border: 1px solid #f0f0f0;
    transform-origin: top right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-dropdown.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
}

.share-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
    margin-top: 1rem;
}

.share-section-title:first-child {
    margin-top: 0;
}

.share-btn-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.share-action-btn {
    width: 100%;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid #eee;
    background: #f9f9f9;
    color: #2c3e50;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.2s;
    font-family: inherit;
}

.share-action-btn:hover {
    background: #f0f7ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(5px);
}

.share-action-btn.classroom:hover {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #2e7d32;
}

/* --- CONTACT FORM SECTION --- */
.contact-card-wrapper {
    display: flex;
    max-width: 1250px;
    margin: 0 auto;
    background: white;
    border-radius: 40px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
}

.contact-info-side {
    flex: 1;
    background: #1e4bd1;
    color: white;
    padding: 4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.contact-info-side h2 {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.contact-info-side p {
    font-size: 1.2rem;
    opacity: 0.9;
    line-height: 1.5;
}

.contact-method {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1rem;
}

.contact-method-icon {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.info-card-box {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 2rem;
    border-radius: 25px;
    margin-top: auto;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.info-card-icon {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.2);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.info-card-text h4 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.info-card-text p {
    font-size: 1rem;
    opacity: 0.8;
}

.contact-form-side {
    flex: 1.2;
    padding: 4rem;
    background: white;
}

.form-group-contact {
    margin-bottom: 2rem;
}

.form-group-contact label {
    display: block;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    color: var(--text-color);
}

.form-group-contact input, 
.form-group-contact textarea {
    width: 100%;
    padding: 1.2rem;
    border: 2px solid #f0f0f0;
    border-radius: 15px;
    font-family: inherit;
    font-size: 1.1rem;
    transition: all 0.3s;
    background: #fdfdfd;
}

.form-group-contact input:focus, 
.form-group-contact textarea:focus {
    border-color: #1e4bd1;
    outline: none;
    background: white;
    box-shadow: 0 5px 15px rgba(30, 75, 209, 0.05);
}

.form-group-contact textarea {
    height: 180px;
    resize: none;
}

.contact-legal {
    display: flex;
    gap: 1rem;
    margin-bottom: 2.5rem;
    align-items: flex-start;
}

.contact-legal input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin-top: 3px;
    cursor: pointer;
}

.contact-legal label {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #555;
    font-weight: 600;
}

.contact-legal a {
    color: #1e4bd1;
    text-decoration: underline;
}

.btn-contact-submit {
    width: 100%;
    background: #1e4bd1;
    color: white;
    padding: 1.5rem;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(30, 75, 209, 0.2);
}

.btn-contact-submit:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(30, 75, 209, 0.3);
    background: #1538a1;
}

@media (max-width: 992px) {
    .contact-card-wrapper {
        flex-direction: column !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        width: 100% !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    .contact-info-side {
        padding: 5rem 1.5rem 3rem !important;
        background: transparent !important;
        color: var(--text-color) !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    }
    .contact-info-side h2 {
        font-size: 2.2rem !important;
        color: var(--primary-color) !important;
    }
    .contact-info-side p {
        color: #ccc !important;
    }
    .contact-method {
        font-size: 1.1rem !important;
        word-break: break-all !important;
        color: var(--primary-color) !important;
    }
    .contact-method-icon {
        background: rgba(255,255,255,0.05) !important;
        color: var(--primary-color) !important;
    }
    .info-card-box {
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 1.5rem !important;
        background: rgba(0,0,0,0.3) !important;
        border-color: rgba(255,255,255,0.1) !important;
    }
    .info-card-icon {
        background: transparent !important;
        box-shadow: none !important;
    }
    .info-card-text h4 {
        color: var(--primary-color) !important;
    }
    .contact-form-side {
        padding: 3rem 1.5rem !important;
        background: transparent !important;
    }
}

.footer-logo {
    width: 60px;
    height: auto;
    transition: all 0.3s ease;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.1));
}

.footer-logo:hover {
    filter: drop-shadow(0 8px 20px rgba(93, 95, 239, 0.2));
}

/* Note: .btn-verify buttons are managed individually by JS logic */

/* --- LOGIN PATH STYLES --- */
.login-path-card {
    background: #f8faff;
    border: 2px solid #eee;
    border-radius: 20px;
    padding: 1.2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-path-card:hover {
    transform: translateX(5px);
    border-color: var(--secondary-color);
    background: white;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.login-path-card.active {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 10px 25px rgba(93, 95, 239, 0.1);
}

.login-path-card.active h4 {
    color: var(--primary-color);
}

/* --- ONBOARDING STYLES --- */
.onboarding-container {
    animation: fadeIn 0.8s ease-out;
}

.onboarding-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

@media (max-width: 900px) {
    .onboarding-card-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.onboarding-card {
    border: 1px solid rgba(0,0,0,0.05);
}

.role-opt-large {
    background: #fff;
    border: 2px solid #f0f0f0;
    border-radius: 40px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.role-opt-large h3 {
    font-weight: 900;
    letter-spacing: -0.5px;
    margin: 0;
}

.role-opt-large p {
    font-size: 0.95rem;
    color: #777;
    line-height: 1.5;
}

.role-opt-large:hover {
    transform: translateY(-12px);
    border-color: var(--primary-color);
    box-shadow: 0 25px 50px rgba(255, 127, 127, 0.15);
}

.role-opt-large.active {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px rgba(93, 95, 239, 0.15);
}

.role-opt-large h4 {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.role-opt-large p {
    font-size: 0.9rem;
    opacity: 0.7;
}

.onboarding-step.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .onboarding-container { padding: 2rem 1rem; }
    .role-opt-large { padding: 1.5rem; }
}

/* 📱 OTTIMIZZAZIONE MOBILE: Rimozione Card per massimizzare lo spazio di lettura */
@media (max-width: 768px) {
    /* Trasformiamo la card in un contenitore trasparente a tutta larghezza */
    .exercise-container {
        background: transparent !important;
        padding: 1.5rem 0.2rem !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* I testi di lettura non devono più avere bordi o sfondi bianchi */
    .reading-text {
        padding: 1.5rem 0.5rem !important;
        background: transparent !important;
        border: none !important;
        font-size: 1.3rem !important;
        line-height: 1.7 !important;
    }
    
    .exercise-title {
        font-size: 1.6rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 0.5rem 0.5rem 0.5rem !important;
    }

    /* Riduciamo il padding globale del corpo pagina per dare più respiro */
    main {
        padding-left: 0.8rem !important;
        padding-right: 0.8rem !important;
    }

    /* Anche la teoria e gli schemi diventano meno ingombranti */
    .theory-schema, .map-container, .example-box {
        padding: 1.2rem !important;
        border-radius: 15px !important;
        margin: 1rem 0 !important;
    }

    /* Le griglie di opzioni usano meglio lo spazio */
    .options-grid {
        grid-template-columns: 1fr !important; /* Una sola colonna su mobile molto piccolo */
        gap: 0.8rem !important;
    }
}

/* 📱 OTTIMIZZAZIONE MOBILE: Rimozione Card per massimizzare lo spazio di lettura */
@media (max-width: 768px) {
    .exercise-container {
        background: transparent !important;
        padding: 1.5rem 0.2rem !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .reading-text {
        padding: 1.5rem 0.5rem !important;
        background: transparent !important;
        border: none !important;
        font-size: 1.3rem !important;
        line-height: 1.7 !important;
    }
    
    .exercise-title {
        font-size: 1.6rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 0.5rem 0.5rem 0.5rem !important;
    }

    main {
        padding-left: 0.8rem !important;
        padding-right: 0.8rem !important;
    }

    .theory-schema, .map-container, .example-box {
        padding: 1.2rem !important;
        border-radius: 15px !important;
        margin: 1rem 0 !important;
    }

    .options-grid {
        grid-template-columns: 1fr !important;
        gap: 0.8rem !important;
    }
}

/* 📱 OTTIMIZZAZIONE RADICALE MOBILE: Eliminazione "Effetto Card" */
@media (max-width: 992px) {
    main {
        padding: 0px 0.5rem 0px 0.5rem !important; 
        background-color: transparent !important; 
    }

    /* Rimuoviamo bordi, ombre e padding eccessivi da TUTTI i contenitori card-like */
    .exercise-container, .full-width .exercise-container,
    .interactive-container, .full-width .interactive-container,
    .reading-text, .full-width .reading-text,
    .theory-schema, .map-container, .example-box, .question-block, .profile-card, .stat-card,
    .theory-section, .instruction-box, .profile-header, .teacher-area {
        background: transparent !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        display: block !important;
    }

    /* Forza allineamento a sinistra e font-size leggibile per la lettura */
    .reading-text, .reading-text p, .reading-text li, 
    .interactive-container, .interactive-container p,
    .theory-section, .theory-section p, .instruction-box {
        font-size: 1.35rem !important;
        line-height: 1.7 !important;
        text-align: left !important;
        margin-bottom: 1.2rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .exercise-title {
        font-size: 1.4rem !important;
        padding: 1.2rem 0.5rem 0.5rem 0.5rem !important; /* Spazio per hamburger */
        margin-bottom: 1.2rem !important;
        border-bottom: 2px solid #f0f0f0 !important;
        text-align: left !important;
    }

    /* TRASFORMAZIONE GRID IN LISTE SLIM PER MOBILE */
    .materie-grid, .all-levels-container, .levels-list, [style*="display: grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.8rem !important;
    }

    .materia-card, .menu-card, .level-row, .list-item {
        padding: 1.2rem 1.5rem !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: left !important;
        border-radius: 20px !important;
        min-height: auto !important;
        gap: 1.2rem !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.03) !important;
        background: #fdfdfd !important;
        border: 1px solid #eee !important;
        margin: 0 !important;
        width: 100% !important;
        position: relative !important;
    }

    .materia-icon, .menu-card .icon, .list-item span:first-child, .level-row span:first-child {
        font-size: 1.8rem !important;
        margin-bottom: 0 !important;
        min-width: 45px !important;
        text-align: center !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .materia-label, .materia-card h3, .menu-card h3, .list-item-content, .level-row span:not(:first-child):not(:last-child), .level-row span:nth-child(2) {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
        margin: 0 !important;
        color: var(--text-color) !important;
        flex-grow: 1 !important;
        display: block !important;
    }

    /* Rimuoviamo descrizioni lunghe e frecce duplicate in modo mirato */
    .menu-card p, .materia-card p, .level-row span[style*="color: var(--primary-color)"] {
        display: none !important;
    }

    /* Aggiungiamo una freccia uniforme a destra solo dove serve */
    .materia-card::after, .menu-card::after {
        content: '➜';
        font-weight: 800;
        color: var(--primary-color);
        font-size: 1.2rem;
        margin-left: auto;
    }

    .options-grid {
        grid-template-columns: 1fr !important;
        gap: 0.8rem !important;
        padding: 0 0.5rem !important;
    }

    .btn-secondary {
        padding: 1.2rem !important;
        font-size: 1rem !important;
        text-align: left !important;
    }

    /* Sistemazione Header Profilo su Mobile */
    .profile-header {
        flex-direction: column !important;
        text-align: center !important;
        padding-top: 1rem !important;
        gap: 1.5rem !important;
    }
    
    .profile-avatar-large {
        width: 100px !important;
        height: 100px !important;
        margin: 0 auto 1rem !important;
    }
    
    .profile-name {
        font-size: 1.6rem !important;
        text-align: center !important;
    }
    
    .profile-badges {
        justify-content: center !important;
        margin-bottom: 1rem !important;
    }
    
    .profile-actions {
        flex-direction: row !important;
        gap: 0.5rem !important;
        margin-top: 1rem !important;
    }

    /* Avviciniamo il pulsante menu al bordo */
    .floating-toggle {
        top: 0.8rem !important;
        left: 0.8rem !important;
        width: 42px !important;
        height: 42px !important;
        border-radius: 10px !important;
    }
    
    #app {
        margin-top: 0.5rem !important;
    }
}

@media (max-width: 480px) {
    main {
        padding: 3.2rem 0.2rem 1rem 0.2rem !important;
    }
    
    .reading-text, .reading-text p {
        font-size: 1.25rem !important;
    }
}

/* --- READING HEADER --- */
.reading-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@media (max-width: 992px) {
    .reading-header {
        padding: 0.8rem !important;
        font-size: 0.85rem !important;
        border-radius: 10px !important;
        margin-bottom: 1.2rem !important;
        letter-spacing: 1px !important;
        width: 100% !important;
    }
}

/* --- MUSIC PLAYER MOBILE ADJUSTMENT --- */
@media (max-width: 768px) {
    #music-player-widget {
        position: fixed !important;
        bottom: 70px !important; /* Above mobile bottom nav */
        right: 10px !important;
        z-index: 999 !important;
        transform: scale(0.85);
        transform-origin: bottom right;
        border: 1px solid rgba(212, 175, 55, 0.5) !important;
        background: rgba(0, 0, 0, 0.8) !important;
        padding: 5px !important;
    }
    #music-player-widget > div:first-child {
        display: none !important; /* Nasconde testo brano su mobile */
    }
}

/* --- NON SCROLL VIEWS ON DESKTOP --- */
@media (min-width: 1024px) {
    #view-map, #view-selezione-profilo {
        overflow: hidden;
        max-height: 100%;
    }
    #view-map .map-container {
        height: 100%;
        overflow-y: auto;
    }
    #view-student-dashboard .profile-card,
    #view-student-dashboard .stat-card {
        max-height: 100%;
    }
    
    #view-student-dashboard .dashboard-grid {
        gap: 10px;
    }
    #view-student-dashboard .glass-panel {
        margin-bottom: 10px;
    }
    #view-student-dashboard .student-header {
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
}

/* ==========================================
   SCROLL INTERNO: Mercato, Inventario, Regolamento, Missioni
   ========================================== */

/* Mercato */
#view-shop {
    padding: 15px 30px;
    flex-direction: column;
    min-height: auto;
    overflow-y: auto;
    overflow-x: hidden;
}
#view-shop.active { display: flex; }
#view-shop > div {
    display: flex;
    flex-direction: column;
}
#view-shop .cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    align-content: start;
    gap: 20px;
    padding-bottom: 20px;
    overflow: visible;
}

/* Inventario */
#view-inventory {
    padding: 15px 30px;
    flex-direction: column;
    min-height: auto;
    overflow-y: auto;
    overflow-x: hidden;
}
#view-inventory.active { display: flex; }
#view-inventory > div {
    display: flex;
    flex-direction: column;
}
#view-inventory .tab-content {
    display: none;
}
#view-inventory .tab-content.active {
    display: flex;
    flex-direction: column;
}
#view-inventory .cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    align-content: start;
    gap: 20px;
    padding-bottom: 20px;
    overflow: visible;
}
#view-inventory .btn-secondary {
    padding: 4px 8px;
    font-size: 0.65rem;
}



/* Missioni */
#view-missions {
    overflow: hidden;
    padding: 15px;
    flex-direction: column;
}
#view-missions.active { display: flex; }
#view-missions > div {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#active-quiz-container[style*="display: block"],
#active-quiz-container[style*="display: flex"] {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.quiz-actions-row {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-wrap: wrap; /* Fix horizontal overflow */
}

@media (max-width: 768px) {
    #active-quiz-container {
        padding: 15px 10px !important;
        margin-top: 10px !important;
    }
    .quiz-actions-row {
        flex-direction: column;
        align-items: stretch;
    }
    .quiz-actions-row .btn {
        width: 100%;
        justify-content: center;
    }
}

#missions-categories-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

/* ==========================================
   FOOTER: nascosto su schermi grandi
   (i link sono ora nel menu a tendina)
   ========================================== */
/* Il footer è visibile su desktop come richiesto dall'utente */

/* Su mobile il footer è nascosto perché i link sono nel menù a tendina */
@media (max-width: 768px) {
    .main-footer {
        display: none !important;
    }
}

/* ==========================================
   MAPPA: padding inferiore per non toccare
   la bottom navigation
   ========================================== */
#view-map {
    padding-bottom: 5px !important;
}

/* ==========================================
   MOBILE: Diario si comporta come il Tempio
   (nascondi pannello lista quando si seleziona
   un nodo, mostra solo il dettaglio)
   ========================================== */
@media (max-width: 1024px) {
    /* Diario: colonna singola su mobile */
    #view-diario .grid-container {
        grid-template-columns: 1fr;
    }

    /* Di default su mobile mostra solo la lista dei nodi */
    #view-diario .grid-container #diario-nodes-list-wrapper {
        display: block;
    }
    #view-diario .grid-container #diario-reflection-panel {
        display: none;
    }

    /* Quando è attivo il dettaglio, nascondi la lista e mostra il pannello */
    #view-diario.detail-active #diario-nodes-list-wrapper {
        display: none;
    }
    #view-diario.detail-active #diario-reflection-panel {
        display: flex !important;
    }
    #view-diario.detail-active #diario-back-btn {
        display: flex !important;
    }

    /* Pulsante "Torna ai Nodi" visibile solo su mobile in detail mode */
    .btn-back-to-diario-nodes {
        display: inline-flex;
        margin: 0;
        width: auto;
        padding: 8px 24px;
        font-size: 0.9rem;
    }

    /* Tempio: flex column su mobile, sidebar + reader impilati */
    #view-guides {
        overflow: hidden;
    }
    #view-guides .guides-container {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        min-height: 0;
        flex: 1;
    }
    #view-guides .guides-sidebar {
        flex: 1;
        flex-shrink: 0;
        overflow-y: auto;
    }
    #view-guides .guides-reader {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    /* Diario su mobile: scroll interno */
    #view-diario {
        overflow: hidden;
    }
    #view-diario .grid-container {
        overflow: hidden;
        flex: 1;
        min-height: 0;
    }
    #diario-nodes-list {
        overflow-y: auto;
        max-height: 100%;
    }
    #diario-reflection-panel {
        overflow-y: auto;
        max-height: 100%;
    }
    #diario-tasks-container {
        overflow-y: auto;
        max-height: none;
    }
}

/* Pulsante "Torna ai Nodi" nascosto su desktop */
@media (min-width: 1025px) {
    .btn-back-to-diario-nodes {
        display: none !important;
    }
}

/* ==========================================
   MISSIONI: Titolo da "Campagne" a "Missioni"
   (solo nella view missions il h2)
   ========================================== */

/* ==========================================
   ANIMAZIONE PULSE (usata dal banner musica)
   ========================================== */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.85; transform: translateX(-50%) scale(1.03); }
}


/* ==========================================
   STUDENT DASHBOARD: su mobile scrolla internamente
   ========================================== */
@media (max-width: 768px) {
    #view-student-dashboard,
    #view-teacher-dashboard,
    #view-admin-dashboard {
        overflow-y: auto;
    }
}

/* ==========================================
   DESKTOP: ogni view attiva scrolla internamente
   (il main-content è overflow:hidden, le view scrollano)
   ========================================== */
.view.active {
    display: flex;
    justify-content: flex-start !important;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100%;
}

/* Eccezioni: view che gestiscono lo scroll internamente */
#view-diario.active,
#view-guides.active {
    overflow: hidden;
}

/* ==========================================
   DIARIO: scroll interno dei nodi garantito
   ========================================== */
#diario-nodes-list {
    overflow-y: auto;
    height: 100%;
    max-height: 100%;
}

#diario-reflection-panel {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#diario-active-state {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#diario-tasks-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

/* ==========================================
   INVENTARIO: riduzione padding card su desktop
   ========================================== */
#view-inventory .card {
    padding: 14px;
}

/* ==========================================
   HEADER: responsive su smartphone e tablet (< 768px)
   ========================================== */
@media (max-width: 768px) {
    .app-header {
        padding: 0 8px;
        height: 60px;
        flex-wrap: nowrap;
        gap: 6px;
    }
    /* Su schermi < 768px (bottom nav attiva):
       main-content = 100dvh - header(60px) - bottom-nav(64px) */
    .main-content {
        margin-top: 60px;
        height: calc(100dvh - 60px - 64px);
        max-height: calc(100dvh - 60px - 64px);
        flex: none;
    }
    body:not(.logged-in) .main-content {
        margin-top: 0;
        height: 100dvh;
        max-height: 100dvh;
        flex: none;
    }
    .header-logo-text {
        display: none;
    }
    .header-logo-container img {
        height: 34px !important;
    }
    .header-user-name { font-size: 0.68rem; }
    .header-user-level { font-size: 0.58rem; }
    .header-avatar-img { width: 28px !important; height: 28px !important; }
    /* Timer e altri elementi header compatti */
    #student-timer-display {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
}

/* ==========================================
   TEMPIO (guide cards): responsive su mobile
   ========================================== */
@media (max-width: 1024px) {
    .guide-game-portrait-layout {
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        align-items: stretch;
        gap: 18px;
    }
    .guide-portrait-container {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 auto;
        overflow: hidden;
    }
    .guide-portrait-img {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: cover !important;
        object-position: center center !important;
    }
    .guide-game-portrait-layout:not(.horizontal-layout) .guide-portrait-img {
        height: auto !important;
        width: 100% !important;
    }
    .guide-game-portrait-layout .sheet-body {
        width: 100% !important;
        min-width: auto !important;
        padding: 0 12px 12px !important;
        box-sizing: border-box !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .guide-game-portrait-layout.horizontal-layout {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .guide-game-portrait-layout.horizontal-layout .sheet-body {
        padding: 0 12px !important;
    }
}

@media (max-width: 768px) {
    .guide-game-portrait-layout {
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .guide-portrait-container {
        width: 100% !important;
        max-height: 240px;
        overflow: visible;
    }
    .guide-portrait-img {
        width: 100% !important;
        max-height: 240px !important;
        object-fit: contain !important;
    }
    .guide-game-portrait-layout:not(.horizontal-layout) .guide-portrait-img {
        height: 240px !important;
        width: auto !important;
    }
    /* Cards griglia: 1 colonna su mobile */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    /* View welcome: scrolla su mobile */
    #view-welcome {
        overflow-y: auto;
    }
}

/* Su smartphone molto piccolo: 1 sola colonna */
@media (max-width: 400px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   MOBILE HEADER: solo avatar, nascondi testo e freccia
   ========================================== */
@media (max-width: 768px) {
    /* Nascondi nome/livello e freccia — solo avatar cliccabile */
    #header-profile-widget .header-user-info,
    #header-profile-widget .dropdown-arrow {
        display: none !important;
    }
    /* Avatar più piccolo e cliccabile */
    #header-profile-widget {
        gap: 0;
        cursor: pointer;
    }
    #header-profile-widget .header-avatar-img {
        width: 34px !important;
        height: 34px !important;
        border-radius: 50%;
        border: 2px solid var(--gold-dark);
    }

    /* DROPDOWN su mobile: occupa tutta la larghezza, testo leggibile */
    .profile-dropdown-card {
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 0 12px 12px !important;
        padding: 16px 14px !important;
        font-size: 0.88rem;
    }
    .profile-dropdown-card .dropdown-class-info {
        font-size: 0.95rem;
    }
    .profile-dropdown-card .dropdown-class-info span {
        font-size: 0.78rem !important;
    }
    /* Pulsanti dropdown su mobile: più leggibili */
    .dropdown-sm-btn {
        font-size: 0.72rem !important;
        padding: 6px 10px !important;
    }
    /* Testo tracker musica più leggibile */
    #music-track-title {
        font-size: 0.72rem !important;
        max-width: 120px !important;
    }

}

/* ==========================================
   GUIDE (TEMPIO): testo card non esce fuori
   ========================================== */
.guide-game-portrait-layout {
    overflow: visible;
}
.guide-game-portrait-layout .sheet-body {
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Guide sidebar: testo lista non esce fuori */
.guide-list-item {
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

/* ==========================================
   DIARIO: scroll nodi garantito su desktop e mobile
   ========================================== */
.grid-container {
    display: grid;
    flex: 1;
    min-height: 0;
}

#diario-nodes-list {
    overflow-y: auto !important;
    min-height: 0;
}

/* ==========================================
   SHOP E INVENTARIO MOBILE: layout a lista compatta
   ========================================== */
@media (max-width: 768px) {
    #view-shop .cards-grid, #view-inventory .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    #view-shop .card, #view-inventory .card {
        flex-direction: row;
        max-width: 100%;
        margin: 0;
        align-items: center;
        padding: 12px;
        min-height: auto;
        text-align: left;
    }
    #view-shop .card-icon, #view-inventory .card-icon {
        width: 45px;
        height: 45px;
        margin-bottom: 0;
        margin-right: 12px;
        flex-shrink: 0;
    }
    #view-shop .card-content, #view-inventory .card-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-width: 0; /* previene overflow text */
    }
    #view-shop .card-title, #view-inventory .card-title {
        font-size: 0.95rem;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #view-shop .card-desc, #view-inventory .card-desc {
        display: none; /* Nasconde la descrizione per fare spazio */
    }
    #view-shop .card-meta, #view-inventory .card-meta {
        justify-content: flex-start;
        margin: 2px 0;
        font-size: 0.8rem;
    }
    #view-shop .card button, #view-inventory .card button {
        margin-top: 6px;
        padding: 6px 12px;
        font-size: 0.75rem;
        width: auto !important;
        align-self: flex-start;
    }
    #view-shop .card > p, #view-inventory .card > p,
    #view-shop .card-content > p, #view-inventory .card-content > p {
        margin-bottom: 4px !important;
    }
    #view-shop .card-rarity-badge, #view-inventory .card-rarity-badge {
        position: absolute;
        top: 8px;
        right: 8px;
        font-size: 0.55rem;
        padding: 2px 6px;
    }
    /* Tempio mobile: testo card non esce */
    .guides-reader .guide-game-portrait-layout {
        flex-direction: column;
    }
    .guides-reader .guide-game-portrait-layout .parchment-sheet {
        padding: 15px;
    }
    
    /* SPAZIO TITOLO: riduce padding-top della view su schermi ridotti */
    .view.active {
        padding-top: 10px !important;
        padding-bottom: 20px !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    .view h2, .view h1 {
        margin-top: 0 !important;
    }
    
    /* Su smartphone non usiamo "card", ma un layout piatto fluido come le app native */
    .glass-panel {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 5px 0 !important;
        margin-bottom: 15px !important;
    }
    #view-map .glass-panel {
        padding: 0 !important;
        margin-bottom: 20px !important;
    }
    .guides-reader .guide-game-portrait-layout .sheet-body {
        max-height: none;
        overflow: visible;
    }
}

/* ==========================================
   DROPDOWN: pulsante Dashboard solo su mobile
   ========================================== */
.dropdown-dashboard-link {
    display: none;
    text-align: center;
    margin-bottom: 8px;
}
@media (max-width: 768px) {
    .dropdown-dashboard-link {
        display: block;
    }
    .dropdown-dashboard-btn {
        width: 100%;
        justify-content: center;
        font-size: 0.78rem !important;
        padding: 7px 10px !important;
    }
}

/* Teacher Dashboard Responsiveness */
.form-create-student-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: flex-end;
}
.teacher-students-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .form-create-student-grid {
        grid-template-columns: 1fr;
    }
    .teacher-students-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .teacher-students-header > div {
        width: 100%;
        flex-direction: column;
    }
    .teacher-students-header > div > input,
    .teacher-students-header > div > select {
        width: 100% !important;
    }
}
@media (max-width: 768px) {
    /* Rimuovi completamente i gap attorno alle view per sfruttare tutto lo spazio */
    .view, .view.active, #view-missions {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .glass-panel {
        padding: 10px !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
        /* Per assicurarsi che copra tutto se mostriamo un background */
        height: 100% !important;
    }

    #view-missions > div {
        margin: 0 !important;
        padding: 10px !important;
    }

    /* Assicura che main-content parta esattamente da sotto l'header e arrivi al bottom nav */
    .main-content, body.logged-in .main-content {
        margin-top: 60px !important;
        height: calc(100dvh - 60px - 64px) !important;
        padding: 0 !important;
    }
}

/* Tooltips per la Navbar */
@media screen and (min-width: 1024px) {
    .mobile-bottom-nav {
        overflow: visible !important;
    }

    .mobile-nav-item {
        position: relative;
    }

    .mobile-nav-item::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 110%;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        background: var(--primary-color, #3b82f6);
        color: white;
        padding: 8px 14px;
        border-radius: 12px;
        font-size: 0.9rem;
        font-weight: 600;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        box-shadow: 0 10px 25px rgba(0,0,0,0.4);
        z-index: 2000;
        border: 1px solid rgba(255,255,255,0.1);
    }

    .mobile-nav-item:hover::after {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }

    .mobile-nav-item:hover i {
        transform: translateY(-5px);
        color: var(--primary-color, #3b82f6);
    }
}


/* Nascondi testo navbar su PC */
@media (min-width: 769px) {
  .mobile-nav-item span {
    display: none !important;
  }
}
