/* Tiro con l'Arco 3D - prefisso .ar- per non collidere con gli altri tool */

.ar-app { max-width: 1180px; margin: 0 auto; padding: 18px 14px 60px; color: #0f172a; }

/* display:flex/grid vincono sull'attributo hidden: qui lo rimettiamo al comando */
.ar-app [hidden] { display: none !important; }

.ar-hero { text-align: center; margin-bottom: 18px; }
.ar-hero h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); margin: 0 0 8px; line-height: 1.15; }
.ar-hero p { margin: 0 auto; max-width: 780px; color: #475569; font-size: 1.02rem; line-height: 1.55; }

/* --- palco 3D --------------------------------------------------------- */
.ar-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 380px;
    border-radius: 18px;
    overflow: hidden;
    background: #9cc9ef;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .35);
    touch-action: none;
    user-select: none; -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.ar-stage:fullscreen { border-radius: 0; aspect-ratio: auto; height: 100%; }
.ar-stage.is-dragover { outline: 4px dashed #facc15; outline-offset: -8px; }
#arCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

@media (max-width: 700px) and (orientation: portrait) {
    .ar-stage { aspect-ratio: 3 / 4; }
}

/* mirino */
.ar-cross {
    position: absolute; left: 50%; top: 50%; width: 34px; height: 34px;
    transform: translate(-50%, -50%); pointer-events: none;
    border: 2px solid rgba(255, 255, 255, .9); border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(0, 0, 0, .25);
    transition: width .15s, height .15s, border-color .15s;
}
.ar-cross::before, .ar-cross::after {
    content: ''; position: absolute; left: 50%; top: 50%; background: rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.ar-cross::before { width: 2px; height: 52px; transform: translate(-50%, -50%); }
.ar-cross::after  { width: 52px; height: 2px; transform: translate(-50%, -50%); }
.ar-cross i {
    position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; border-radius: 50%;
    background: #ff3b3b; transform: translate(-50%, -50%); z-index: 1;
}
.ar-cross.is-on-target { border-color: #facc15; }
.ar-cross.is-drawing { width: 26px; height: 26px; }

/* --- HUD -------------------------------------------------------------- */
.ar-hud {
    position: absolute; inset: 0; pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 12px; font-variant-numeric: tabular-nums;
}
.ar-hud-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.ar-chip {
    background: rgba(8, 13, 28, .6); color: #fff; border-radius: 999px;
    padding: 7px 13px; font-size: .88rem; font-weight: 700;
    backdrop-filter: blur(6px); white-space: nowrap;
}
.ar-chip small { font-weight: 500; opacity: .75; }
.ar-wind-arrow { display: inline-block; font-style: normal; color: #7dd3fc; transition: transform .4s; }
.ar-hud-right { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; }
.ar-icon-btn {
    min-width: 46px; height: 46px; border-radius: 13px; border: 0; cursor: pointer;
    background: rgba(8, 13, 28, .6); color: #fff; font-size: 1.12rem;
    backdrop-filter: blur(6px); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.ar-icon-btn:hover { background: rgba(8, 13, 28, .85); }
.ar-icon-btn.is-off { opacity: .55; }
.ar-icon-wide { padding: 0 14px; font-size: .95rem; font-weight: 700;
    background: linear-gradient(135deg, #f97316, #e11d48); }
.ar-icon-wide:hover { background: linear-gradient(135deg, #fb923c, #f43f5e); }

.ar-hud-center { position: absolute; left: 0; right: 0; top: calc(50% + 40px); display: flex; justify-content: center; }
.ar-aim-chip { font-size: .85rem; }
.ar-hud-bottom { display: flex; justify-content: center; }
.ar-power {
    width: min(320px, 60%); height: 12px; border-radius: 999px; margin-bottom: 8px;
    background: rgba(8, 13, 28, .55); overflow: hidden; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
}
.ar-power i { display: block; height: 100%; width: 0; border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #facc15 70%, #ef4444); }

/* punteggio che vola via dal mirino */
.ar-float {
    position: absolute; left: 50%; top: 42%; transform: translate(-50%, 0);
    font-size: clamp(1.8rem, 6vw, 3.2rem); font-weight: 900; color: #fff;
    text-shadow: 0 4px 18px rgba(0, 0, 0, .55), 0 0 2px rgba(0, 0, 0, .6);
    pointer-events: none; opacity: 0; white-space: nowrap;
}
.ar-float.is-on { animation: arFloat 1.3s ease-out forwards; }
.ar-float.is-gold { color: #fde047; }
@keyframes arFloat {
    0%   { opacity: 0; transform: translate(-50%, 10px) scale(.6); }
    15%  { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
    30%  { transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

.ar-toast {
    position: absolute; left: 50%; top: 70px; transform: translate(-50%, -8px);
    background: rgba(8, 13, 28, .8); color: #fff; padding: 9px 18px; max-width: 90%;
    border-radius: 999px; font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s;
    pointer-events: none; text-align: center;
}
.ar-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* cornice della telecamera sulla freccia: il riquadro lo disegna WebGL, qui solo bordo ed etichetta */
.ar-pip-label {
    position: absolute; box-sizing: border-box; pointer-events: none;
    border: 2px solid rgba(255, 255, 255, .75); border-radius: 6px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
    color: #fff; font-size: .75rem; font-weight: 800; padding: 4px 8px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

/* zoom: grande e in basso a sinistra, raggiungibile col pollice */
.ar-dock { position: absolute; left: 14px; bottom: 14px; }
.ar-pad {
    min-width: 76px; height: 64px; border-radius: 20px; padding: 0 14px;
    border: 2px solid rgba(255, 255, 255, .4); background: rgba(8, 13, 28, .5);
    color: #fff; font-size: 1.05rem; font-weight: 800; cursor: pointer;
    backdrop-filter: blur(4px); touch-action: manipulation;
}
.ar-pad.is-active { background: rgba(250, 204, 21, .55); border-color: #fde047; }

/* --- overlay ---------------------------------------------------------- */
.ar-overlay {
    position: absolute; inset: 0; z-index: 5; overflow: auto;
    background: linear-gradient(180deg, rgba(6, 10, 24, .86), rgba(6, 10, 24, .95));
    color: #e9eefb; padding: 22px 18px; backdrop-filter: blur(5px);
    touch-action: pan-y;
}
.ar-overlay h2 { margin: 0 0 4px; font-size: clamp(1.3rem, 3.4vw, 1.9rem); }
.ar-sub { opacity: .78; margin: 0 0 16px; font-size: .95rem; line-height: 1.45; }

.ar-panel { max-width: 640px; margin: 2vh auto 0; text-align: center; }
.ar-big-emoji { font-size: 3rem; line-height: 1; margin-bottom: 6px; }
.ar-howto { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 16px; text-align: left; }
.ar-howto div {
    background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.ar-howto b { font-size: .95rem; }
.ar-howto span { font-size: .84rem; opacity: .8; line-height: 1.35; }

.ar-diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.ar-diff-btn {
    border: 2px solid rgba(255, 255, 255, .15); border-radius: 14px; padding: 12px 10px;
    min-height: 64px; background: rgba(255, 255, 255, .06); color: #fff; cursor: pointer;
    display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.ar-diff-btn small { opacity: .75; font-size: .76rem; line-height: 1.3; }
.ar-diff-btn.is-active { border-color: #facc15; background: rgba(250, 204, 21, .16); }

.ar-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ar-btn {
    border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: .96rem;
    cursor: pointer; min-height: 48px; background: rgba(255, 255, 255, .14); color: #fff;
}
.ar-btn:hover { background: rgba(255, 255, 255, .24); }
.ar-btn.is-primary { background: linear-gradient(135deg, #f97316, #e11d48); }
.ar-btn.is-primary:hover { filter: brightness(1.1); }
.ar-btn.is-danger { background: rgba(239, 68, 68, .22); color: #fecaca; }

.ar-keys { margin-top: 16px; font-size: .84rem; opacity: .8; line-height: 2; }
.ar-keys kbd {
    background: rgba(255, 255, 255, .16); border-radius: 6px; padding: 3px 8px;
    font-family: inherit; font-weight: 700; margin: 0 2px;
}

/* --- elenco bersagli ------------------------------------------------- */
.ar-photos-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.ar-photos-head > div:first-child { flex: 1 1 320px; }
.ar-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.ar-slot {
    position: relative; border: 1px solid rgba(255, 255, 255, .14); border-radius: 16px;
    background: rgba(255, 255, 255, .05); padding: 10px; cursor: pointer; color: #fff;
    display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    transition: transform .15s, border-color .15s;
}
.ar-slot:hover { transform: translateY(-3px); border-color: #fb923c; }
.ar-slot canvas { width: 100%; max-width: 110px; aspect-ratio: 1; border-radius: 50%;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
.ar-slot-n { position: absolute; top: 8px; left: 10px; font-weight: 900; font-size: .9rem;
    background: rgba(8, 13, 28, .75); border-radius: 8px; padding: 1px 7px; }
.ar-slot-d { font-size: .8rem; opacity: .75; }
.ar-slot-a { font-size: .82rem; font-weight: 700; color: #fdba74; }
.ar-slot-h { position: absolute; top: 8px; right: 10px; font-size: .75rem; font-weight: 700;
    background: rgba(34, 197, 94, .3); border-radius: 8px; padding: 1px 7px; }

/* --- editor foto ----------------------------------------------------- */
.ar-editor { max-width: 560px; margin: 0 auto; text-align: center; }
.ar-ed-canvas-wrap { display: flex; justify-content: center; margin-bottom: 12px; }
#arEdCanvas {
    width: min(100%, 360px); aspect-ratio: 1; border-radius: 18px; cursor: grab;
    background: repeating-conic-gradient(#1e293b 0 25%, #0f172a 0 50%) 50% / 24px 24px;
    touch-action: none;
}
#arEdCanvas:active { cursor: grabbing; }
.ar-ed-controls { display: grid; gap: 10px; margin-bottom: 14px; }
.ar-ed-row { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: .92rem; }
.ar-ed-row > span { min-width: 110px; text-align: left; }
.ar-ed-row input[type=range] { flex: 1; height: 36px; accent-color: #f97316; }
.ar-ed-btns { flex-wrap: wrap; justify-content: center; gap: 8px; }
.ar-ed-btns .ar-btn { padding: 10px 14px; }
.ar-ed-rings { flex-wrap: wrap; }
.ar-seg {
    flex: 1; min-height: 44px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .15);
    background: rgba(255, 255, 255, .06); color: #fff; font-weight: 700; cursor: pointer;
}
.ar-seg.is-active { border-color: #facc15; background: rgba(250, 204, 21, .16); }

/* sugli schermi larghi il palco e' basso: foto a sinistra, comandi a destra */
@media (min-width: 760px) {
    .ar-editor {
        max-width: 920px; text-align: left; display: grid; column-gap: 24px; align-items: start;
        grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
        grid-template-areas: "t t" "s s" "c k" "c a";
    }
    .ar-editor h2 { grid-area: t; }
    .ar-editor .ar-sub { grid-area: s; margin-bottom: 12px; }
    .ar-editor .ar-ed-canvas-wrap { grid-area: c; margin: 0; }
    .ar-editor .ar-ed-controls { grid-area: k; }
    .ar-editor .ar-actions { grid-area: a; justify-content: flex-start; }
    #arEdCanvas { width: min(100%, 380px, calc(100vh - 220px)); }
    .ar-stage:not(:fullscreen) #arEdCanvas { max-width: 360px; }
}

.ar-nowebgl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; text-align: center; padding: 30px; background: #0b1020; z-index: 9; }

@media (max-width: 640px) {
    .ar-howto { grid-template-columns: 1fr; }
    .ar-diff { grid-template-columns: 1fr; }
    .ar-diff-btn { min-height: 54px; }
    .ar-chip { padding: 6px 10px; font-size: .8rem; }
    .ar-chip small { display: none; }
    .ar-icon-wide span { display: none; }
    .ar-ed-row > span { min-width: 88px; }
}

/* --- testo sotto il palco -------------------------------------------- */
.ar-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0; }
.ar-help > div { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 16px 18px; }
.ar-help h3 { margin: 0 0 6px; font-size: 1.05rem; }
.ar-help p { margin: 0; color: #475569; font-size: .93rem; line-height: 1.55; }

.ar-seo { max-width: 860px; margin: 26px auto 0; line-height: 1.65; color: #334155; }
.ar-seo h2 { font-size: 1.45rem; color: #0f172a; }
.ar-seo h3 { font-size: 1.12rem; color: #0f172a; margin-top: 20px; }

[data-theme="dark"] .ar-app { color: #e2e8f0; }
[data-theme="dark"] .ar-hero p, [data-theme="dark"] .ar-seo { color: #94a3b8; }
[data-theme="dark"] .ar-seo h2, [data-theme="dark"] .ar-seo h3 { color: #f1f5f9; }
[data-theme="dark"] .ar-help > div { background: #111827; border-color: #1f2937; }
[data-theme="dark"] .ar-help p { color: #94a3b8; }
