@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:       #0a0f1e;
  --surface:  #111827;
  --surface2: #1a2336;
  --accent:   #00e5ff;
  --accent2:  #ff6b35;
  --text:     #e8eaf6;
  --muted:    #6b7a99;
  --success:  #00e676;
  --warning:  #ffd740;
}

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Syne', sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Game container ── */
#game-container {
  position: relative;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(0,229,255,0.08);
  border-right: 1px solid rgba(0,229,255,0.08);
}

/* ── Header ── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,229,255,0.1);
  position: sticky;
  top: 0;
  z-index: 5;
}

#game-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
}

#round-info {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

#score-display {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  color: var(--text);
  text-align: right;
}

#score-val {
  display: block;
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
}

/* ── Main game area ── */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 90px;
  gap: 10px;
}

/* ── Target card ── */
#target-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 20px;
  width: 100%;
  border: 1px solid rgba(255,107,53,0.3);
  display: flex;
  align-items: center;
  gap: 14px;
}

#target-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,107,53,0.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

#target-info { flex: 1; min-width: 0; }

#target-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

#target-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#target-distance {
  font-size: 12px;
  color: var(--accent2);
  font-family: 'DM Mono', monospace;
  margin-top: 2px;
}

/* ── Compass ── */
#compass-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#compass-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

#compass-wrapper {
  width: 190px;
  height: 190px;
  filter: drop-shadow(0 0 20px rgba(0,229,255,0.08));
}

#compass-svg { width: 190px; height: 190px; }

#compass-degrees {
  font-family: 'DM Mono', monospace;
  font-size: 24px;
  font-weight: 500;
  color: var(--accent);
}

/* ── Compass legend ── */
#compass-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-north { background: var(--accent); }
.legend-target { background: var(--accent2); }

/* ── Instructions ── */
#instructions {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

#instructions strong { color: var(--accent); font-weight: 700; }

/* ── Manual slider ── */
#manual-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.05);
}

#manual-controls label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}

#angle-slider {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

#angle-val {
  color: var(--text);
  font-weight: 500;
}

/* ── Buttons ── */
#permission-btn {
  width: 100%;
  padding: 13px 16px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0,229,255,0.35);
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#permission-btn:hover { background: rgba(0,229,255,0.07); }

#submit-btn {
  width: 100%;
  padding: 18px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.2s, transform 0.1s;
}

#submit-btn:hover   { opacity: 0.88; }
#submit-btn:active  { transform: scale(0.98); }

/* ── Status bar ── */
#status-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  border-top: 1px solid rgba(0,229,255,0.08);
  z-index: 4;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.dot-ok   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-warn { background: var(--warning); }
.dot-off  { background: var(--muted); }


/* ── Responsive tweaks ── */
@media (min-height: 800px) {
  #compass-wrapper { width: 210px; height: 210px; }
  #compass-svg     { width: 210px; height: 210px; }
}

@media (prefers-color-scheme: light) {
  /* Keep dark theme regardless — game aesthetic */
  body { background: var(--bg); }
}

/* ── Timer ── */
#timer-container {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

#timer-svg {
  width: 64px;
  height: 64px;
}

#timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  transition: color 0.3s;
}

/* ── Result countdown line ── */
#result-countdown {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

#result-countdown-num {
  color: var(--text);
  font-weight: 500;
}

/* ── Final overlay ── */
#final-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 120px;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 8px;
}

#final-overlay.show { display: flex; }

#final-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

#final-total-label {
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

#final-total-score {
  font-size: 80px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin: 4px 0 8px;
}

#final-rank {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 20px;
}

/* Round list */
#final-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}


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

.final-round-num {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  width: 16px;
  flex-shrink: 0;
}

.final-emoji { font-size: 18px; flex-shrink: 0; }

.final-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.final-row-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.final-error {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

.final-pts {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  min-width: 40px;
  text-align: right;
}

#new-game-btn {
  width: 100%;
  padding: 18px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

#new-game-btn:hover  { opacity: 0.88; }
#new-game-btn:active { transform: scale(0.98); }

/* ── Start overlay ── */
#start-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 20px 100px;
  gap: 10px;
  z-index: 40;
  overflow-y: auto;
}

#start-overlay.show { display: flex; }

