* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #0d0e12;
  color: #e6e8eb;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR CONTROLLI A SINISTRA */
.sidebar-controls {
  width: 380px;
  min-width: 380px;
  background-color: #16181d;
  border-right: 1px solid #2d3139;
  padding: 20px;
  overflow-y: auto;
  height: 100vh;
}

.sidebar-controls h2 {
  font-size: 20px;
  color: #38bdf8;
  margin-bottom: 20px;
  font-weight: 700;
}

.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 5px;
  letter-spacing: 0.5px;
}

.help-text {
  font-size: 10px;
  font-weight: 400;
  color: #64748b;
  margin-left: 4px;
}

input[type="text"], input[type="date"], textarea {
  width: 100%;
  background-color: #21252d;
  border: 1px solid #333842;
  border-radius: 6px;
  color: #ffffff;
  padding: 8px 12px;
  font-size: 13px;
  color-scheme: dark;
}

input[type="text"]:focus, input[type="date"]:focus, textarea:focus {
  outline: none;
  border-color: #38bdf8;
}

textarea {
  height: 110px;
  resize: vertical;
  font-family: monospace;
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

button.btn-primary {
  background-color: #0284c7;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

button.btn-success {
  background-color: #e11d48;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

/* AREA ANTEPRIMA (DESTRA) */
.preview-viewport {
  flex: 1;
  background-color: #090a0f;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: auto;
}

/* CONTENITORE ESTERNO PER IL BORDO GRADIENTE HD */
#export-wrapper {
  background: linear-gradient(135deg, #38bdf8, #818cf8, #f43f5e, #22c55e, #fde047);
  padding: 3px; /* Spessore del bordo */
  border-radius: 4px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
  display: inline-block;
}

/* CANVAS REALE */
#preview-canvas {
  width: 920px;
  min-width: 920px;
  min-height: 960px;
  background-color: #0a0c10;
  padding: 25px 30px;
  position: relative;
  box-sizing: border-box;
  border-radius: 2px;
}

/* HEADER CANVAS */
.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1e232d;
  padding-bottom: 8px;
  margin-bottom: 15px;
}

.brand-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
}

.event-meta {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  letter-spacing: 1px;
}

.header-main-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  overflow: hidden;
  background-color: #1e232d;
  flex-shrink: 0;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-meta h1 {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #ffffff;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 6px;
}

.player-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-name {
  font-size: 18px;
  font-weight: 700;
  color: #cbd5e1;
}

.badge-rank {
  background-color: #eab308;
  color: #000000;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

/* WATERMARK LOGO AL CENTRO */
.watermark-container {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.05;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.watermark-logo-img {
  width: 360px;
  height: auto;
  object-fit: contain;
}

/* LAYOUT DECKLIST */
.cards-layout {
  display: flex;
  gap: 24px;
  position: relative;
  z-index: 2;
  align-items: flex-start;
}

.column-mainboard {
  flex: 1;
}

/* MAINBOARD GRID: 5 COLONNE */
.cards-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.card-item {
  position: relative;
  width: 100%;
}

.card-item img {
  width: 100%;
  height: auto;
  border-radius: 5px;
  display: block;
  box-shadow: 0 3px 8px rgba(0,0,0,0.6);
}

.card-qty-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  background: #38bdf8;
  color: #000000;
  font-size: 12px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.8);
  z-index: 3;
}

/* SIDEBOARD A CASCATA */
.column-sideboard-wrapper {
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  width: 185px;
}

.sideboard-label-vertical {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
  background: #1e293b;
  padding: 10px 4px;
  text-align: center;
  border-radius: 4px;
}

.sideboard-stack {
  display: flex;
  flex-direction: column;
  width: 140px;
}

.sideboard-stack .card-item {
  margin-bottom: -130px;
  transition: transform 0.2s;
}

.sideboard-stack .card-item:last-child {
  margin-bottom: 0;
}

/* FOOTER LOGO + INSTAGRAM */
.canvas-footer {
  position: absolute;
  bottom: 15px;
  right: 25px;
  display: flex;
  align-items: center;
  z-index: 10;
}

