/* On està el poble? — mateixa paleta que Descobrix el poble (blau nit i or). */
:root{--bg:#07101d;--panel:#101b2d;--panel2:#16243a;--text:#f7f5ed;--muted:#9eacc0;--line:#2e405b;--gold:#ffd452;--red:#e74b4b;--green:#35c779;--shadow:0 18px 48px rgba(0,0,0,.30)}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:radial-gradient(circle at top,#14264a 0,#0b1220 46%,#070c15 100%);background-attachment:fixed;color:var(--text);font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}
button{font:inherit;cursor:pointer}
button:focus-visible,a:focus-visible,svg:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
.app-shell{width:min(1180px,100% - 40px);margin:0 auto}

.topbar{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:20px 0 16px;border-bottom:1px solid var(--line)}
.brand{display:flex;gap:11px;align-items:center;color:var(--text);text-decoration:none}
.brand b{display:block;font-size:17px;font-weight:900;letter-spacing:.04em}
.brand small{display:block;margin-top:3px;font-size:12.5px;font-weight:800;color:var(--muted)}
.brand:hover small{color:var(--gold)}
.flag{width:12px;height:42px;border-radius:6px;background:repeating-linear-gradient(to bottom,var(--gold) 0 11.1111%,var(--red) 11.1111% 22.2222%);box-shadow:0 0 0 3px rgba(255,255,255,.06)}
.close-x{flex:none;display:grid;place-items:center;width:44px;height:44px;margin-left:-6px;border-radius:12px;border:1px solid var(--line);background:var(--panel);color:var(--text);font-size:28px;line-height:1;font-weight:700;text-decoration:none}.close-x:hover{color:var(--gold);border-color:var(--gold)}
.topbar .language-switch{margin-left:auto}
.language-switch{padding:3px;border:1px solid var(--line);border-radius:10px;display:flex;gap:3px;background:var(--panel)}
.language-switch button{border:0;border-radius:7px;font-size:11px;letter-spacing:.08em;padding:7px 10px;background:transparent;color:var(--muted);font-weight:900}
.language-switch button.active{background:var(--gold);color:#211d10}

.intro{padding:26px 0 20px}
.eyebrow{display:flex;align-items:center;gap:10px;font-weight:900;color:var(--gold);letter-spacing:.16em;font-size:11px;text-transform:uppercase}
.eyebrow-dot{width:7px;height:7px;background:var(--gold);border-radius:50%;box-shadow:0 0 10px var(--gold)}
.eyebrow-sep{opacity:.35}
.intro h1{margin:8px 0 10px;font-size:clamp(34px,5.6vw,60px);letter-spacing:-.03em;line-height:1.05;font-weight:950}
.intro h1 em{font-style:normal;color:var(--gold)}
.intro-copy{color:var(--muted);font-size:16px;margin:0;max-width:680px;line-height:1.5}

/* Ronda, temps i punts a les cantonades del mapa (així cap tot en pantalla) */
.timer-track{position:absolute;top:0;left:0;right:0;height:5px;background:rgba(7,16,29,.6);z-index:2;pointer-events:none}
.map-hud{position:absolute;z-index:2;pointer-events:none;display:flex;flex-direction:column;gap:1px;padding:7px 11px;border-radius:12px;background:rgba(16,27,45,.86);border:1px solid var(--line);backdrop-filter:blur(5px);box-shadow:0 6px 20px rgba(0,0,0,.35)}
.map-hud .stat-label{font-size:9.5px;font-weight:900;color:var(--muted);letter-spacing:.12em}
.map-hud b{display:flex;align-items:baseline;gap:3px}
.map-hud strong{font-size:22px;line-height:1;font-weight:950;color:#fff;font-variant-numeric:tabular-nums}
.map-hud b span{font-weight:800;font-size:11.5px;color:#7f8da3}
.hud-round{top:14px;left:12px}
.hud-time{top:14px;right:12px;align-items:flex-end}
.hud-score{bottom:12px;left:12px}
.timer-stat.low strong{color:#ff7a6b}
.timer-track span{display:block;height:100%;width:100%;background:var(--green);transition:width .1s linear}
.map-stage:has(.timer-stat.low) .timer-track span{background:var(--red)}

.game-layout{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(290px,.85fr);gap:16px;align-items:start}
.map-panel{background:var(--panel);border:1px solid var(--line);border-radius:18px;overflow:hidden;min-width:0;box-shadow:var(--shadow)}
.map-instructions{display:flex;gap:9px;align-items:center;padding:14px 18px;color:#c7d1e0;background:var(--panel2);font-size:13px;font-weight:800;border-bottom:1px solid var(--line)}
.map-instructions span:first-child{font-size:19px;color:var(--gold)}
.mobile-prompt{display:none}
.map-stage{position:relative;overflow:hidden;background:#0b1d38}
.map-stage svg{width:100%;display:block;aspect-ratio:900/780;touch-action:none;cursor:crosshair;user-select:none;-webkit-user-select:none}
.neighbours{fill:#223250;stroke:none}
.prov-borders{fill:none;stroke:#33476a;stroke-width:1.2;stroke-dasharray:5 5}
.land{stroke:#8d7a45;stroke-width:2.2;stroke-linejoin:round}
.mun-borders{fill:none;stroke:#b19f68;stroke-width:.7;opacity:.55;stroke-linejoin:round}
.com-borders{fill:none;stroke:#7c6a39;stroke-width:1.8;opacity:.8;stroke-linejoin:round;stroke-linecap:round}
.coast{fill:none;stroke:#9fd3ff;stroke-width:3;opacity:.45;stroke-linejoin:round}
.mun-borders,.com-borders,.coast,.land,.prov-borders{vector-effect:non-scaling-stroke}
.com-labels text{font-size:11.5px;font-weight:900;letter-spacing:.14em;fill:#5e4f26;opacity:.72;paint-order:stroke;stroke:#f1e7c8;stroke-width:3px;stroke-linejoin:round}
.sea-label{letter-spacing:.3em;font-size:17px;fill:#6f9bd1;font-weight:900;opacity:.55}
.compass circle{fill:rgba(16,27,45,.6);stroke:#33476a}
.compass path{fill:var(--gold)}
.compass text{font-size:12px;font-weight:900;fill:#c7d1e0;text-anchor:middle}
.map-controls{position:absolute;right:12px;bottom:12px;z-index:2;display:flex;flex-direction:column;border-radius:11px;overflow:hidden;border:1px solid var(--line);box-shadow:0 6px 20px rgba(0,0,0,.35)}
.map-controls button{background:var(--panel);color:var(--text);border:0;border-bottom:1px solid var(--line);width:40px;height:40px;font-size:22px;font-weight:900}
.map-controls button:last-child{border-bottom:0;font-size:18px}
.map-controls button:hover{background:var(--panel2);color:var(--gold)}
.map-legend{display:flex;gap:7px;align-items:center;color:#c7d1e0;font-size:11px;font-weight:800;width:100%}
.map-legend i{width:10px;height:10px;display:inline-block;border-radius:50%;margin-left:6px}
.map-legend i:first-child{margin-left:0}
.legend-player{background:var(--gold)}
.legend-real{background:var(--green)}
.map-footnote{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:12px 16px;background:var(--panel2);color:#7f8da3;font-size:11px;line-height:1.4;border-top:1px solid var(--line)}
.marker-label{paint-order:stroke;stroke:#07101d;stroke-linejoin:round;font-weight:900;fill:#fff}
.point-line,.point-line-halo{fill:none;stroke-linecap:round}
.point-line{stroke:#ffd34e}
.point-line-halo{stroke:#07101d;opacity:.5}
.drawing{stroke-dasharray:1 1;stroke-dashoffset:1;animation:drawLine 1s cubic-bezier(.2,.7,.3,1) forwards}
@keyframes drawLine{to{stroke-dashoffset:0}}
.travel-dot{fill:#fff;stroke:#ffd34e;stroke-width:3;filter:drop-shadow(0 0 6px #ffd34e)}
.km-badge rect{fill:#07101d;stroke:#ffd452;stroke-width:2;opacity:.94;filter:drop-shadow(0 4px 10px rgba(0,0,0,.45))}
.km-badge text{fill:#ffd452;font-size:25px;font-weight:950;text-anchor:middle;font-variant-numeric:tabular-nums}
.km-badge.rising{animation:fadeUp .35s ease-out both}
@keyframes fadeUp{from{opacity:0}to{opacity:1}}
.real-pin.pop{transform-box:fill-box;transform-origin:center;animation:pinPop .55s cubic-bezier(.3,1.6,.5,1) both}
@keyframes pinPop{from{transform:scale(0)}to{transform:scale(1)}}
.real-ring{fill:none;stroke:#35c779;stroke-width:3;transform-box:fill-box;transform-origin:center;animation:ring .9s ease-out forwards}
@keyframes ring{from{transform:scale(1);opacity:.9}to{transform:scale(4.5);opacity:0}}
.pop-label{animation:fadeUp .4s .15s ease-out both}
.sparkles circle{fill:#ffd452;animation:spark .8s ease-out forwards}
@keyframes spark{from{transform:translate(0,0) scale(1);opacity:1}to{transform:translate(var(--dx),var(--dy)) scale(.3);opacity:0}}
.result-box{transition:opacity .3s}.result-box.pending{opacity:.3}
.result-box.landed strong{display:inline-block;animation:bump .5s cubic-bezier(.3,1.6,.5,1)}
@keyframes bump{40%{transform:scale(1.35)}}
.real-halo{fill:#35c779;opacity:.22;animation:halo 1.6s ease-out infinite;transform-box:fill-box;transform-origin:center}
.relief{mix-blend-mode:multiply;pointer-events:none}
@keyframes halo{from{transform:scale(.6);opacity:.45}to{transform:scale(1.5);opacity:0}}

.side-panel{display:flex;flex-direction:column;gap:14px}
.question-card{background:radial-gradient(circle at 15% 0,rgba(255,212,82,.18),transparent 50%),linear-gradient(135deg,#1b2a4a,#101a30);border:1px solid rgba(255,212,82,.45);border-radius:20px;padding:26px;min-height:340px;display:flex;flex-direction:column;box-shadow:var(--shadow)}
.question-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--muted);font-weight:900;letter-spacing:.1em;font-size:11px}
.question-meta #difficultyBadge{color:#211d10;background:var(--gold);border-radius:7px;padding:6px 10px}
.question-pretitle{font-size:11.5px;letter-spacing:.16em;color:#ffe08a;font-weight:900;margin:32px 0 6px}
.question-card h2{font-size:clamp(28px,3.6vw,40px);line-height:1.1;letter-spacing:-.02em;margin:0;font-weight:950;overflow-wrap:anywhere}
.question-divider{height:1px;background:var(--line);margin:22px 0 16px}
.action-help{font-size:13.5px;line-height:1.55;color:#c7d1e0;margin:0 0 15px;min-height:42px}
.primary-button{display:block;width:100%;padding:14px 16px;text-align:center;text-decoration:none;border:0;border-radius:15px;color:#2a1a00;background:linear-gradient(180deg,#ffe066,#ffb020);box-shadow:0 5px 0 #b77a10,0 10px 20px rgba(255,176,32,.2);font-weight:950;font-size:15px;transition:transform .12s,box-shadow .12s;margin-bottom:5px}
.primary-button:not(:disabled):active{transform:translateY(3px);box-shadow:0 2px 0 #b77a10}
.primary-button:disabled{opacity:.4;cursor:not-allowed;box-shadow:none}
.result-box{background:rgba(255,255,255,.06);border:1px solid var(--line);border-radius:12px;padding:14px;margin-bottom:14px;display:flex;flex-direction:column;gap:6px}
.result-heading{display:flex;justify-content:space-between;align-items:center;gap:10px}
.result-heading strong{font-size:22px;color:var(--gold);font-weight:950}
.result-heading span{font-size:13.5px;color:#fff;font-weight:800}
.result-box p{margin:2px 0 0;color:var(--muted);font-size:12.5px;line-height:1.4}
.mini-rules{display:flex;gap:13px;background:var(--panel);border-radius:16px;border:1px solid var(--line);padding:17px}
.rules-icon{font-size:24px}
.mini-rules h3{font-weight:950;font-size:11.5px;letter-spacing:.12em;color:#ffe08a;margin:2px 0 6px}
.mini-rules p{margin:0;color:var(--muted);font-size:13px;line-height:1.55}
.round-steps{display:flex;gap:8px}
.round-step{flex:1;display:grid;place-items:center;border-radius:10px;background:var(--panel);border:1px solid var(--line);color:#7f8da3;height:38px;font-weight:950;font-size:13px}
.round-step.active{color:#211d10;background:var(--gold);border-color:var(--gold)}
.round-step.done{color:#7fe3ab;background:rgba(53,199,121,.12);border-color:rgba(53,199,121,.45)}

.end-screen,.locked-screen{max-width:720px;margin:0 auto 46px;background:var(--panel);border:1px solid var(--line);border-radius:22px;text-align:center;padding:32px 26px;box-shadow:var(--shadow)}
.end-medal,.locked-ico{font-size:54px}
.eyebrow.center{justify-content:center;margin:10px 0}
.end-screen h2,.locked-screen h2{font-weight:950;font-size:clamp(24px,4.6vw,38px);line-height:1.15;margin:10px 0 12px}
.locked-screen p{color:var(--muted);font-size:15px;line-height:1.5;margin:0 auto 22px;max-width:460px}
.locked-screen .primary-button{max-width:340px;margin:0 auto}
.final-score{display:flex;justify-content:center;align-items:baseline;gap:9px}
.final-score #endScore{font-size:64px;font-weight:950;color:var(--gold);font-variant-numeric:tabular-nums}
.final-score small{font-weight:800;color:var(--muted)}
.end-screen p{color:var(--muted)}
.end-rows{margin:22px auto;text-align:left;max-width:540px;border:1px solid var(--line);border-radius:12px;overflow:hidden}
.end-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:14px;align-items:center;padding:12px 15px;border-bottom:1px solid var(--line);font-size:14px;font-weight:700}
.end-row:last-child{border:0}
.end-row:nth-child(odd){background:rgba(255,255,255,.03)}
.end-row .dist{color:var(--muted);font-size:12.5px}
.end-row strong{color:var(--gold);font-weight:950}
.end-actions{display:flex;gap:10px;max-width:540px;margin:auto}
.end-actions>*{flex:1}
.secondary-button{border:1px solid rgba(255,255,255,.22);border-radius:15px;background:rgba(255,255,255,.08);color:var(--text);font-size:15px;font-weight:900;padding:13px}
.secondary-button:hover{background:rgba(255,255,255,.14)}
.back-link{display:inline-block;margin-top:20px;color:var(--muted);font-weight:800;font-size:14px}
.back-link:hover{color:var(--gold)}
.hidden{display:none!important}
.toast{position:fixed;z-index:10;left:50%;bottom:23px;transform:translate(-50%,30px);background:var(--panel2);border:1px solid var(--line);color:#fff;padding:12px 21px;box-shadow:var(--shadow);border-radius:12px;font-size:14px;font-weight:700;opacity:0;pointer-events:none;transition:transform .2s,opacity .2s}
.toast.visible{opacity:1;transform:translate(-50%,0)}
footer{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:26px 0 34px;color:#6d7b91;font-size:11px;letter-spacing:.04em;font-weight:700}

@media(max-width:900px){
  .app-shell{width:min(100% - 24px,760px)}
  .game-layout{grid-template-columns:1fr}
  .side-panel .question-card{display:none}
  .mobile-prompt{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px;padding:14px 16px;background:linear-gradient(135deg,#1b2a4a,#101a30);border-bottom:1px solid rgba(255,212,82,.4)}
  .mobile-prompt span{font-size:11px;font-weight:900;letter-spacing:.14em;color:#ffe08a;width:100%}
  .mobile-prompt strong{font-size:26px;font-weight:950;line-height:1.1}
  .mobile-prompt em{font-style:normal;font-size:10.5px;font-weight:950;letter-spacing:.08em;color:#211d10;background:var(--gold);border-radius:6px;padding:4px 8px}
  .mobile-actions{padding:14px 16px 6px}
  .mobile-actions .result-box{margin:0 0 12px}
}
@media(min-width:901px){.mobile-actions{display:none}}
@media(max-width:620px){
  .topbar{padding:14px 0 12px}
  .brand b{font-size:14px}
  .intro{padding:18px 0 14px}
  .intro-copy{font-size:14.5px}
  .map-instructions{padding:11px 14px;font-size:12px}
  .map-hud{padding:5px 9px}.map-hud strong{font-size:18px}.hud-round,.hud-time{top:10px}.hud-round,.hud-score{left:8px}.hud-time{right:8px}.hud-score{bottom:8px}
  .map-controls button{width:36px;height:36px}
  .end-actions{flex-direction:column}
  .end-screen,.locked-screen{padding:26px 16px}
  .final-score #endScore{font-size:52px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition-duration:0s!important;animation:none!important}}

/* Rècord personal de menor distància en un poble repetit */
.result-box .record-note{margin-top:6px;padding:8px 10px;border-radius:10px;background:rgba(255,212,82,.14);border:1px solid rgba(255,212,82,.55);color:#ffe08a;font-weight:900;font-size:13px}
.result-box.landed .record-note{animation:recordIn .6s cubic-bezier(.3,1.6,.5,1) both}
@keyframes recordIn{from{transform:scale(.6);opacity:0}to{transform:none;opacity:1}}
.result-box .best-note{color:#c7d1e0;font-weight:700}
.record-tag{font-style:normal;font-size:11px;font-weight:950;color:#211d10;background:var(--gold);border-radius:999px;padding:2px 7px;white-space:nowrap}
/* Desviació acumulada i top 3 del dia (menys km). */
.end-km{display:flex;flex-wrap:wrap;justify-content:center;align-items:baseline;gap:4px 10px;margin:14px auto 0;max-width:540px}
.end-km span{font-size:11px;font-weight:900;letter-spacing:.14em;text-transform:uppercase;color:var(--muted)}
.end-km strong{font-size:24px;font-weight:950;color:var(--text)}
.end-km small{flex-basis:100%;font-size:12px;color:var(--muted)}
.top-box{max-width:540px;margin:0 auto 22px;padding:16px 16px 12px;text-align:left;border:1px solid rgba(255,212,82,.45);border-radius:14px;background:radial-gradient(circle at 10% 0,rgba(255,212,82,.14),transparent 55%),var(--panel2)}
.top-box h3{margin:0 0 10px;font-size:14px;font-weight:950;color:var(--gold);letter-spacing:.04em}
.top-list{list-style:none;margin:0;padding:0}
.top-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;padding:9px 10px;border-radius:10px;font-weight:800;font-size:14.5px}
.top-row+.top-row{margin-top:4px}
.top-row.mine{background:rgba(255,212,82,.16);box-shadow:inset 0 0 0 1px rgba(255,212,82,.5)}
.top-medal{font-size:20px;line-height:1}
.top-nick{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.top-nick em{font-style:normal;color:var(--gold);font-size:12px}
.top-row strong{color:var(--gold);font-weight:950}
.top-note{margin:8px 2px 2px;font-size:12.5px;color:var(--muted);line-height:1.4}
