:root {
    color-scheme: light;
    --paper: #f5f0e7;
    --ink: #3d3732;
    --muted: #776c63;
    --wine: #803948;
    --wine-dark: #662b38;
    --line: #dcd1c3;
    --white: #fffdf8;
    --sage: #68725b;
    --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; min-width: 280px; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .14; z-index: -1; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.45' filter='url(%23n)'/%3E%3C/svg%3E"); }
a { color: inherit; }
button, input, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
button, a, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #a95a6b; outline-offset: 5px; }
.site-header { max-width: 1320px; margin: 0 auto; padding: 30px 56px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-family: var(--serif); font-size: 22px; letter-spacing: -.4px; }
.brand-icon { font-family: Georgia, serif; font-size: 33px; color: var(--wine); line-height: 1; }
.header-note { margin-left: auto; font-size: 9px; letter-spacing: 2.2px; color: var(--muted); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--wine); font-size: 25px; display: inline-grid; place-items: center; flex-shrink: 0; line-height: 1; }
.icon-button:hover { background: #eae0d4; }
.login-layout { max-width: 1210px; margin: 0 auto; padding: 66px 56px 74px; display: grid; grid-template-columns: 1fr 1fr; gap: 100px; align-items: center; }
.eyebrow { display: block; color: var(--wine); font-size: 10px; font-weight: 650; letter-spacing: 2.5px; line-height: 1.8; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(43px, 4.6vw, 65px); line-height: 1.06; letter-spacing: -1.8px; margin: 24px 0; text-wrap: balance; }
h2 { font-family: var(--serif); font-size: 32px; line-height: 1.2; font-weight: 400; letter-spacing: -.8px; margin: 12px 0 18px; }
p { margin: 0 0 20px; }
.intro-text { color: var(--muted); font-size: 15px; line-height: 1.8; max-width: 390px; }
.little-divider { display: flex; gap: 16px; align-items: center; width: 140px; color: #9a7e5e; margin: 25px 0; }
.little-divider span:first-child, .little-divider span:last-child { height: 1px; background: var(--line); flex: 1; }
.form-intro { font-family: var(--serif); font-size: 21px; margin-bottom: 18px; }
.login-form { max-width: 375px; }
label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 7px; }
input:not([type='checkbox']), textarea { width: 100%; border: 1px solid #cfc2b3; border-radius: 5px; background: #fffdf77a; min-height: 47px; padding: 11px 14px; color: var(--ink); margin-bottom: 17px; font-size: 16px; }
input::placeholder { color: #978b81; font-size: 13px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 20px; border-radius: 5px; min-height: 50px; padding: 13px 22px; text-decoration: none; border: 1px solid transparent; font-size: 13px; font-weight: 550; line-height: 1.5; transition: background .2s, transform .2s; }
.button.primary { background: var(--wine); color: #fffcf6; }
.button.primary:hover { background: var(--wine-dark); transform: translateY(-1px); }
.button.secondary { border-color: var(--line); background: transparent; color: var(--ink); }
.button.secondary:hover { background: #ebe1d5; }
.login-form .button { width: 100%; justify-content: space-between; margin-top: 3px; }
.password-field { position: relative; margin-bottom: 17px; }
.login-form .password-field #password { margin-bottom: 0; padding-right: 55px; }
.login-form .password-field #password-toggle { position: absolute !important; right: 8px !important; top: 50% !important; transform: translateY(-50%) !important; width: 35px !important; height: 35px !important; min-height: 0 !important; border: 0 !important; border-radius: 50% !important; background: transparent !important; color: var(--muted) !important; display: grid !important; place-items: center !important; padding: 0 !important; margin: 0 !important; line-height: 1 !important; }
.login-form .password-field #password-toggle svg { display: block !important; width: 19px !important; height: 19px !important; fill: none !important; stroke: currentColor !important; stroke-width: 1.7 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }
.login-form .password-field #password-toggle:hover { background: #efe5d9 !important; color: var(--wine) !important; }
.small-note { font-size: 11px; color: var(--muted); line-height: 1.8; margin: 16px 0 0; }
.cover-scene { position: relative; padding: 38px 0 56px; }
.polaroid { margin: 0; padding: 13px 13px 0; background: var(--white); box-shadow: 0 14px 40px #4b35251a, 0 1px 5px #4b352516; transform: rotate(-3deg); position: relative; }
.polaroid::before { content: ''; display: block; width: 99px; height: 27px; position: absolute; top: -11px; left: calc(50% - 49px); background: #ded1b9b3; transform: rotate(-5deg); z-index: 1; }
.polaroid img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 4.6; object-fit: cover; background: #d6ccbc; }
.polaroid figcaption { color: #736455; font-family: var(--serif); font-style: italic; text-align: center; padding: 22px 5px 26px; font-size: 16px; line-height: 1.4; }
.handwritten { font-family: var(--serif); font-style: italic; color: var(--wine); font-size: 19px; }
.top-note { position: absolute; right: 0; top: -8px; transform: rotate(4deg); }
.round-stamp { border: 1px solid #91505c; border-radius: 50%; color: var(--wine); width: 112px; height: 112px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 8px; line-height: 1.4; letter-spacing: 1.3px; position: absolute; bottom: 45px; right: -33px; background: #f5f0e7ed; transform: rotate(15deg); outline: 1px solid #91505c; outline-offset: -6px; }
.round-stamp b { font-size: 34px; font-weight: 400; line-height: 1.25; }
.scene-caption { position: absolute; bottom: -10px; left: 18px; font-size: 9px; letter-spacing: 2px; line-height: 1.9; color: var(--muted); }
.site-footer { max-width: 1208px; border-top: 1px solid var(--line); padding: 23px 0; margin: 0 auto; display: flex; justify-content: space-between; gap: 18px; align-items: center; font-size: 8px; letter-spacing: 1.9px; color: var(--muted); }
.site-footer > span:nth-child(2) { font-size: 21px; color: var(--wine); }
.hunt-shell { max-width: 1130px; margin: 0 auto; padding: 45px 48px 70px; min-height: calc(100svh - 193px); }
.hunt-shell:focus { outline: none; }
.welcome-grid, .final-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 90px; align-items: center; padding: 37px 0; }
.welcome-grid h1 { font-size: clamp(43px, 4.8vw, 65px); }
.how-it-works { margin: 28px 0 31px; }
.how-it-works p { margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.how-it-works span { margin-right: 13px; font-family: var(--serif); color: var(--wine); font-size: 17px; }
.photo-wrap { padding: 8px 15px; position: relative; }
.photo-heart { position: absolute; font: 83px var(--serif); color: var(--wine); right: -8px; bottom: -17px; transform: rotate(18deg); }
.journey-top { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.progress-count { color: var(--muted); font-size: 11px; }
.journey-track { display: flex; padding: 0; list-style: none; margin: 24px 0 45px; gap: 10px; }
.journey-track li { display: flex; align-items: center; flex: 1; gap: 10px; color: #897c70; }
.journey-track li::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.journey-track li:last-child { flex: 0; }
.journey-track li:last-child::after { display: none; }
.journey-track li > span:first-child { font-size: 10px; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; }
.journey-track li.current > span:first-child { border-color: var(--wine); color: var(--wine); }
.journey-track li.done > span:first-child { background: var(--wine); border-color: var(--wine); color: white; }
.stage-grid { display: grid; grid-template-columns: .94fr 1fr; gap: 95px; align-items: center; }
.stage-photo-wrap { position: relative; padding: 0 5px 33px; }
.stage-photo-wrap .polaroid { transform: rotate(-2deg); }
.photo-number { position: absolute; bottom: -10px; right: 10px; font-family: var(--serif); font-size: 18px; font-style: italic; color: var(--wine); transform: rotate(-4deg); }
.stage-copy h1 { font-size: clamp(40px, 4.4vw, 58px); }
.clue { font-family: var(--serif); font-size: 22px; line-height: 1.65; color: #685a50; margin: 24px 0 32px; white-space: pre-line; }
.gps-status { font-size: 12px; color: var(--muted); line-height: 1.8; margin: 19px 0 0; min-height: 43px; }
.stage-bottom { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 32px; }
.success-seal { width: 62px; height: 62px; border-radius: 50%; border: 1px solid #bd9399; color: var(--wine); font: 40px var(--serif); display: grid; place-items: center; margin-top: 23px; animation: bloom .8s ease both; }
.success-note { font-size: 12px; color: var(--sage); }
.final-grid { gap: 65px; padding-top: 5px; }
.final-letter { font-family: var(--serif); font-size: 19px; line-height: 1.75; white-space: pre-line; }
.final-spark { color: var(--wine); letter-spacing: 12px; font-size: 30px; margin-bottom: 24px; animation: float 5s ease-in-out infinite; }
.final-photo { transform: rotate(3deg); animation: reveal 1.2s ease both; }
.time-keepsake { display: flex; flex-direction: column; gap: 6px; padding: 18px 0 0; margin-top: 28px; border-top: 1px solid var(--line); }
.time-keepsake span { font-size: 9px; letter-spacing: 2px; color: var(--muted); }
.time-keepsake strong { font-family: var(--serif); color: var(--wine); font-size: 26px; font-weight: 400; }
.text-button { background: none; border: 0; padding: 10px 0; min-height: 44px; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; color: var(--wine); }
.notice { padding: 13px 16px; background: #e8ecdf; border-radius: 5px; font-size: 13px; }
.notice.error { background: #f1e0df; color: #732c3a; }
.storage-warning { background: #f7dfb6; padding: 12px 20px; text-align: center; font-size: 12px; }
dialog { width: min(540px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 13px; padding: 27px; background: var(--paper); color: var(--ink); max-height: calc(100svh - 48px); box-shadow: 0 25px 90px #21130e40; overscroll-behavior: contain; }
dialog::backdrop { background: #2e251db3; backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; }
dialog .small-note { margin: 0 0 16px; }
.admin-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 15px 0; }
.admin-grid .button { flex: 1 1 180px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 12px 0; cursor: pointer; }
input[type='checkbox'] { width: 19px; height: 19px; accent-color: var(--wine); flex-shrink: 0; }
.debug-data { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.9 ui-monospace, monospace; background: #e8e0d5; padding: 15px; border-radius: 6px; margin: 8px 0 20px; }
.hash-tools { font-size: 12px; border-block: 1px solid var(--line); padding: 16px 0; }
.hash-tools summary { cursor: pointer; min-height: 30px; }
.hash-tools .small-note { margin-top: 16px; }
.hash-tools textarea { margin: 0; font-family: monospace; font-size: 12px; overflow-wrap: anywhere; resize: vertical; }
.hash-tools button { margin-bottom: 15px; }
.admin-bottom { display: flex; justify-content: space-between; gap: 18px; margin-top: 15px; }
.danger { color: #a2303d; }
.logout-form { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes bloom { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes reveal { from { opacity: 0; transform: translateY(18px) rotate(0); } to { opacity: 1; transform: translateY(0) rotate(3deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (min-width: 1500px) { .login-layout { padding-block: 80px; } }
@media (max-width: 1000px) {
    .site-header { padding: 24px 32px; }
    .login-layout { gap: 55px; padding: 50px 40px 65px; }
    .site-footer { margin-inline: 32px; }
    .hunt-shell { padding-inline: 38px; }
    .welcome-grid, .stage-grid, .final-grid { gap: 50px; }
    .round-stamp { right: -17px; }
}
@media (max-width: 700px) {
    .site-header { padding: 18px 22px; gap: 10px; }
    .brand { font-size: 20px; gap: 9px; }
    .brand-icon { font-size: 29px; }
    .header-note { display: none; }
    .site-header .icon-button { margin-left: auto; width: 38px; height: 38px; }
    .login-layout { grid-template-columns: 1fr; padding: 39px 28px 45px; gap: 34px; max-width: 480px; }
    h1 { font-size: 49px; margin: 20px 0; }
    .intro-text { font-size: 14px; }
    .login-form { max-width: none; }
    .cover-scene { max-width: 310px; margin: 0 auto; width: 100%; padding: 30px 0 42px; }
    .cover-photo img { aspect-ratio: 4 / 3.6; }
    .top-note { font-size: 16px; top: 0; }
    .round-stamp { width: 90px; height: 90px; font-size: 6px; right: -12px; bottom: 40px; }
    .round-stamp b { font-size: 28px; }
    .polaroid figcaption { font-size: 15px; padding-block: 18px 21px; }
    .site-footer { padding-block: 18px; margin-inline: 22px; font-size: 7px; letter-spacing: 1px; gap: 10px; }
    .site-footer span:first-child { max-width: 130px; }
    .site-footer span:last-child { text-align: right; max-width: 100px; }
    .hunt-shell { padding: 32px 26px 42px; max-width: 480px; }
    .welcome-grid, .stage-grid, .final-grid { grid-template-columns: 1fr; gap: 37px; padding: 0; }
    .welcome-grid h1 { font-size: 47px; }
    .photo-wrap { max-width: 340px; width: 100%; margin: auto; padding: 10px 14px; }
    .welcome-photo img { aspect-ratio: 4 / 3.5; }
    .journey-top { align-items: flex-start; gap: 20px; }
    .journey-top .eyebrow { max-width: 160px; font-size: 8px; }
    .progress-count { text-align: right; max-width: 110px; font-size: 10px; }
    .journey-track { margin: 18px 0 32px; gap: 7px; overflow-x: auto; }
    .journey-track li { gap: 7px; min-width: 34px; }
    .journey-track li > span:first-child { width: 28px; height: 28px; flex-shrink: 0; }
    .stage-photo-wrap { padding: 0 7px 18px; max-width: 340px; width: 100%; margin-inline: auto; }
    .stage-photo-wrap img { aspect-ratio: 4 / 3; }
    .photo-number { font-size: 15px; bottom: -14px; }
    .stage-copy h1 { font-size: 42px; margin: 16px 0; }
    .stage-copy .eyebrow { font-size: 9px; }
    .clue { font-size: 20px; line-height: 1.55; margin: 20px 0 24px; }
    .stage-copy > .button, .welcome-copy > .button { width: 100%; }
    .stage-bottom { margin-top: 24px; }
    .final-letter { font-size: 19px; }
    .final-copy h1 { font-size: 50px; }
    .final-spark { margin-top: 5px; }
    dialog { padding: 22px; }
    dialog h2 { font-size: 29px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---- Ritocchi per telefono ---- */
.stage-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 16px; }
.stage-bottom #music-status { flex-basis: 100%; }
@media (max-width: 700px) {
    .site-header, .hunt-shell, .login-layout { padding-left: max(var(--pad-x), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad-x), env(safe-area-inset-right, 0px)); }
    .site-footer { padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 700px) {
    .site-header { --pad-x: 22px; }
    .login-layout { --pad-x: 28px; }
    .hunt-shell { --pad-x: 26px; }
    /* Le foto delle tappe sono verticali: niente taglio orizzontale */
    .stage-photo-wrap img { aspect-ratio: 4 / 5; max-height: 62svh; }
    .final-photo img { aspect-ratio: 4 / 5; max-height: 66svh; }
    /* Cuore piu piccolo e fuori dalla didascalia */
    .photo-heart { font-size: 54px; right: -6px; bottom: -26px; }
    .photo-wrap { padding-bottom: 22px; }
    .polaroid figcaption { padding-inline: 18px; }
    /* Testi piccoli leggibili */
    .eyebrow, .journey-top .eyebrow, .stage-copy .eyebrow { font-size: 10px; letter-spacing: 2px; }
    .site-footer { font-size: 9px; }
    .small-note, .progress-count { font-size: 12px; }
    .time-keepsake span { font-size: 10px; }
}
@media (max-width: 360px) {
    h1, .welcome-grid h1, .final-copy h1 { font-size: 40px; }
    .stage-copy h1 { font-size: 36px; }
    .clue { font-size: 18px; }
    .hunt-shell { --pad-x: 20px; }
    .login-layout { --pad-x: 20px; }
}