.footer-social-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-logo-img {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.instagram-handle {
  font-size: 15px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.5px;
}
/* MODALE SELEZIONE */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9, 10, 15, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-box {
  background: #16181d;
  border: 1px solid #2d3139;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.modal-box h2 {
  color: #38bdf8;
  font-size: 26px;
  margin-bottom: 10px;
}

.modal-box p {
  color: #94a3b8;
  margin-bottom: 25px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.btn-primary-lg, .btn-success-lg {
  padding: 15px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: white;
}

.btn-primary-lg { background: #0284c7; }
.btn-success-lg { background: #16a34a; }
.btn-secondary { background: #334155; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.btn-save { background: #eab308; color: black; border: none; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; }

/* TOP NAV EDITOR */
.top-nav {
  background: #16181d;
  padding: 10px 20px;
  border-bottom: 1px solid #2d3139;
  display: flex;
  align-items: center;
  gap: 20px;
}

.editing-status {
  font-weight: 700;
  color: #38bdf8;
}

/* DATABASE VIEW */
.db-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: #16181d;
  border-bottom: 1px solid #2d3139;
}

.db-container {
  display: flex;
  min-height: calc(100vh - 80px);
}

.players-sidebar {
  width: 280px;
  background: #12141a;
  border-right: 1px solid #2d3139;
  padding: 20px;
}

.players-sidebar h3 {
  font-size: 14px;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 15px;
}

.players-menu {
  list-style: none;
}

.players-menu li {
  padding: 12px 15px;
  background: #1e232d;
  margin-bottom: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  transition: background 0.2s;
}

.players-menu li:hover, .players-menu li.active {
  background: #0284c7;
  color: white;
}

.player-details-panel {
  flex: 1;
  padding: 30px;
  background: #090a0f;
}

.deck-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.deck-card-item {
  background: #16181d;
  border: 1px solid #2d3139;
  border-radius: 8px;
  padding: 15px;
  position: relative;
}

.deck-card-item h4 {
  color: #ffffff;
  font-size: 18px;
  margin-bottom: 6px;
}

.deck-card-item .meta-info {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 15px;
}

.deck-actions {
  display: flex;
  gap: 10px;
}

.db-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.deck-actions button {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.btn-edit { background: #38bdf8; color: black; }
.btn-delete { background: #ef4444; color: white; }
.empty-state { color: #64748b; text-align: center; margin-top: 50px; font-size: 16px; }
.btn-duplicate { background: #8b5cf6; color: white; }


/* --- TESTATA (HEADER) --- */
.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  gap: 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Tessera / Banner Carta Iconica (ex Cerchio) */
.iconic-card-wrapper {
  width: 170px;            /* Larghezza tessera rettangolare */
  height: 100px;           /* Altezza tessera */
  border-radius: 10px;     /* Angoli arrotondati anziché cerchio completo */
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  border: 2px solid #ffffff;
}

.iconic-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;       /* Inquadra l'artwork della carta al centro */
  object-position: center 20%; /* Centra la porzione migliore dell'illustrazione */
}

/* Info Giocatore & Archetipo */
.player-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.deck-archetype {
  font-size: 2rem;          /* Dimensione maggiore e dominante */
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
  color: #111827;
}

.player-name-rank {
  font-size: 1.25rem;       /* Ingrandito, ma inferiore all'archetipo (2rem) */
  font-weight: 600;
  color: #374151;           /* Grigio scuro ad alto contrasto */
  margin-top: 4px;
}

/* Dettagli Evento (Destra) */
.event-details {
  text-align: right;
  font-size: 1.1rem;        /* Ingrandito rispetto al precedente */
  font-weight: 600;
  color: #1F2937;           /* Sostituito il grigio chiaro con grigio antracite nitido */
  line-height: 1.4;
}

.event-details span {
  display: block;
}


/* --- FOOTER (IN BASSO A DESTRA) --- */
.footer-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hdemia-logo {
  height: 48px;             /* Ingrandito il logo (es. da 35px a 48px) */
  width: auto;
  object-fit: contain;
}

.social-handle {
  font-size: 1.2rem;        /* Ingrandito il testo dell'handle */
  font-weight: 700;
  color: #111827;
}
/* ==========================================
   FORZATURA STILI BANNER / TESSERA & FOOTER
   ========================================== */

/* 1. TRASFORMAZIONE CARTA ICONICA DA CERCHIO A BANNER/TESSERA */
#preview-canvas #avatar-container,
#preview-canvas .avatar-circle {
  width: 160px !important;
  height: 95px !important;
  border-radius: 8px !important; /* Rettangolo arrotondato anziché tondo */
  overflow: hidden !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4) !important;
  flex-shrink: 0 !important;
}

#preview-canvas #display-avatar {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center 25% !important; /* Inquadra il centro dell'artwork */
  border-radius: 0 !important;
}

/* 2. DETTAGLI EVENTO (DESTRA) - TESTO ANTRACITE SCURO / AD ALTO CONTRASTO */
#preview-canvas #display-event-meta,
#preview-canvas .event-meta {
  color: #111827 !important; /* Grigio scuro/antracite ben visibile */
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  text-align: right !important;
  line-height: 1.3 !important;
}

/* 3. FOOTER - INGRANDIMENTO LOGO E HANDLE SOCIAL */
#preview-canvas .footer-logo-img {
  height: 48px !important; /* Logo più grande */
  width: auto !important;
}

#preview-canvas .instagram-handle {
  font-size: 1.3rem !important; /* Handle @hdemiacento più grande */
  font-weight: 800 !important;
}
/* ==========================================
   AGGIORNAMENTO DETTAGLI EVENTO (TESTO CHIARO)
   ========================================== */

/* Dettagli Evento (Stagione, Data, Tappa) ad ALTO CONTRASTO su sfondo nero */
#preview-canvas #display-event-meta,
#preview-canvas .event-meta {
  color: #ffffff !important; /* Bianco brillante per massima leggibilità su nero */
  font-size: 1.15rem !important;
  font-weight: 800 !important; /* Testo più marcato */
  text-align: right !important;
  line-height: 1.35 !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important; /* Ombra per separarlo dallo sfondo */
}
/* ==========================================
   BILANCIAMENTO DETTAGLI EVENTO (VIA DI MEZZO)
   ========================================== */

#preview-canvas #display-event-meta,
#preview-canvas .event-meta {
  color: #ffffff !important;         /* Bianco nitido */
  font-size: 0.95rem !important;     /* Dimensione bilanciata per stare su una riga */
  font-weight: 700 !important;       /* Bold ben visibile */
  text-align: right !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;    /* Impedisce al testo di andare a capo a metà riga */
}
/* ==========================================
   FIX DEFINTIVO NITIDEZZA HANDLE SOCIAL
   ========================================== */

#preview-canvas .canvas-footer .instagram-handle,
#preview-canvas .footer-social-box span,
.instagram-handle {
  /* Reset completo per eliminare sgranature e sfocature */
  text-shadow: none !important;
  filter: none !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: initial !important;
  
  /* Tipografia nitida e ad alta definizione */
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  letter-spacing: 1.5px !important;
  color: #ffc107 !important; /* Giallo/Oro nitido e brillante della palette H-Demia */
}