/* ================================================================
   style.css — Caccia al Day Zero
   Mobile-first, dark theme, zero dipendenze
   ================================================================ */

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

:root {
    --bg:           #0d0f18;
    --surface:      #161926;
    --surface-2:    #1e2235;
    --surface-3:    #252a42;
    --border:       #2a2f4a;
    --primary:      #6c63ff;
    --primary-d:    #5850e0;
    --primary-glow: rgba(108,99,255,.25);
    --accent:       #00d4aa;
    --gold:         #ffd700;
    --danger:       #ff4d6a;
    --warning:      #ffb347;
    --success:      #4caf82;
    --text:         #e8eaf6;
    --text-2:       #9ba3c9;
    --text-3:       #5a6082;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    5px;
    --shadow:       0 8px 32px rgba(0,0,0,.45);
    --shadow-sm:    0 2px 12px rgba(0,0,0,.3);
    --t:            .18s ease;
    --mono:         'Courier New', monospace;
}

html   { font-size: 16px; scroll-behavior: smooth; }
body   {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.65;
    min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container { width: 100%; max-width: 1060px; margin: 0 auto; padding: 0 1.1rem; }

/* ── Footer ─────────────────────────────────────────────────────── */
.site-footer {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 1rem 0; text-align: center; color: var(--text-3); font-size: .8rem;
    margin-top: auto;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
    margin-bottom: 1.5rem;
}
.card__header {
    padding: 1rem 1.3rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    background: var(--surface-2);
}
.card__header h2, .card__header h3 { font-size: 1rem; font-weight: 700; }
.card__body { padding: 1.3rem; }
.card__body--flush { padding: 0; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .65rem 1.4rem; border: 2px solid transparent; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: all var(--t); text-decoration: none; line-height: 1;
    font-family: inherit;
}
.btn:active                 { transform: translateY(1px); }
.btn--primary               { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn--primary:hover         { background: var(--primary-d); border-color: var(--primary-d); text-decoration: none; }
.btn--primary:disabled      { opacity: .45; cursor: not-allowed; transform: none; }
.btn--outline               { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn--outline:hover         { background: var(--primary); color: #fff; text-decoration: none; }
.btn--ghost                 { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn--ghost:hover           { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn--full                  { width: 100%; }
.btn--large                 { padding: .85rem 2rem; font-size: 1.05rem; }
.btn--sm                    { padding: .4rem .9rem; font-size: .85rem; }
.btn-link                   { color: var(--primary); font-size: .85rem; font-weight: 600; cursor: pointer; background: none; border: none; padding: 0; margin: 0; font-family: inherit; line-height: inherit; appearance: none; -webkit-appearance: none; }
.btn-link:hover             { text-decoration: underline; }
.btn-link--close            { display: block; margin-top: .75rem; color: var(--text-3); font-size: .8rem; }
.btn-logout                 { font-size: .8rem; color: var(--text-3); padding: .3rem .6rem; border-radius: var(--radius-xs); transition: color var(--t); }
.btn-logout:hover           { color: var(--danger); text-decoration: none; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 1.2rem; }
.form-label   {
    display: block; font-size: .8rem; font-weight: 700;
    color: var(--text-2); margin-bottom: .45rem;
    text-transform: uppercase; letter-spacing: .06em;
}
.form-input {
    width: 100%; padding: .7rem 1rem;
    background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 1rem;
    transition: border-color var(--t), box-shadow var(--t); outline: none;
    font-family: inherit;
}
.form-input:focus            { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-input--error           { border-color: var(--danger); }
.form-hint-top               { font-size: .88rem; color: var(--text-2); margin-bottom: 1.2rem; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
    padding: .9rem 1.1rem; border-radius: var(--radius-sm);
    margin-bottom: 1.2rem; font-size: .92rem;
    border-left: 4px solid transparent;
}
.alert p + p               { margin-top: .3rem; }
.alert--error              { background: rgba(255,77,106,.1); border-color: var(--danger);  color: #ffb3be; }
.alert--success            { background: rgba(76,175,130,.1); border-color: var(--success); color: #a8f0cc; }
.alert--info               { background: rgba(108,99,255,.1); border-color: var(--primary); color: #c4c0ff; }
.alert--warning            { background: rgba(255,179,71,.1); border-color: var(--warning); color: #ffe0b2; }

/* ── Tags / Badges ───────────────────────────────────────────────── */
.badge               { display: inline-block; padding: .2rem .7rem; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); }
.badge--success      { background: rgba(76,175,130,.15); border-color: var(--success); color: #a8f0cc; }
.badge--info         { background: rgba(108,99,255,.15); border-color: var(--primary); color: #c4c0ff; }
.tag                 { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .55rem; border-radius: var(--radius-xs); font-size: .78rem; font-weight: 700; }
.tag--success        { background: rgba(76,175,130,.2); color: #a8f0cc; }
.tag--error          { background: rgba(255,77,106,.2); color: #ffb3be; }
.tag--info           { background: rgba(108,99,255,.2); color: #c4c0ff; }
.tag--warning        { background: rgba(255,179,71,.2); color: #ffe0b2; }

/* ── Stats Grid ──────────────────────────────────────────────────── */
.stats-grid         { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card          { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1rem; text-align: center; transition: border-color var(--t); }
.stat-card:hover    { border-color: var(--primary); }
.stat-card--accent  { border-color: rgba(255,215,0,.35); }
.stat-card__value   { font-size: 2rem; font-weight: 900; color: var(--primary); line-height: 1.1; }
.stat-card--accent .stat-card__value { color: var(--gold); }
.stat-card__label   { font-size: .72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-top: .3rem; }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap         { overflow-x: auto; }
.data-table         { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th      { background: var(--surface-2); padding: .7rem 1rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 700; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td      { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table--inner  { background: var(--surface); font-size: .84rem; }
.row--highlighted td { background: rgba(108,99,255,.08); }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-2); }
.text-sm      { font-size: .82rem; }
.text-center  { text-align: center; }
.text-success { color: var(--success); font-weight: 700; }
.text-warning { color: var(--warning); font-weight: 700; }
.text-mono    { font-family: var(--mono); }
.empty-state  { padding: 2.5rem; text-align: center; color: var(--text-2); font-size: .95rem; }

/* ── Mini Progress Bar (tabella) ─────────────────────────────────── */
.mini-progress       { width: 70px; height: 5px; background: var(--surface-3); border-radius: 99px; margin-bottom: .25rem; overflow: hidden; }
.mini-progress__bar  { height: 100%; background: var(--primary); border-radius: 99px; transition: width .5s ease; }

/* ── Tab Nav ─────────────────────────────────────────────────────── */
.tab-nav        { display: flex; gap: .5rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.tab            { padding: .5rem 1.1rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all var(--t); }
.tab:hover      { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tab--active    { background: var(--primary); color: #fff; }
.tab--active:hover { background: var(--primary-d); }

/* ── Detail Panel (admin) ────────────────────────────────────────── */
.detail-row td     { background: var(--surface-2); padding: 0; }
.detail-panel      { padding: 1.2rem 1.5rem; border-top: 2px solid var(--primary); }
.detail-panel h3   { font-size: .95rem; font-weight: 700; margin-bottom: .9rem; color: var(--text-2); }

/* ================================================================
   LANDING PAGE
   ================================================================ */
.page-landing      { background: radial-gradient(ellipse at top, #1a1040 0%, var(--bg) 60%); }

.landing-wrap {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 2rem 1rem;
    gap: 2rem;
}

.landing-hero       { text-align: center; max-width: 560px; }
.hero-badge         { display: inline-block; background: rgba(108,99,255,.2); border: 1px solid rgba(108,99,255,.4); color: #c4c0ff; padding: .35rem .9rem; border-radius: 99px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 1rem; }
.hero-title         { font-size: clamp(2rem, 5vw, 3rem); font-weight: 900; background: linear-gradient(135deg, #fff 0%, var(--primary) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: .75rem; }
.hero-sub           { color: var(--text-2); font-size: 1.05rem; line-height: 1.7; }

.landing-card       { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.8rem; width: 100%; max-width: 480px; box-shadow: var(--shadow); }
.form-title         { font-size: 1.1rem; font-weight: 700; margin-bottom: .4rem; }

.landing-rules      { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.landing-rules h3   { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin-bottom: .7rem; }
.landing-rules ul   { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.landing-rules li   { font-size: .88rem; color: var(--text-2); }

/* ================================================================
   GAME PAGE
   ================================================================ */
.page-game { background: var(--bg); }

/* Game Header */
.game-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .75rem 0; position: sticky; top: 0; z-index: 100;
}
.game-header .container { display: flex; align-items: center; gap: 1rem; }
.game-header__left  { flex: 0 0 auto; }
.game-header__center{ flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.game-header__right { flex: 0 0 auto; display: flex; align-items: center; gap: .75rem; }
.game-logo          { font-size: .85rem; font-weight: 800; color: var(--primary); white-space: nowrap; }
.player-tag         { font-size: .8rem; color: var(--text-2); white-space: nowrap; }

/* Progress Bar */
.progress-bar       { display: flex; gap: 3px; }
.progress-bar__step {
    width: 22px; height: 7px; border-radius: 99px;
    background: var(--surface-3); transition: background var(--t), transform var(--t);
}
.progress-bar__step.done    { background: var(--success); }
.progress-bar__step.current { background: var(--primary); transform: scaleY(1.3); }
.progress-label     { font-size: .72rem; color: var(--text-2); font-weight: 700; }

/* Game Main */
.game-main          { padding-top: 1.5rem; padding-bottom: 3rem; max-width: 760px; }

/* Feedback */
.feedback-card {
    display: flex; align-items: flex-start; gap: 1rem;
    padding: 1rem 1.2rem; border-radius: var(--radius); margin-bottom: 1.5rem;
    border: 1.5px solid transparent;
}
.feedback-card--correct { background: rgba(76,175,130,.12); border-color: var(--success); }
.feedback-card--wrong   { background: rgba(255,77,106,.12); border-color: var(--danger); }
.feedback-icon          { font-size: 1.6rem; flex-shrink: 0; }
.feedback-body strong   { font-size: 1rem; }
.feedback-body p        { font-size: .88rem; color: var(--text-2); margin-top: .3rem; }
.feedback-note          { font-style: italic; }

/* Stage Card */
.stage-card             { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stage-card__header     { padding: 1.4rem 1.5rem; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); border-bottom: 1px solid var(--border); }
.stage-badge            { display: inline-block; background: var(--primary); color: #fff; padding: .25rem .8rem; border-radius: 99px; font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .6rem; }
.stage-title            { font-size: 1.5rem; font-weight: 900; line-height: 1.25; }
.stage-image-wrap       { background: var(--surface-2); }
.stage-image            { width: 100%; max-height: 280px; object-fit: cover; }
.stage-card__body       { padding: 1.5rem; }
.stage-text             { color: var(--text-2); line-height: 1.8; font-size: .97rem; margin-bottom: 1.5rem; }

/* Question */
.stage-question         { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 1.1rem 1.2rem; margin-bottom: 1.5rem; }
.question-label         { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: .5rem; }
.question-text          { font-size: 1.05rem; font-weight: 700; line-height: 1.5; }

/* Options */
.options-grid           { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.5rem; }
.option-label {
    display: flex; align-items: center; gap: .9rem;
    padding: .9rem 1.1rem; background: var(--surface-2); border: 2px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer;
    transition: border-color var(--t), background var(--t), transform var(--t);
}
.option-label:hover { border-color: var(--primary); background: rgba(108,99,255,.08); }
.option-label--selected { border-color: var(--primary); background: rgba(108,99,255,.15); }
.option-radio       { position: absolute; opacity: 0; pointer-events: none; }
.option-letter {
    flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface-3); border: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: .78rem; font-weight: 900; color: var(--text-2);
    transition: all var(--t);
}
.option-label--selected .option-letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-text        { font-size: .95rem; font-weight: 500; }

/* Answer Actions */
.answer-actions     { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.answer-hint        { font-size: .8rem; color: var(--text-3); transition: opacity .3s; }

/* ================================================================
   COMPLETE PAGE
   ================================================================ */
.page-complete  { background: radial-gradient(ellipse at top, #1a1040 0%, var(--bg) 60%); }

.complete-wrap  { padding-top: 2.5rem; padding-bottom: 3rem; }

.complete-hero  {
    text-align: center; padding: 2.5rem 1.5rem; margin-bottom: 1.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.complete-hero--perfect { border-color: var(--gold); background: linear-gradient(135deg, var(--surface), #2a2010); }
.complete-emoji { font-size: 4rem; margin-bottom: .75rem; }
.complete-title { font-size: clamp(1.3rem, 3.5vw, 1.9rem); font-weight: 900; margin-bottom: .5rem; }
.complete-nome  { font-size: 1.2rem; color: var(--text-2); margin-bottom: 1rem; }
.complete-perfect-badge { display: inline-block; background: rgba(255,215,0,.15); border: 1px solid rgba(255,215,0,.5); color: var(--gold); padding: .6rem 1.2rem; border-radius: var(--radius-sm); font-size: .95rem; margin-top: .5rem; }
.complete-score { font-size: 1rem; color: var(--text-2); margin-top: .5rem; }
.complete-score strong { font-size: 1.6rem; color: var(--primary); }
.complete-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }

/* ================================================================
   ADMIN / LOGIN PAGE
   ================================================================ */
.page-admin-login    { background: radial-gradient(ellipse at top, #0f0a2a 0%, var(--bg) 70%); }
.login-wrap          { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.login-card          { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.2rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); text-align: center; }
.login-icon          { font-size: 2.5rem; margin-bottom: .75rem; }
.login-title         { font-size: 1.4rem; font-weight: 900; margin-bottom: .25rem; }
.login-sub           { font-size: .85rem; color: var(--text-2); margin-bottom: 1.5rem; }
.login-form          { text-align: left; }

.page-admin          { background: var(--bg); }
.admin-header        { background: var(--surface); border-bottom: 1px solid var(--border); padding: .9rem 0; position: sticky; top: 0; z-index: 100; }
.admin-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-title         { font-size: 1rem; font-weight: 800; color: var(--primary); }
.admin-header__actions { display: flex; gap: .5rem; align-items: center; }
.admin-main          { padding-top: 1.5rem; padding-bottom: 3rem; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
    .game-header .container { flex-wrap: wrap; justify-content: space-between; }
    .game-header__center    { order: 3; width: 100%; }
    .progress-bar__step     { width: 16px; height: 6px; }
    .stage-title            { font-size: 1.2rem; }
    .question-text          { font-size: .95rem; }
    .option-label           { padding: .75rem .9rem; gap: .7rem; }
    .stats-grid             { grid-template-columns: repeat(2, 1fr); }
    .stat-card__value       { font-size: 1.6rem; }
    .tab-nav                { overflow-x: auto; padding-bottom: .5rem; flex-wrap: nowrap; }
    .admin-header__actions  { gap: .3rem; }
    .btn--sm                { padding: .35rem .65rem; font-size: .78rem; }
}

/* ================================================================
   ADMIN STAGES EDITOR
   ================================================================ */

/* ── Page-level layout ───────────────────────────────────────────── */
.admin-header__left   { display:flex; align-items:center; }
.btn-back             { color:var(--text-2); font-size:.9rem; font-weight:700; display:inline-flex; align-items:center; gap:.35rem; }
.btn-back:hover       { color:var(--text); text-decoration:none; }

.page-h1    { font-size:1.5rem; font-weight:900; line-height:1.2; }
.page-sub   { color:var(--text-2); font-size:.9rem; margin-top:.35rem; }

/* ── Stage list ──────────────────────────────────────────────────── */
.stages-list-header {
    display:flex; align-items:flex-start; justify-content:space-between;
    gap:1rem; margin-bottom:1.5rem; flex-wrap:wrap;
}

.stages-grid {
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap:1rem;
    margin-bottom:1.5rem;
}

.stage-admin-card {
    background:var(--surface); border:2px solid var(--border);
    border-radius:var(--radius); padding:1.2rem;
    display:flex; flex-direction:column; gap:.75rem;
    transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.stage-admin-card:hover           { border-color:var(--primary); transform:translateY(-2px); box-shadow:var(--shadow); }
.stage-admin-card--free           { border-left:4px solid var(--success); }
.stage-admin-card--warm           { border-left:4px solid var(--warning); }
.stage-admin-card--busy           { border-left:4px solid var(--danger); }

.stage-admin-card__head {
    display:flex; align-items:center; justify-content:space-between; gap:.5rem;
}
.stage-admin-card__meta           { display:flex; gap:.35rem; flex-wrap:wrap; }
.stage-admin-card__title          { font-size:1rem; font-weight:800; line-height:1.3; }
.stage-admin-card__preview        { font-size:.82rem; color:var(--text-2); line-height:1.55; flex:1; }
.stage-admin-card__foot {
    display:flex; align-items:center; justify-content:space-between;
    gap:.5rem; flex-wrap:wrap; padding-top:.5rem; border-top:1px solid var(--border);
    margin-top:auto;
}
.warn-hint { font-size:.72rem; color:var(--warning); flex:1; }

.stage-num {
    width:32px; height:32px; border-radius:50%;
    background:var(--primary); color:#fff;
    display:flex; align-items:center; justify-content:center;
    font-size:.85rem; font-weight:900; flex-shrink:0;
}
.stage-num--lg {
    width:48px; height:48px; font-size:1.2rem;
    flex-shrink:0;
}

/* ── Legend ──────────────────────────────────────────────────────── */
.legend-bar {
    display:flex; align-items:center; gap:.4rem; flex-wrap:wrap;
    font-size:.8rem; color:var(--text-2); margin-bottom:1.5rem;
}
.legend-dot            { display:inline-block; width:10px; height:10px; border-radius:50%; }
.legend-dot--free      { background:var(--success); }
.legend-dot--warm      { background:var(--warning); }
.legend-dot--busy      { background:var(--danger); }

/* ── Edit form layout ────────────────────────────────────────────── */
.edit-header {
    display:flex; align-items:center; gap:1rem;
    margin-bottom:1.2rem; flex-wrap:wrap;
}

.edit-form { /* container */ }

.edit-layout {
    display:grid;
    grid-template-columns: 1fr 420px;
    gap:1.5rem;
    align-items:start;
}

.edit-col       { display:flex; flex-direction:column; gap:1.25rem; }

.edit-section {
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius); padding:1.3rem; overflow:hidden;
}
.edit-section__title    { font-size:.9rem; font-weight:800; text-transform:uppercase; letter-spacing:.06em; color:var(--text-2); margin-bottom:1rem; }
.edit-section__sub      { font-size:.84rem; color:var(--text-2); margin-bottom:.9rem; }

.form-textarea--tall    { min-height:160px; resize:vertical; }

.char-count             { display:block; font-size:.75rem; color:var(--text-3); margin-top:.3rem; text-align:right; }

/* ── Image upload ────────────────────────────────────────────────── */
.current-image-wrap     { margin-bottom:.75rem; }
.current-image          { width:100%; max-height:220px; object-fit:cover; border-radius:var(--radius-sm); border:1px solid var(--border); }
.current-image-actions  { display:flex; align-items:center; justify-content:space-between; gap:.5rem; margin-top:.5rem; flex-wrap:wrap; }

.btn--danger-hover:hover { color:var(--danger); border-color:var(--danger); }

.image-placeholder {
    width:100%; height:120px; background:var(--surface-2); border:2px dashed var(--border);
    border-radius:var(--radius-sm); display:flex; flex-direction:column;
    align-items:center; justify-content:center; gap:.4rem;
    color:var(--text-3); font-size:.85rem; margin-bottom:.75rem;
}
.image-placeholder span { font-size:2rem; }

.file-upload-wrap       { display:flex; flex-direction:column; gap:.5rem; }
.file-upload-label {
    display:flex; align-items:center; gap:.6rem;
    padding:.65rem 1rem; background:var(--surface-2);
    border:1.5px dashed var(--border); border-radius:var(--radius-sm);
    cursor:pointer; transition:border-color var(--t), background var(--t);
    font-size:.88rem; color:var(--text-2);
}
.file-upload-label:hover { border-color:var(--primary); background:rgba(108,99,255,.06); color:var(--text); }
.file-upload-input      { position:absolute; opacity:0; pointer-events:none; width:1px; height:1px; }
.file-upload-icon       { font-size:1.1rem; }
.file-name-display      { font-size:.78rem; color:var(--text-3); font-family:var(--mono); padding-left:.3rem; }

/* ── Options editor ──────────────────────────────────────────────── */
.options-editor         { display:flex; flex-direction:column; gap:.65rem; }

.option-editor-row {
    display:flex; align-items:center; gap:.75rem;
    background:var(--surface-2); border:2px solid var(--border);
    border-radius:var(--radius-sm); padding:.65rem .9rem;
    transition:border-color var(--t), background var(--t);
}
.option-editor-row--correct {
    border-color:var(--success);
    background:rgba(76,175,130,.08);
}
.option-editor-row__left  { display:flex; align-items:center; gap:.5rem; flex-shrink:0; }
.option-editor-row__right { flex:1; }

/* Custom radio button */
.correct-radio-wrap   { display:flex; align-items:center; cursor:pointer; }
.correct-radio        { position:absolute; opacity:0; pointer-events:none; width:1px; height:1px; }
.correct-radio-dot {
    width:20px; height:20px; border-radius:50%;
    border:2px solid var(--border); background:var(--surface-3);
    display:flex; align-items:center; justify-content:center;
    transition:all var(--t); flex-shrink:0;
}
.correct-radio:checked + .correct-radio-dot {
    border-color:var(--success); background:var(--success);
    box-shadow:0 0 0 3px rgba(76,175,130,.25);
}
.correct-radio-dot::after {
    content:''; width:8px; height:8px; border-radius:50%;
    background:#fff; opacity:0; transition:opacity var(--t);
}
.correct-radio:checked + .correct-radio-dot::after { opacity:1; }

.option-ltr {
    width:24px; height:24px; border-radius:50%; background:var(--surface-3);
    border:1.5px solid var(--border); display:flex; align-items:center;
    justify-content:center; font-size:.75rem; font-weight:900; color:var(--text-2);
    flex-shrink:0;
}
.option-editor-row--correct .option-ltr { background:var(--success); border-color:var(--success); color:#fff; }

.option-text-input    { border:none; background:transparent; padding:.25rem 0; font-size:.95rem; color:var(--text); outline:none; width:100%; }
.option-text-input:focus { color:var(--text); }
.option-text-input::placeholder { color:var(--text-3); }

.correct-legend { display:flex; align-items:center; gap:.5rem; font-size:.78rem; color:var(--text-3); margin-top:.6rem; }

/* ── Save bar (sticky-ish) ───────────────────────────────────────── */
.edit-save-bar {
    position:sticky; bottom:1rem;
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius); padding:1.1rem;
    box-shadow:var(--shadow); display:flex; flex-direction:column; gap:.6rem;
}

/* ── Responsive editor ───────────────────────────────────────────── */
@media (max-width: 860px) {
    .edit-layout { grid-template-columns:1fr; }
    .edit-col--quiz { order:-1; } /* quiz prima del contenuto su mobile */
    .edit-save-bar { position:static; }
    .stages-grid { grid-template-columns:1fr; }
}

/* ================================================================
   ADMIN PATHS EDITOR
   ================================================================ */

/* ── Lista percorsi ──────────────────────────────────────────────── */
.paths-grid {
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap:1rem;
    margin-bottom:1.5rem;
}

.path-card {
    background:var(--surface); border:2px solid var(--border);
    border-radius:var(--radius); padding:1.2rem;
    display:flex; flex-direction:column; gap:.9rem;
    transition:border-color var(--t), box-shadow var(--t);
}
.path-card:hover              { box-shadow:var(--shadow); }
.path-card--complete          { border-left:4px solid var(--success); }
.path-card--incomplete        { border-left:4px solid var(--warning); }

.path-card__head              { display:flex; align-items:center; justify-content:space-between; gap:.5rem; flex-wrap:wrap; }
.path-card__name              { font-size:1rem; font-weight:800; }

.path-card__stats             { display:flex; gap:1rem; }
.path-stat                    { display:flex; flex-direction:column; align-items:center; min-width:60px; }
.path-stat__val               { font-size:1.3rem; font-weight:900; color:var(--primary); }
.path-stat__label             { font-size:.7rem; color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; }

.path-card__foot              { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding-top:.6rem; border-top:1px solid var(--border); flex-wrap:wrap; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state-card {
    background:var(--surface); border:2px dashed var(--border);
    border-radius:var(--radius); padding:3rem 2rem;
    text-align:center; color:var(--text-2);
}
.empty-state-card h2 { font-size:1.2rem; margin-bottom:.4rem; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,.65);
    display:flex; align-items:center; justify-content:center;
    z-index:1000; padding:1rem;
}
.modal-box {
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius); padding:1.75rem; width:100%; max-width:440px;
    box-shadow:var(--shadow);
}
.modal-title   { font-size:1.1rem; font-weight:800; margin-bottom:1.1rem; }
.modal-actions { display:flex; gap:.75rem; justify-content:flex-end; margin-top:1.25rem; }

/* ── Path editor layout ──────────────────────────────────────────── */
.path-editor-layout {
    display:grid;
    grid-template-columns: 1fr 420px;
    gap:1.5rem;
    align-items:start;
}

.path-editor-col {
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius); overflow:hidden;
}

.path-editor-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:.9rem 1.2rem; background:var(--surface-2);
    border-bottom:1px solid var(--border);
}

.path-editor-hint {
    font-size:.8rem; color:var(--text-3); padding:.6rem 1.2rem;
    border-bottom:1px solid var(--border);
}

/* ── Available stages list ───────────────────────────────────────── */
.available-stages        { max-height:520px; overflow-y:auto; }

.avail-stage {
    display:flex; align-items:center; gap:.75rem;
    padding:.7rem 1.2rem; border-bottom:1px solid var(--border);
    cursor:pointer; transition:background var(--t);
    user-select:none;
}
.avail-stage:hover           { background:rgba(108,99,255,.08); }
.avail-stage:last-child      { border-bottom:none; }
.avail-stage--used           { opacity:.4; cursor:not-allowed; background:transparent !important; }
.avail-num  {
    width:26px; height:26px; border-radius:50%; background:var(--surface-3);
    border:1.5px solid var(--border); display:flex; align-items:center; justify-content:center;
    font-size:.72rem; font-weight:900; color:var(--text-2); flex-shrink:0;
}
.avail-title { flex:1; font-size:.9rem; font-weight:600; }
.avail-add-icon { color:var(--primary); font-size:1.1rem; flex-shrink:0; opacity:.6; }
.avail-stage:not(.avail-stage--used):hover .avail-add-icon { opacity:1; }

/* ── Path slots ──────────────────────────────────────────────────── */
.path-slots { padding:.6rem; display:flex; flex-direction:column; gap:.4rem; min-height:400px; }

.path-slot {
    display:flex; align-items:center; gap:.6rem;
    padding:.6rem .8rem; border-radius:var(--radius-sm); border:1.5px solid var(--border);
    transition:all var(--t);
}
.path-slot--empty  { background:var(--surface-2); border-style:dashed; color:var(--text-3); }
.path-slot--filled { background:var(--surface-2); cursor:grab; border-color:var(--border); }
.path-slot--filled:hover { border-color:var(--primary); }
.path-slot.dragging    { opacity:.5; border-style:dashed; }
.path-slot.drag-over   { border-color:var(--accent); background:rgba(0,212,170,.08); transform:scale(1.01); }

.slot-pos  {
    width:24px; height:24px; border-radius:50%; background:var(--primary); color:#fff;
    display:flex; align-items:center; justify-content:center;
    font-size:.72rem; font-weight:900; flex-shrink:0;
}
.path-slot--empty .slot-pos { background:var(--surface-3); color:var(--text-3); }

.slot-num  { font-size:.72rem; color:var(--text-3); flex-shrink:0; font-family:var(--mono); min-width:24px; }
.slot-title { flex:1; font-size:.88rem; font-weight:600; }
.slot-placeholder { flex:1; font-size:.82rem; font-style:italic; }

.slot-actions { display:flex; gap:2px; flex-shrink:0; }
.slot-btn {
    width:24px; height:24px; border-radius:var(--radius-xs);
    background:var(--surface-3); border:1px solid var(--border);
    color:var(--text-2); font-size:.75rem; cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    transition:all var(--t);
    /* reset stili nativi browser per <button> */
    padding:0; margin:0; line-height:1;
    font-family:inherit; appearance:none; -webkit-appearance:none;
    box-sizing:border-box; flex-shrink:0;
}
.slot-btn:hover:not(:disabled)        { background:var(--primary); color:#fff; border-color:var(--primary); }
.slot-btn--remove:hover:not(:disabled){ background:var(--danger);  color:#fff; border-color:var(--danger); }
.slot-btn:disabled                    { opacity:.3; cursor:not-allowed; }

/* ── Completeness badge ──────────────────────────────────────────── */
.path-completeness {
    font-size:.95rem; font-weight:800; color:var(--text-2);
    padding:.4rem .9rem; border-radius:var(--radius-sm);
    background:var(--surface-2); border:1.5px solid var(--border);
    white-space:nowrap; transition:all var(--t);
}
.path-completeness--ok { color:var(--success); border-color:var(--success); background:rgba(76,175,130,.12); }

/* ── Save bar ────────────────────────────────────────────────────── */
.path-save-bar {
    padding:1rem; border-top:1px solid var(--border);
    display:flex; flex-direction:column; gap:.6rem;
    background:var(--surface-2);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width:860px) {
    .path-editor-layout { grid-template-columns:1fr; }
    .available-stages   { max-height:280px; }
    .path-slots         { min-height:auto; }
    .paths-grid         { grid-template-columns:1fr; }
}

/* ================================================================
   DASHBOARD — CLASSIFICA & RESET
   ================================================================ */

/* ── Bottone danger ──────────────────────────────────────────────── */
.btn--danger {
    background: var(--danger); color: #fff; border: 1.5px solid var(--danger);
    padding: .45rem 1rem; border-radius: var(--radius-sm);
    font-weight: 700; font-size: .85rem; cursor: pointer;
    transition: all var(--t); font-family: inherit;
    appearance: none; -webkit-appearance: none;
}
.btn--danger:hover { background: #e0304a; border-color: #e0304a; }

/* ── Modal danger variant ────────────────────────────────────────── */
.modal-box--danger { border-top: 4px solid var(--danger); }

/* ── Winner banner ───────────────────────────────────────────────── */
.winner-banner {
    display: flex; align-items: center; gap: 1.25rem;
    background: linear-gradient(135deg, #2a2000 0%, #1a1600 100%);
    border: 2px solid var(--gold); border-radius: var(--radius);
    padding: 1.3rem 1.5rem; margin-bottom: 1.25rem;
    box-shadow: 0 0 32px rgba(255,215,0,.15);
}
.winner-banner__trophy  { font-size: 2.8rem; flex-shrink: 0; }
.winner-banner__label   { font-size: .7rem; font-weight: 900; letter-spacing: .12em; color: var(--gold); text-transform: uppercase; }
.winner-banner__name    { font-size: 1.5rem; font-weight: 900; color: #fff; line-height: 1.2; margin: .15rem 0; }
.winner-banner__detail  { font-size: .85rem; color: var(--text-2); }

/* ── Ranking table rows ──────────────────────────────────────────── */
.row--winner td          { background: rgba(255,215,0,.05); }
.ranking-pos             { font-size: 1.3rem; min-width: 48px; }
.rank-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface-3); border: 1.5px solid var(--border);
    font-size: .8rem; font-weight: 800; color: var(--text-2);
}