#start-logo {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 0;
}

#start-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
  text-align: center;
}

#start-subtitle {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

#start-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin: 2px 0;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
  color: var(--text);
}

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

#permission-btn-start {
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0,229,255,0.35);
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#permission-btn-start:hover { background: rgba(0,229,255,0.07); }

#start-btn {
  width: 100%;
  padding: 15px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.2s, transform 0.1s;
}

#start-btn:hover  { opacity: 0.88; }
#start-btn:active { transform: scale(0.98); }

/* ── Result overlay con mappa ── */
#result-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(10,15,30,0.98);
  flex-direction: column;
  align-items: center;
  padding: 20px 20px 100px;
  z-index: 20;
  overflow-y: auto;
  gap: 12px;
}

#result-overlay.show { display: flex; }

#result-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#result-score-big {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

#result-error {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  color: var(--muted);
}

#result-message {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

/* Mappa */
#result-map {
  width: 100%;
  height: 260px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(0,229,255,0.15);
  flex-shrink: 0;
}

/* Sovrascrive stili Leaflet per tema dark */
.leaflet-container {
  background: #0d1117 !important;
  font-family: 'Syne', sans-serif;
}

/* Legenda mappa */
#map-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.legend-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.legend-seg {
  width: 24px;
  height: 3px;
  border-radius: 2px;
}

#result-countdown {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

#result-countdown-num {
  color: var(--text);
  font-weight: 500;
}

/* ── Region selector ── */
#region-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  align-self: flex-start;
  margin-top: 2px;
}

#region-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}

.region-btn {
  padding: 10px 8px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}

.region-btn:first-child {
  grid-column: 1 / -1;
  font-size: 14px;
  padding: 12px;
}

.region-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: rgba(0,229,255,0.2);
}

.region-btn.active {
  background: rgba(0,229,255,0.1);
  color: var(--accent);
  border-color: rgba(0,229,255,0.5);
}

/* ── Target card ridisegnata ── */
#target-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 16px;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#target-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
}

#target-place {
  font-size: 18px;
  font-weight: 800;
  color: #00e5ff;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

#target-city {
  font-size: 14px;
  font-weight: 600;
  color: #ffd740;
  margin-top: 2px;
}

#target-country {
  font-size: 13px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

#target-distance {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* ── Final list aggiornata ── */
.final-target-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.final-place {
  font-size: 13px;
  font-weight: 700;
  color: #00e5ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.final-city-country {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Animazione submit: freeze bussola ── */
#compass-ring.frozen {
  transition: none !important;
}

#compass-degrees.frozen {
  color: var(--warning) !important;
}

#compass-svg {
  transition: filter 0.15s ease;
}

/* ── Wikipedia link ── */
.wiki-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.wiki-link:hover {
  background: rgba(0,229,255,0.12);
  color: var(--accent);
  border-color: rgba(0,229,255,0.4);
}

/* ── Header aggiornato ── */
#header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#profile-btn {
  background: transparent;
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 10px;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

#profile-btn:hover {
  background: rgba(0,229,255,0.08);
  color: var(--accent);
  border-color: rgba(0,229,255,0.4);
}

/* ── Profile overlay ── */
#profile-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg);
  flex-direction: column;
  padding: 0 0 120px;
  z-index: 50;
  overflow-y: auto;
}

#profile-overlay.show { display: flex; }

#profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,229,255,0.1);
  position: sticky;
  top: 0;
  z-index: 5;
}

#profile-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.3px;
}

#profile-close-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#profile-close-btn:hover { background: var(--surface2); color: var(--text); }

/* Stat cards globali */
#profile-global {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 20px 20px 0;
}

.stat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.05);
}

.stat-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  line-height: 1.1;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* Sezione regioni */
#profile-region-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 20px 20px 8px;
}

#profile-regions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 20px;
}

.region-stat {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.04);
}

.region-stat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.region-stat-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.region-stat-games {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.region-stat-best {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
}

/* Ultima partita */
#profile-last-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 20px 20px 6px;
}

#profile-last-date {
  font-size: 14px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  padding: 0 20px 20px;
}

/* Reset button */
#profile-reset-btn {
  margin: 8px 20px 0;
  padding: 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#profile-reset-btn:hover {
  background: rgba(255,100,100,0.08);
  color: #ff6b6b;
  border-color: rgba(255,100,100,0.3);
}

