/* Toka e Gjyshit — interfaccia: calda, rotonda, leggibile al sole, comoda col pollice. */
@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }

:root {
  --ink: #241c14; --paper: #f7f0e1; --paper2: #efe4cc; --cream: #fff8ea;
  --olive: #5f6d2c; --olive2: #7d8f3a; --leaf: #3f7a3a; --soil: #7a5636; --red: #c8102e; --gold: #e3a21f; --sky: #3f7fd0;
  --glass: rgba(26, 22, 16, .58); --glass2: rgba(26, 22, 16, .78); --line: rgba(255, 248, 234, .16);
  --r: 16px; --head: 'Fredoka', 'Nunito', system-ui, sans-serif; --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1a14; color: var(--cream); font-family: var(--body); }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.off { display: none !important; }
b, strong { font-weight: 800; }

/* ---------------------------------- HUD ---------------------------------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.pill { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 999px; }
.card { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); }
.tl { position: absolute; left: calc(10px + var(--sal)); top: calc(10px + var(--sat)); display: flex; flex-direction: column; gap: 8px; max-width: min(340px, 60vw); pointer-events: none; }
.tl > * { pointer-events: auto; }
.clock { padding: 7px 14px 8px; border-radius: 18px; display: grid; grid-template-columns: auto auto; column-gap: 12px; align-items: center; }
.clock .ct { display: flex; align-items: baseline; gap: 6px; }
.clock .ct b { font-family: var(--head); font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.clock .cd { font-size: 12.5px; opacity: .85; grid-column: 1; }
.clock #hWx { font-size: 13px; opacity: .9; }
.speeds { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 4px; }
.speeds button { min-width: 34px; height: 30px; border-radius: 10px; font-weight: 800; font-size: 12px; background: rgba(255,255,255,.08); }
.speeds button.on { background: var(--gold); color: var(--ink); }
.obj { padding: 10px 13px; font-size: 13.5px; line-height: 1.35; }
.obj .ot { font-family: var(--head); font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); margin-bottom: 3px; }
.obj .ol { display: flex; gap: 7px; align-items: flex-start; margin-top: 4px; }
.obj .ol i { flex: 0 0 15px; height: 15px; border-radius: 5px; border: 2px solid rgba(255,248,234,.55); margin-top: 1px; }
.obj .ol.ok i { background: var(--olive2); border-color: var(--olive2); }
.obj .ol.ok { opacity: .6; text-decoration: line-through; }
.obj .op { height: 5px; border-radius: 4px; background: rgba(255,255,255,.12); margin-top: 6px; overflow: hidden; }
.obj .op i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.obj.collapsed .ol, .obj.collapsed .op { display: none; }

.tr { position: absolute; right: calc(10px + var(--sar)); top: calc(10px + var(--sat)); display: grid; grid-template-columns: auto auto; gap: 8px; justify-items: end; align-items: start; }
.money { font-family: var(--head); font-size: 21px; font-weight: 600; padding: 7px 15px; transition: color .3s; white-space: nowrap; }
.money.up { color: #b6e08a; } .money.down { color: #ffb0a0; }
.phoneBtn { width: 46px; height: 46px; border-radius: 15px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); display: grid; place-items: center; position: relative; }
.phoneBtn svg { width: 24px; height: 24px; }
.phoneBtn .dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); border: 2px solid #2a2219; }
#minimap { grid-column: 1 / span 2; width: 132px; height: 132px; border-radius: 50%; border: 2px solid rgba(255,248,234,.35); background: #2c2a1f; box-shadow: 0 4px 18px rgba(0,0,0,.35); }

.veh { position: absolute; left: 50%; bottom: calc(14px + var(--sab)); transform: translateX(-50%); display: flex; gap: 10px; align-items: center; padding: 7px 14px; font-size: 13px; }
.veh:empty { display: none; }
.veh .spd { font-family: var(--head); font-size: 26px; font-weight: 600; min-width: 48px; text-align: right; }
.veh .spd small { font-size: 11px; opacity: .7; margin-left: 2px; }
.veh .tk { width: 92px; }
.veh .tk .b { height: 7px; background: rgba(255,255,255,.14); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.veh .tk .b i { display: block; height: 100%; background: var(--gold); }
.veh .tag { padding: 3px 8px; border-radius: 8px; background: rgba(255,255,255,.1); font-weight: 800; font-size: 11.5px; white-space: nowrap; }
.veh .tag.on { background: var(--olive2); color: #fff; }
.veh .tag.warn { background: #b4472f; }

.acts { position: absolute; right: calc(12px + var(--sar)); bottom: calc(14px + var(--sab)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 62vw; }
.act { display: flex; align-items: center; gap: 9px; padding: 0 16px 0 7px; height: 48px; border-radius: 16px; background: var(--glass2); border: 1px solid var(--line); font-weight: 800; font-size: 14.5px; backdrop-filter: blur(8px); box-shadow: 0 3px 12px rgba(0,0,0,.25); white-space: nowrap; transition: transform .08s; }
.act:active { transform: scale(.96); }
.act kbd { min-width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.13); font: 800 13px var(--head); }
.act.main { background: var(--gold); color: var(--ink); border-color: transparent; height: 56px; font-size: 16px; }
.act.main kbd { background: rgba(0,0,0,.14); }
.act.small { height: 40px; font-size: 13px; }
.touch .act kbd { display: none; }
.touch .act { padding: 0 18px; }
.actrow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.hint { position: absolute; left: 50%; top: calc(88px + var(--sat)); transform: translateX(-50%); padding: 9px 16px; border-radius: 14px; background: var(--glass2); font-weight: 700; font-size: 14px; max-width: 80vw; text-align: center; opacity: 0; transition: opacity .25s; pointer-events: none !important; }
.hint.on { opacity: 1; }
.busy { position: absolute; left: 50%; bottom: 34%; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 6px; pointer-events: none !important; }
.busy.on { display: flex; }
.busy .bar { width: 220px; height: 12px; border-radius: 8px; background: var(--glass2); overflow: hidden; border: 1px solid var(--line); }
.busy .bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.busy span { font-weight: 800; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.joy { position: absolute; width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(255,248,234,.3); background: rgba(20,16,10,.18); display: none; pointer-events: none !important; transform: translate(-50%, -50%); }
.joy i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255,248,234,.55); }
.joy.on { display: block; }
.joy.idle { display: block; opacity: .45; }

/* ---------------------------------- avvisi ---------------------------------- */
#toasts { position: absolute; left: 50%; top: calc(10px + var(--sat)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 30; width: min(460px, 70vw); }
.toast { padding: 9px 15px; border-radius: 14px; background: rgba(36, 28, 20, .9); border: 1px solid var(--line); font-weight: 700; font-size: 14px; box-shadow: 0 6px 22px rgba(0,0,0,.3); display: flex; gap: 9px; align-items: center; animation: tIn .35s ease-out; max-width: 100%; }
.toast .ti { font-size: 18px; }
.toast .amt { font-family: var(--head); font-weight: 600; margin-left: auto; padding-left: 10px; }
.toast .amt.p { color: #b6e08a; } .toast .amt.n { color: #ffb0a0; }
.toast.gold { background: linear-gradient(120deg, #e3a21f, #f2c45a); color: var(--ink); }
.toast.out { animation: tOut .4s ease-in forwards; }
@keyframes tIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes tOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------------------------------- dialoghi ---------------------------------- */
#dialog { position: absolute; left: 50%; bottom: calc(16px + var(--sab)); transform: translateX(-50%); width: min(720px, calc(100vw - 24px)); z-index: 40; }
.dlg { display: flex; gap: 14px; align-items: flex-end; }
.dlg .por { flex: 0 0 104px; height: 104px; border-radius: 22px; background: #c9b88f center/cover no-repeat; border: 3px solid var(--paper); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.dlg .box { flex: 1; background: var(--paper); color: var(--ink); border-radius: 22px; padding: 14px 18px 12px; box-shadow: 0 10px 34px rgba(0,0,0,.4); position: relative; min-height: 104px; }
.dlg .nm { font-family: var(--head); font-weight: 600; font-size: 15px; color: var(--soil); letter-spacing: .3px; }
.dlg .tx { font-size: 16.5px; line-height: 1.45; margin-top: 3px; min-height: 48px; }
.dlg .ch { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dlg .ch button { text-align: left; padding: 10px 14px; border-radius: 13px; background: var(--paper2); font-weight: 800; font-size: 15px; color: var(--ink); }
.dlg .ch button:hover, .dlg .ch button:focus-visible { background: #e5d6b4; outline: none; }
.dlg .nx { position: absolute; right: 16px; bottom: 9px; font-size: 12px; font-weight: 800; color: var(--soil); opacity: .75; animation: bob 1.2s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

/* ---------------------------------- finestre modali ---------------------------------- */
#modal { position: absolute; inset: 0; z-index: 58; display: grid; place-items: center; background: rgba(15,12,8,.45); padding: 16px; }
.mbox { background: var(--paper); color: var(--ink); border-radius: 24px; padding: 20px; width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.45); max-height: 88vh; overflow: auto; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* i pulsanti in fondo restano sempre visibili, anche quando il contenuto scorre */
.mbox > .row:last-child { position: sticky; bottom: -20px; margin: 12px -20px -20px; padding: 12px 20px 18px; background: var(--paper); box-shadow: 0 -10px 16px -12px rgba(0,0,0,.35); z-index: 1; }
.mbox h3 { font-family: var(--head); font-weight: 600; margin: 0 0 6px; font-size: 22px; }
.mbox p { margin: 6px 0 12px; line-height: 1.5; }
.mbox .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn { padding: 11px 16px; border-radius: 13px; background: var(--paper2); font-weight: 800; color: var(--ink); font-size: 15px; }
.btn.pri { background: var(--olive); color: #fff; }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.red { background: #b4472f; color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------------------------------- telefono ---------------------------------- */
#phone { position: absolute; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(12,10,6,.35); }
.ph { width: min(400px, calc(100vw - 20px)); height: min(760px, calc(100vh - 20px)); background: #15130f; border-radius: 38px; padding: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.55), inset 0 0 0 2px #3a342a; display: flex; flex-direction: column; animation: phIn .28s cubic-bezier(.2,.9,.3,1.2); }
@keyframes phIn { from { transform: translateY(40px) scale(.96); opacity: 0; } }
.ph .scr { flex: 1; border-radius: 30px; overflow: hidden; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; position: relative; }
.ph .sb { display: flex; justify-content: space-between; align-items: center; padding: 9px 20px 4px; font: 700 13px var(--head); color: var(--ink); }
.ph .bar2 { display: flex; align-items: center; gap: 8px; padding: 6px 14px 10px; }
.ph .bar2 h2 { font-family: var(--head); font-weight: 600; font-size: 22px; margin: 0; flex: 1; }
.ph .back { width: 40px; height: 40px; border-radius: 13px; background: var(--paper2); display: grid; place-items: center; font-size: 20px; font-weight: 800; }
.ph .body { flex: 1; overflow-y: auto; padding: 4px 14px 18px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.ph .home { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 8px; padding: 18px 14px; }
.ph .app { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; text-align: center; position: relative; }
.ph .app .ic { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; box-shadow: 0 4px 10px rgba(0,0,0,.15); }
.ph .app .ic svg { width: 30px; height: 30px; }
.ph .app .badge { position: absolute; top: -4px; right: 6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--paper); }
.ph .homeHead { padding: 12px 20px 2px; }
.ph .homeHead .bal { font-family: var(--head); font-size: 32px; font-weight: 600; }
.ph .homeHead .sub { font-size: 13px; opacity: .7; }
.ph .close { margin: 8px auto 2px; width: 120px; height: 5px; border-radius: 3px; background: #6a6050; }
.li { background: var(--cream); border-radius: 16px; padding: 12px 13px; margin-bottom: 9px; box-shadow: 0 1px 0 rgba(0,0,0,.06); }
.li .lh { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.li .lt { font-weight: 800; font-size: 15px; }
.li .lp { font-family: var(--head); font-weight: 600; white-space: nowrap; color: var(--leaf); }
.li .lp.n { color: #a3402c; }
.li .ls { font-size: 13px; opacity: .78; margin-top: 3px; line-height: 1.4; }
.li .lb { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.li .lb .btn { padding: 8px 12px; font-size: 13.5px; }
.li.act2 { border: 2px solid var(--gold); }
.chip { display: inline-block; padding: 3px 8px; border-radius: 8px; background: var(--paper2); font-size: 11.5px; font-weight: 800; margin-right: 4px; }
.chip.g { background: #d8e6c0; } .chip.r { background: #f2cfc4; } .chip.y { background: #f5e2a8; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; touch-action: pan-x; }
.tabs button { padding: 7px 12px; border-radius: 11px; background: var(--paper2); font-weight: 800; font-size: 13px; white-space: nowrap; }
.tabs button.on { background: var(--ink); color: var(--paper); }
.sec { font: 600 12px var(--head); text-transform: uppercase; letter-spacing: 1.3px; opacity: .55; margin: 14px 2px 7px; }
.spark { width: 100%; height: 34px; display: block; margin-top: 6px; }
.mapc { width: 100%; aspect-ratio: 1; border-radius: 18px; display: block; background: #3a3a2a; touch-action: none; }
.kv { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px dashed rgba(0,0,0,.12); font-size: 14px; }
.kv b { font-family: var(--head); font-weight: 600; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 16px; margin: 6px 0; font-size: 14.5px; line-height: 1.4; background: var(--cream); }
.msg.me { margin-left: auto; background: #d8e6c0; }
.msg .mf { font-size: 11px; font-weight: 800; opacity: .6; margin-bottom: 2px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; display: block; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px dashed rgba(0,0,0,.12); font-weight: 700; gap: 10px; }
.seg { display: flex; background: var(--paper2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 10px; border-radius: 9px; font-weight: 800; font-size: 13px; }
.seg button.on { background: var(--ink); color: var(--paper); }
input[type=range] { width: 130px; accent-color: var(--olive); }
input[type=text] { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--paper2); background: var(--cream); width: 100%; font-weight: 700; color: var(--ink); }

/* ---------------------------------- titolo ---------------------------------- */
#title { position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 20px 16px calc(28px + var(--sab)); background: linear-gradient(180deg, rgba(20,14,8,0) 30%, rgba(20,14,8,.25) 55%, rgba(20,14,8,.78) 100%); }
.tlogo { position: absolute; top: calc(9vh + var(--sat)); left: 0; right: 0; text-align: center; pointer-events: none; }
.tlogo h1 { font-family: var(--head); font-weight: 700; font-size: clamp(44px, 9vw, 92px); margin: 0; line-height: .95; color: var(--cream); text-shadow: 0 4px 0 #8a5a2a, 0 10px 40px rgba(0,0,0,.45); letter-spacing: 1px; }
.tlogo h1 span { color: var(--gold); }
.tlogo p { font-size: clamp(15px, 2.4vw, 20px); font-weight: 800; margin: 14px 0 0; color: var(--cream); text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.tmenu { display: flex; flex-direction: column; gap: 10px; width: min(380px, 100%); }
.tmenu .btn { padding: 15px 18px; font-size: 17px; border-radius: 17px; text-align: center; }
.tmenu .btn small { display: block; font-size: 12.5px; font-weight: 700; opacity: .7; margin-top: 2px; }
.tfoot { display: flex; gap: 8px; justify-content: center; margin-top: 12px; align-items: center; font-size: 13px; }
.tfoot .seg { background: rgba(255,248,234,.14); }
.tfoot .seg button { color: var(--cream); }
.tfoot .seg button.on { background: var(--cream); color: var(--ink); }
.modes { display: grid; gap: 9px; }
.mode { text-align: left; padding: 14px 15px; border-radius: 17px; background: var(--cream); border: 2px solid transparent; }
.mode.on { border-color: var(--olive); background: #eef2dd; }
.mode b { font-family: var(--head); font-weight: 600; font-size: 17px; display: block; }
.mode span { font-size: 13.5px; opacity: .8; line-height: 1.4; display: block; margin-top: 2px; }

#fade { position: absolute; inset: 0; background: #0d0a06; opacity: 0; pointer-events: none; transition: opacity .6s; z-index: 60; }
#fade.on { opacity: 1; pointer-events: auto; }
#fade .ft { position: absolute; left: 0; right: 0; top: 46%; text-align: center; font-family: var(--head); font-size: 24px; color: var(--cream); }
#loading { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #3b3322, #15120c); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .lg { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#loading b { font-family: var(--head); font-size: 40px; font-weight: 700; color: var(--cream); }
#loading span { font-size: 14px; opacity: .7; }
.lbar { width: 220px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.lbar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }

/* foto e album */
.photo { background: #f4ecd8; padding: 10px 10px 30px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.35); transform: rotate(-1.5deg); }
.photo img, .photo canvas { width: 100%; display: block; border-radius: 2px; }
.photo .cap { font-family: var(--head); text-align: center; margin-top: 8px; color: #5a4632; }
#tl { position: absolute; inset: 0; z-index: 55; background: #000; display: grid; place-items: center; }
#tl canvas { max-width: 100%; max-height: 100%; }
#tl .tlc { position: absolute; left: 0; right: 0; bottom: calc(24px + var(--sab)); display: flex; gap: 8px; justify-content: center; }

@media (max-width: 640px) {
  .clock .ct b { font-size: 19px; }
  .money { font-size: 17px; padding: 6px 12px; }
  #minimap { width: 104px; height: 104px; }
  .obj { font-size: 12.5px; padding: 8px 11px; }
  .tl { max-width: 52vw; }
  .speeds button { min-width: 30px; height: 28px; }
  .act { height: 46px; font-size: 13.5px; }
  .act.main { height: 54px; }
  .dlg .por { flex-basis: 74px; height: 74px; border-radius: 18px; }
  .dlg .tx { font-size: 15px; }
  .ph { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; padding: 0; }
  .ph .scr { border-radius: 0; }
  .clock { grid-template-columns: auto; row-gap: 4px; }
  .speeds { grid-column: 1; grid-row: 3; }
  .veh { bottom: auto; top: calc(138px + var(--sat)); left: auto; right: calc(10px + var(--sar)); transform: none; flex-wrap: wrap; justify-content: flex-end; max-width: 46vw; padding: 6px 10px; gap: 6px; border-radius: 16px; }
  .veh .spd { font-size: 20px; min-width: 0; }
  .veh .tk { width: 76px; }
  .veh .tag { font-size: 10.5px; }
}
@media (max-height: 480px) {
  .obj { display: none; }
  #minimap { width: 92px; height: 92px; }
}