/* Badge nuovo record */
#final-new-best {
  display: none;
  background: linear-gradient(135deg, #ffd740, #ffab00);
  color: #0a0f1e;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 4px;
}

/* ── Bottone link profilo (start + final screen) ── */
.profile-link-btn {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.profile-link-btn:hover {
  background: rgba(0,229,255,0.06);
  color: var(--accent);
  border-color: rgba(0,229,255,0.25);
}

/* ── Country selector ── */
#country-selector {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

#country-selector.show { display: flex; }

#country-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

#country-select {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a99' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

#country-select:focus {
  outline: none;
  border-color: rgba(0,229,255,0.5);
}

#country-select option {
  background: var(--surface);
  color: var(--text);
}

/* ── Final row con Wikipedia extract ── */
.final-row {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}

.final-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
  cursor: pointer;
}

/* ── Wiki toggle button ── */
.wiki-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.05);
  color: var(--muted);
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}

.wiki-toggle:hover { color: var(--accent); }

.wiki-toggle-chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.wiki-toggle[aria-expanded="true"] .wiki-toggle-chevron {
  transform: rotate(180deg);
}

/* ── Wiki extract panel (collassato di default) ── */
.wiki-extract {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.wiki-extract.open {
  max-height: 400px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.wiki-extract-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.wiki-thumb {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.wiki-read-more {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.3px;
  align-self: flex-start;
  opacity: 0.85;
}

.wiki-read-more:hover { opacity: 1; text-decoration: underline; }

/* ── Challenge system ────────────────────────────────────────────────────── */

/* Banner sfida nello start overlay */
#challenge-banner {
  display: none;
  width: 100%;
  background: linear-gradient(135deg, rgba(255,107,53,0.15), rgba(255,215,64,0.10));
  border: 1px solid rgba(255,107,53,0.45);
  border-radius: 16px;
  padding: 14px 16px;
  align-items: center;
  gap: 12px;
}

#challenge-banner.show {
  display: flex;
}

.challenge-banner-icon {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
}

.challenge-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.challenge-banner-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: -0.2px;
}

.challenge-banner-sub {
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

#challenge-banner-code {
  color: var(--warning);
  font-weight: 700;
}

/* Sezione inserisci codice sfida */
.challenge-join-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.challenge-join-toggle {
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.2px;
}

.challenge-join-toggle:hover {
  border-color: rgba(0,229,255,0.3);
  color: var(--accent);
}

#challenge-input-row {
  display: none;
  gap: 8px;
  width: 100%;
}

#challenge-input-row.show {
  display: flex;
}

#challenge-code-input {
  flex: 1;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(0,229,255,0.25);
  border-radius: 12px;
  font-family: 'DM Mono', monospace;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

#challenge-code-input::-webkit-outer-spin-button,
#challenge-code-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

#challenge-code-input:focus {
  border-color: rgba(0,229,255,0.6);
}

.challenge-join-go {
  padding: 11px 18px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.challenge-join-go:hover  { opacity: 0.88; }
.challenge-join-go:active { transform: scale(0.96); }

/* Pannello challenge nel final scoreboard */
#challenge-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255,107,53,0.3);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#challenge-panel:empty {
  display: none;
}

.challenge-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.challenge-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.challenge-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.challenge-code {
  font-family: 'DM Mono', monospace;
  font-size: 28px;
  font-weight: 500;
  color: var(--warning);
  letter-spacing: 3px;
  flex: 1;
}

.challenge-copy-btn {
  padding: 10px 16px;
  background: rgba(255,107,53,0.12);
  color: var(--accent2);
  border: 1px solid rgba(255,107,53,0.35);
  border-radius: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.challenge-copy-btn:hover {
  background: rgba(255,107,53,0.2);
}

/* ── Termina sfida button ── */
#end-challenge-btn {
  width: 100%;
  padding: 18px;
  background: transparent;
  color: var(--accent2);
  border: 2px solid rgba(255,107,53,0.5);
  border-radius: 14px;
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#end-challenge-btn:hover  { background: rgba(255,107,53,0.1); border-color: var(--accent2); }
#end-challenge-btn:active { transform: scale(0.98); }