/* Kesäkaupunki – pehmeä pastellinen käyttöliittymä */
:root {
  --cream: #fff8ee;
  --cream2: #fff1de;
  --pink: #ff7fb0;
  --pink-d: #e85d97;
  --mint: #7fd3b0;
  --mint-d: #4fb48c;
  --sky: #8fd3f5;
  --sun: #ffcf4d;
  --text: #5b3d2b;
  --text-soft: #8a6a55;
  --shadow: 0 6px 0 rgba(120, 80, 50, 0.18), 0 10px 24px rgba(80, 50, 30, 0.18);
  --radius: 20px;
  --font: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #8fd16a; font-family: var(--font); color: var(--text); user-select: none; -webkit-user-select: none; touch-action: none; }
input, button { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

/* ---------- yleiset napit ---------- */
.big-btn {
  display: block; width: 100%; margin-top: 14px; padding: 14px 18px; border: 0; border-radius: 18px;
  font-size: 24px; font-weight: 700; color: #fff; background: linear-gradient(#ff97c0, var(--pink));
  box-shadow: 0 5px 0 var(--pink-d), 0 10px 20px rgba(232, 93, 151, 0.35); transition: transform .08s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--pink-d); }
.big-btn:disabled { filter: grayscale(.6); opacity: .7; }
.pill-btn { border: 0; border-radius: 999px; padding: 9px 16px; font-size: 16px; font-weight: 600; background: #fff; color: var(--text); box-shadow: 0 3px 0 rgba(120, 80, 50, .2); }
.pill-btn:active { transform: translateY(2px); box-shadow: none; }
.pill-btn.green { background: var(--mint); color: #fff; box-shadow: 0 3px 0 var(--mint-d); }
.pill-btn.pink { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--pink-d); }
.round-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; font-size: 18px; color: var(--text); box-shadow: 0 3px 0 rgba(120, 80, 50, .2); }
.link-btn { border: 0; background: none; color: var(--text-soft); font-size: 13px; font-weight: 600; padding: 2px 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--cream); border-radius: 999px; padding: 6px 14px 6px 6px; font-weight: 700; font-size: 20px; box-shadow: var(--shadow); }
.pill.small { font-size: 13px; padding: 4px 10px; font-weight: 600; }
.card { background: var(--cream); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- aloitus ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; background: radial-gradient(ellipse at top, rgba(255, 240, 210, 0.35), rgba(255, 200, 220, 0.25)); overflow-y: auto; }
.start-card { width: min(420px, 100%); background: var(--cream); border-radius: 28px; padding: 22px 22px 18px; box-shadow: var(--shadow); text-align: left; margin: auto; }
.logo { text-align: center; margin-bottom: 10px; }
.logo .sun { font-size: 54px; display: inline-block; animation: spin 14s linear infinite; }
.logo h1 { margin: 2px 0 0; font-size: 42px; letter-spacing: .5px; color: var(--pink-d); text-shadow: 0 3px 0 #ffe0ec; }
.tagline { margin: 0; color: var(--text-soft); font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.field input { width: 100%; font-size: 22px; padding: 11px 14px; border-radius: 14px; border: 3px solid #f3d9c4; background: #fff; color: var(--text); outline: none; user-select: text; -webkit-user-select: text; }
.field input:focus { border-color: var(--pink); }
.hint { display: block; color: var(--text-soft); margin-top: 4px; line-height: 1.3; }
.profiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.profiles button { border: 0; border-radius: 14px; padding: 7px 12px; background: #fff; box-shadow: 0 3px 0 rgba(120, 80, 50, .18); font-size: 15px; color: var(--text); font-weight: 600; }
.profiles button small { display: block; font-weight: 500; color: var(--mint-d); }
.net-hint { margin-top: 10px; font-size: 13px; color: var(--text-soft); text-align: center; }

/* ---------- editori ---------- */
.editor-card { width: min(1000px, 100%); max-height: calc(100vh - 32px); background: var(--cream); border-radius: 28px; box-shadow: var(--shadow); display: flex; overflow: hidden; margin: auto; }
.editor-preview { flex: 0 0 38%; background: linear-gradient(#bfe8ff, #e9f8ff 55%, #a8e08a 56%, #8fd16a); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; }
.editor-preview canvas { width: 100%; max-width: 330px; height: auto; }
.preview-btns { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.editor-options { flex: 1; padding: 16px 20px 18px; overflow-y: auto; }
.editor-options h2 { margin: 0 0 6px; color: var(--pink-d); }
#editorDone { position: sticky; bottom: 0; z-index: 2; }
.opt { margin: 10px 0 4px; }
.opt h3 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.opt h3 .cname { font-size: 13px; font-weight: 600; color: var(--text-soft); background: #fff; padding: 1px 8px; border-radius: 999px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { border: 3px solid transparent; border-radius: 14px; background: #fff; padding: 7px 12px; font-size: 15px; font-weight: 600; color: var(--text); box-shadow: 0 2px 0 rgba(120, 80, 50, .15); }
.choice.sel { border-color: var(--pink); background: #fff0f6; }
.choice canvas { display: block; width: 54px; height: 54px; }
.choice.hair { padding: 3px 4px 2px; font-size: 11px; text-align: center; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.swatch { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--text-soft); }
.swatch i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(120, 80, 50, .18); display: block; }
.swatch.sel i { box-shadow: 0 0 0 3px var(--pink); transform: scale(1.1); }
.swatch.sel { color: var(--pink-d); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tab { border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 14px; background: #fff; color: var(--text); box-shadow: 0 2px 0 rgba(120, 80, 50, .15); display: inline-flex; align-items: center; gap: 6px; }
.tab i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.tab.sel { background: var(--pink); color: #fff; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topleft { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); width: min(320px, 46vw); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#topleft > * { pointer-events: auto; }
#moneyRow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#money .coin { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #ffcf4d 55%, #e8a91a); color: #8a5a00; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
#money.bump { animation: bump .45s; }
@keyframes bump { 30% { transform: scale(1.18); } 100% { transform: scale(1); } }
.goal { background: rgba(255, 248, 238, .92); border-radius: 14px; padding: 6px 10px 8px; box-shadow: var(--shadow); font-size: 12.5px; font-weight: 600; }
.goal .bar { height: 10px; border-radius: 6px; background: #f1dccb; margin-top: 4px; overflow: hidden; }
.goal .bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--mint), #b6e88a); transition: width .5s; }
.task { padding: 10px 12px; }
.task.pop { animation: pop .5s; }
@keyframes pop { 0% { transform: scale(.85); opacity: .3; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
.task-head { display: flex; gap: 10px; align-items: center; }
.task-icon { font-size: 30px; width: 44px; height: 44px; border-radius: 14px; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .06); flex: none; }
.task-kicker { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.task-kicker b { color: var(--mint-d); }
.task-title { font-size: 18px; font-weight: 700; line-height: 1.1; }
.task-text { margin-top: 6px; font-size: 15px; line-height: 1.25; font-weight: 500; }
.task-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.task-progress { background: #fff; border-radius: 999px; padding: 1px 8px; color: var(--pink-d); }
.task-progress:empty { display: none; }
.task-dist { flex: 1; }

#topright { position: absolute; right: calc(12px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; gap: 8px; width: 220px; }
.map-box { padding: 6px; }
#minimap { width: 100%; display: block; border-radius: 14px; cursor: pointer; background: #8fd16a; }
.map-btn { width: 100%; margin-top: 6px; border: 0; border-radius: 12px; padding: 7px; background: var(--mint); color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 3px 0 var(--mint-d); }
.clock-box { position: relative; padding: 0; overflow: hidden; height: 64px; }
#skyCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.clock-text { position: absolute; right: 10px; bottom: 6px; display: flex; flex-direction: column; align-items: flex-end; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .35); }
#clockText { font-size: 26px; font-weight: 700; line-height: 1; }
#dayText { font-size: 12px; font-weight: 600; }

#actions { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 10px; align-items: flex-end; pointer-events: none; }
#actions button { pointer-events: auto; }
.act { border: 0; border-radius: 18px; padding: 10px 18px; font-size: 19px; font-weight: 700; background: var(--cream); color: var(--text); box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; animation: pop .3s; white-space: nowrap; }
.act .key { font-size: 12px; background: #f1dccb; color: var(--text-soft); border-radius: 6px; padding: 1px 6px; }
.act.buy { background: linear-gradient(#9be0c3, var(--mint)); color: #fff; font-size: 24px; padding: 14px 26px; box-shadow: 0 5px 0 var(--mint-d), 0 10px 22px rgba(60, 140, 100, .35); }
.act.buy small { display: block; font-size: 14px; opacity: .95; }
.act.buy .key { background: rgba(255, 255, 255, .35); color: #fff; }
.act.info { opacity: .9; font-size: 15px; }
.act:active { transform: translateY(3px); }

.phone-btn { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 74px; height: 74px; border-radius: 24px; border: 0; font-size: 38px; background: linear-gradient(#fff, var(--cream2)); box-shadow: var(--shadow); }
.phone-btn.ring { animation: ring .6s 3; }
@keyframes ring { 20%, 60% { transform: rotate(-12deg); } 40%, 80% { transform: rotate(12deg); } }
.badge { position: absolute; top: -6px; right: -6px; min-width: 26px; height: 26px; border-radius: 13px; background: #ff4d6d; color: #fff; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 6px; box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }

.edge-arrow { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none !important; display: flex; align-items: center; justify-content: center; }
.edge-arrow .arrow-head { font-size: 34px; color: var(--pink); text-shadow: 0 0 0 #fff, 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff; }
.edge-arrow span { position: absolute; bottom: -10px; font-size: 12px; font-weight: 700; background: var(--cream); border-radius: 999px; padding: 1px 7px; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); white-space: nowrap; }

#joyZone { position: absolute; inset: 0; z-index: 1; touch-action: none; }
.joy-hint { position: absolute; left: calc(24px + var(--safe-l)); bottom: calc(28px + var(--safe-b)); z-index: 2; pointer-events: none !important; background: rgba(255, 248, 238, .9); border-radius: 18px; padding: 10px 14px 10px 52px; font-weight: 600; font-size: 14px; line-height: 1.25; box-shadow: var(--shadow); animation: hintPulse 2s infinite; }
.joy-hint span { position: absolute; left: 12px; top: 50%; margin-top: -16px; font-size: 28px; animation: hintDrag 2s infinite; }
@keyframes hintDrag { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(10px, -6px); } }
@keyframes hintPulse { 50% { transform: scale(1.03); } }
/* kosketus: toimintonapit oikean peukalon alle puhelinnapin viereen */
.touch #actions { left: auto; right: calc(104px + var(--safe-r)); bottom: calc(20px + var(--safe-b)); transform: none; flex-direction: column-reverse; align-items: flex-end; }
.touch .act { font-size: 18px; padding: 12px 18px; min-height: 52px; }
.touch .act.buy { font-size: 22px; }
#topleft, #topright, #actions, .phone-btn, #touchBtns, .edge-arrow { z-index: 2; }
.touch #joyZone { pointer-events: auto; }
.joy { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(255, 255, 255, .25); border: 3px solid rgba(255, 255, 255, .6); pointer-events: none !important; }
.joy i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 3px 8px rgba(0, 0, 0, .2); }
#touchBtns { position: absolute; right: calc(20px + var(--safe-r)); bottom: calc(104px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.touch-btn { width: 58px; height: 58px; border-radius: 50%; border: 0; font-size: 28px; background: rgba(255, 248, 238, .92); box-shadow: var(--shadow); }
.touch-btn.on { background: var(--mint); }

/* ---------- ilmoitukset ---------- */
#toasts { position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(460px, 60vw); }
.toast { background: var(--cream); border-radius: 14px; padding: 8px 14px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow); animation: toastIn .3s; text-align: center; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: all .4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } }
.banner { position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 45; background: linear-gradient(#fff, var(--cream)); border-radius: 26px; padding: 16px 30px; text-align: center; box-shadow: var(--shadow); pointer-events: none; animation: bannerIn .5s cubic-bezier(.2, 1.6, .4, 1); }
.banner b { display: block; font-size: 30px; color: var(--pink-d); }
.banner span { font-size: 22px; font-weight: 700; color: var(--mint-d); }
@keyframes bannerIn { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 60; transition: opacity .35s; }
.flash.on { opacity: .9; transition: none; }

/* ---------- ikkunat ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(60, 40, 30, .35); display: flex; align-items: center; justify-content: center; padding: 14px; }
.sheet { width: min(860px, 100%); max-height: calc(100vh - 28px); background: var(--cream); border-radius: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: pop .3s; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; background: linear-gradient(#fff, var(--cream)); border-bottom: 2px dashed #f1dccb; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 24px; }
.close-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff; font-size: 20px; color: var(--text); box-shadow: 0 3px 0 rgba(120, 80, 50, .2); }
.sheet-body { padding: 14px 16px 18px; overflow-y: auto; }
.shop-intro { margin: 0 0 12px; color: var(--text-soft); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item { background: #fff; border-radius: 18px; padding: 10px; text-align: center; box-shadow: 0 3px 0 rgba(120, 80, 50, .14); display: flex; flex-direction: column; gap: 4px; align-items: center; }
.item .emoji { font-size: 44px; line-height: 1.1; }
.item .name { font-weight: 700; font-size: 16px; }
.item .price { font-weight: 700; color: var(--mint-d); }
.item .note { font-size: 12px; color: var(--text-soft); min-height: 15px; }
.item button { margin-top: 2px; }
.item.cant { opacity: .65; }
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.carcard { background: #fff; border-radius: 20px; padding: 10px 12px 12px; box-shadow: 0 3px 0 rgba(120, 80, 50, .14); }
.carcard canvas { width: 100%; height: 110px; display: block; }
.carcard h3 { margin: 4px 0 0; font-size: 19px; }
.carcard p { margin: 2px 0 6px; color: var(--text-soft); font-size: 13px; }
.carcard .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.speed { color: #ffb400; letter-spacing: 1px; font-size: 14px; }
.colorpick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; align-items: center; }
.colorpick .swatch i { width: 28px; height: 28px; }
.map-wrap { display: flex; gap: 14px; flex-wrap: wrap; }
.map-wrap canvas { flex: none; max-width: 100%; border-radius: 16px; cursor: pointer; box-shadow: 0 3px 0 rgba(120, 80, 50, .14); touch-action: manipulation; }
.legend { flex: 1 1 200px; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.legend h4 { margin: 4px 0 0; font-size: 14px; color: var(--text-soft); }
.legend button { text-align: left; border: 0; border-radius: 12px; padding: 7px 10px; background: #fff; font-size: 15px; font-weight: 600; color: var(--text); box-shadow: 0 2px 0 rgba(120, 80, 50, .14); }
.legend button:active { transform: translateY(2px); }
.home-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.home-opts button { border: 0; border-radius: 20px; background: #fff; padding: 16px 10px; font-size: 17px; font-weight: 700; color: var(--text); box-shadow: 0 3px 0 rgba(120, 80, 50, .14); }
.home-opts button span { display: block; font-size: 40px; }

/* ---------- puhelin ---------- */
.phone { position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); z-index: 35; animation: phoneIn .3s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes phoneIn { from { transform: translateY(60%); opacity: 0; } }
.phone-frame { width: 330px; height: min(600px, calc(100vh - 32px)); background: #2d2a32; border-radius: 40px; padding: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, .35), inset 0 0 0 3px #4a4552; display: flex; flex-direction: column; }
.phone-status { display: flex; justify-content: space-between; align-items: center; color: #fff; font-size: 13px; font-weight: 600; padding: 2px 16px 6px; }
.notch { width: 80px; height: 18px; border-radius: 10px; background: #111; }
.phone-screen { flex: 1; border-radius: 26px; overflow: hidden; background: linear-gradient(160deg, #ffd6e3, #fff1c9 50%, #c7f0ff); position: relative; display: flex; flex-direction: column; }
.phone-nav { display: flex; justify-content: space-around; padding-top: 8px; }
.phone-nav button { border: 0; background: none; color: #ddd; font-size: 18px; width: 60px; }
.apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; padding: 18px 12px; }
.app { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text); position: relative; }
.app .ic { width: 62px; height: 62px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 32px; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.app .badge { top: -4px; right: 8px; }
.ph-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(255, 255, 255, .75); font-weight: 700; font-size: 17px; }
.ph-body { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.contact { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 16px; background: #fff; padding: 8px 10px; text-align: left; font-size: 16px; font-weight: 600; color: var(--text); box-shadow: 0 2px 0 rgba(0, 0, 0, .08); }
.contact canvas { width: 40px; height: 40px; border-radius: 50%; background: #e9f8ff; }
.contact .unread { margin-left: auto; background: #ff4d6d; color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 7px; }
.chat { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 80%; padding: 7px 11px; border-radius: 16px; font-size: 15px; line-height: 1.25; word-wrap: break-word; user-select: text; -webkit-user-select: text; }
.bubble.me { align-self: flex-end; background: var(--pink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.bubble img { display: block; max-width: 100%; border-radius: 10px; margin: 2px 0; }
.bubble small { display: block; font-size: 10px; opacity: .7; margin-top: 2px; }
.chat-input { display: flex; gap: 6px; padding: 8px; background: rgba(255, 255, 255, .8); }
.chat-input input { flex: 1; min-width: 0; border: 2px solid #f1dccb; border-radius: 999px; padding: 8px 12px; font-size: 15px; outline: none; user-select: text; -webkit-user-select: text; }
.chat-input button { border: 0; border-radius: 50%; width: 40px; height: 40px; background: var(--pink); color: #fff; font-size: 18px; flex: none; }
.quick { display: flex; gap: 4px; padding: 0 8px 6px; flex-wrap: wrap; background: rgba(255, 255, 255, .8); }
.quick button { border: 0; background: #fff; border-radius: 999px; padding: 4px 8px; font-size: 16px; box-shadow: 0 1px 0 rgba(0, 0, 0, .1); }
.photo-big { width: 100%; border-radius: 14px; box-shadow: 0 3px 0 rgba(0, 0, 0, .1); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; cursor: pointer; }
.cam-view { position: relative; border-radius: 14px; overflow: hidden; background: #000; }
.cam-view img { display: block; width: 100%; }
.shutter { width: 70px; height: 70px; border-radius: 50%; border: 5px solid #fff; background: var(--pink); box-shadow: 0 0 0 3px var(--pink-d); align-self: center; font-size: 26px; color: #fff; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ph-note { font-size: 13px; color: var(--text-soft); text-align: center; line-height: 1.3; }
.ach { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach div { background: #fff; border-radius: 14px; padding: 6px 4px; text-align: center; font-size: 11px; font-weight: 600; }
.ach div span { display: block; font-size: 28px; }
.ach div.locked { opacity: .35; filter: grayscale(1); }
.setting { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: 14px; padding: 8px 12px; font-weight: 600; }
.code { font-size: 26px; font-weight: 700; text-align: center; letter-spacing: 2px; background: #fff; border-radius: 14px; padding: 8px; color: var(--pink-d); user-select: text; -webkit-user-select: text; }
.linkbox { font-size: 12px; background: #fff; border-radius: 10px; padding: 8px; word-break: break-all; user-select: text; -webkit-user-select: text; }

/* ---------- uni ---------- */
.sleep { position: fixed; inset: 0; z-index: 50; background: radial-gradient(ellipse at center, #2b2f6b, #0e1030); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; animation: fadeIn 1s; }
@keyframes fadeIn { from { opacity: 0; } }
.zzz { font-size: 80px; position: relative; }
.zzz span { position: absolute; font-size: 30px; font-weight: 700; color: #cfd8ff; animation: zz 2.4s infinite; }
.zzz span:nth-child(1) { left: 80px; top: 0; } .zzz span:nth-child(2) { left: 100px; top: -24px; animation-delay: .8s; } .zzz span:nth-child(3) { left: 120px; top: -48px; animation-delay: 1.6s; }
@keyframes zz { 0% { opacity: 0; transform: translateY(10px); } 50% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.sleep p { font-size: 20px; margin: 0; text-align: center; padding: 0 20px; }

/* ---------- puhelinkoot ---------- */
@media (max-width: 760px) {
  .editor-card { flex-direction: column; max-height: none; }
  .editor-preview { flex: none; }
  .editor-preview { flex-direction: row; gap: 10px; padding: 8px; }
  .editor-preview canvas { max-width: 140px; }
  .preview-btns { flex-direction: column; }
  #topright { width: 150px; }
  .clock-box { height: 50px; }
  #clockText { font-size: 20px; }
  .map-btn { font-size: 12px; padding: 5px; }
  #topleft { width: min(260px, calc(100vw - 190px)); }
  .task-title { font-size: 15px; }
  .task-text { font-size: 13px; }
  .task-icon { width: 36px; height: 36px; font-size: 24px; }
  .pill { font-size: 17px; }
  .phone-frame { width: min(330px, calc(100vw - 24px)); }
  .phone { right: 12px; }
  .act { font-size: 16px; padding: 9px 14px; }
  .act.buy { font-size: 20px; padding: 11px 18px; }
  .goal { font-size: 11px; }
}
@media (max-height: 520px) {
  #goal { display: none; }
  .clock-box { height: 44px; }
  #minimap { max-height: 110px; object-fit: contain; }
  .phone-frame { height: calc(100vh - 24px); }
}
@media (max-height: 520px) {
  #topleft { width: min(250px, 40vw); gap: 6px; }
  .task { padding: 7px 10px; }
  .task-title { font-size: 14px; }
  .task-text { font-size: 12.5px; margin-top: 3px; }
  .task-icon { width: 32px; height: 32px; font-size: 20px; border-radius: 10px; }
  .task-foot { margin-top: 3px; font-size: 12px; }
  .pill { font-size: 16px; padding: 4px 10px 4px 4px; }
  #money .coin { width: 24px; height: 24px; font-size: 14px; }
  #topright { width: 150px; gap: 6px; }
  .map-btn { font-size: 11px; padding: 4px; margin-top: 4px; }
  .phone-btn { width: 58px; height: 58px; font-size: 30px; border-radius: 18px; }
  #touchBtns { bottom: calc(84px + var(--safe-b)); right: calc(16px + var(--safe-r)); }
  .touch #actions { right: calc(86px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); }
  .act { font-size: 15px; padding: 8px 12px; }
  .act.buy { font-size: 18px; padding: 10px 16px; }
  .toast { font-size: 13px; padding: 6px 10px; }
}

/* ---------- puhelinoptimointi: ikkunat koko näytölle pienillä näytöillä ---------- */
@supports (height: 100dvh) {
  .sheet { max-height: calc(100dvh - 28px); }
  .phone-frame { height: min(600px, calc(100dvh - 32px)); }
  .editor-card { max-height: calc(100dvh - 32px); }
}
@media (max-width: 760px), (max-height: 520px) {
  .modal { padding: 0; }
  .sheet { width: 100%; height: 100%; max-height: none; border-radius: 0; padding-left: var(--safe-l); padding-right: var(--safe-r); }
  .sheet-head { padding: calc(10px + var(--safe-t)) 12px 8px; }
  .sheet-head h2 { font-size: 20px; }
  .sheet-body { padding: 10px 12px calc(16px + var(--safe-b)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
  .item .emoji { font-size: 36px; }
  .cars { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
  .carcard canvas { height: 90px; }
  .home-opts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .phone { inset: 0; right: 0; bottom: 0; }
  .phone-frame { width: 100vw; height: 100%; border-radius: 0; padding: calc(8px + var(--safe-t)) 8px calc(8px + var(--safe-b)); }
  .phone-screen { border-radius: 18px; }
}
@media (max-height: 520px) {
  .start-card { padding: 12px 18px; }
  .logo { margin-bottom: 2px; }
  .logo .sun { font-size: 30px; }
  .logo h1 { font-size: 28px; }
  .tagline { display: none; }
  .field { margin-top: 6px; }
  .field input { font-size: 18px; padding: 7px 12px; }
  .hint { display: none; }
  .big-btn { margin-top: 8px; padding: 10px; font-size: 21px; }
  .net-hint { display: none; }
  .phone { top: 8px; bottom: 8px; }
  .phone-frame { height: 100%; width: 300px; border-radius: 28px; padding: 8px; }
  .phone-status { padding: 0 12px 4px; }
  .apps { gap: 8px 6px; padding: 10px 8px; }
  .app .ic { width: 48px; height: 48px; font-size: 26px; border-radius: 14px; }
  .editor-card { max-height: calc(100vh - 16px); }
  .editor-preview canvas { max-width: 170px; }
}

/* ilmoitukset alas, kun ikkuna tai puhelin on auki */
body.overlay-open #toasts { top: auto; bottom: calc(16px + var(--safe-b)); }

/* =====================================================================
   Kevyt HUD puhelimelle (body.compact): pienet kuvakkeet, vähän tekstiä,
   pelinäkymä mahdollisimman vapaana.
   ===================================================================== */
.task-mini, .clock-mini, .map-corner { display: none; }
.compact #topleft { width: auto; max-width: min(62vw, 330px); gap: 5px; left: calc(8px + var(--safe-l)); top: calc(8px + var(--safe-t)); }
.compact #moneyRow { gap: 5px; }
.compact .pill { font-size: 14px; padding: 3px 9px 3px 3px; gap: 4px; box-shadow: 0 2px 0 rgba(120, 80, 50, .18), 0 3px 8px rgba(80, 50, 30, .12); background: rgba(255, 248, 238, .94); }
.compact .pill.small { font-size: 12px; padding: 3px 8px; }
.compact #money .coin { width: 20px; height: 20px; font-size: 12px; }
.compact #goal { display: none; }
.compact #taskCard { display: none; }
.compact.task-open #taskCard { display: block; padding: 8px 10px; max-width: min(78vw, 330px); }
.compact .task-title { font-size: 14px; }
.compact .task-text { font-size: 12.5px; margin-top: 3px; }
.compact .task-icon { width: 30px; height: 30px; font-size: 19px; border-radius: 10px; }
.compact .task-foot { margin-top: 3px; font-size: 12px; }
.compact .task-mini { display: flex; align-items: center; gap: 6px; border: 0; background: rgba(255, 248, 238, .94); border-radius: 999px; padding: 3px 10px 3px 3px; font-size: 12.5px; font-weight: 600; color: var(--text); max-width: 100%; box-shadow: 0 2px 0 rgba(120, 80, 50, .18), 0 3px 8px rgba(80, 50, 30, .12); text-align: left; }
.compact.task-open .task-mini { display: none; }
.task-mini .ic { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.task-mini .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.task-mini .dist { color: var(--pink-d); flex: none; font-size: 11px; font-weight: 700; }
.task-mini .dist:empty { display: none; }
.compact #topright { width: 96px; gap: 5px; top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); }
.compact .map-box { padding: 3px; border-radius: 14px; position: relative; background: rgba(255, 248, 238, .94); box-shadow: 0 2px 0 rgba(120, 80, 50, .18), 0 3px 8px rgba(80, 50, 30, .12); }
.compact #minimap { border-radius: 11px; max-height: none; }
.compact .map-btn { display: none; }
.compact .map-corner { display: block; position: absolute; right: -4px; bottom: -6px; font-size: 15px; background: #fff; border-radius: 50%; width: 24px; height: 24px; text-align: center; line-height: 24px; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); pointer-events: none; }
.compact #clockBox { display: none; }
.compact .clock-mini { display: flex; align-self: center; align-items: center; gap: 4px; background: rgba(255, 248, 238, .94); border-radius: 999px; padding: 2px 9px 2px 6px; font-size: 13px; font-weight: 700; box-shadow: 0 2px 0 rgba(120, 80, 50, .18); }
.compact .phone-btn { width: 50px; height: 50px; font-size: 26px; border-radius: 16px; right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); }
.compact .badge { min-width: 20px; height: 20px; border-radius: 10px; font-size: 12px; top: -5px; right: -5px; padding: 0 5px; }
.compact #actions { left: auto; right: calc(68px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); transform: none; flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
.compact .act { font-size: 14px; padding: 6px 12px 6px 8px; min-height: 42px; border-radius: 21px; gap: 6px; box-shadow: 0 3px 0 rgba(120, 80, 50, .2), 0 4px 10px rgba(80, 50, 30, .15); }
.compact .act > span:first-child { font-size: 20px; }
.compact .act.icon-only { width: 46px; height: 46px; padding: 0; justify-content: center; }
.compact .act.buy { font-size: 16px; padding: 7px 14px 7px 10px; }
.compact .act.buy small { font-size: 11px; }
.compact .act .key { display: none; }
.compact .edge-arrow { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
.compact .edge-arrow .arrow-head { font-size: 22px; }
.compact .edge-arrow span { font-size: 10px; bottom: -7px; padding: 0 5px; }
/* ilmoitukset alas keskelle, jotta yläreunan kuvakkeet pysyvät näkyvissä */
.compact #toasts { width: min(340px, 64vw); top: auto; bottom: calc(70px + var(--safe-b)); flex-direction: column-reverse; }
.compact .toast { font-size: 12px; padding: 5px 10px; border-radius: 10px; box-shadow: 0 2px 6px rgba(80, 50, 30, .2); background: rgba(255, 248, 238, .94); }
.compact .banner { padding: 8px 18px; border-radius: 18px; top: 30%; }
.compact .banner b { font-size: 20px; }
.compact .banner span { font-size: 15px; }
.compact .joy-hint { font-size: 12px; padding: 6px 10px 6px 36px; left: calc(10px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); }
.compact .joy-hint span { font-size: 19px; left: 9px; margin-top: -12px; }
.compact #touchBtns { right: calc(10px + var(--safe-r)); bottom: calc(68px + var(--safe-b)); }
.compact .touch-btn { width: 46px; height: 46px; font-size: 22px; }
.compact .joy { width: 110px; height: 110px; margin: -55px 0 0 -55px; }
.compact .joy i { width: 46px; height: 46px; margin: -23px 0 0 -23px; }

/* ---------- trampoliinitemput ---------- */
.trick-bar { position: absolute; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: min(720px, 92vw); pointer-events: none; z-index: 2; }
.trick-btn { pointer-events: auto; position: relative; border: 0; border-radius: 16px; padding: 6px 10px 5px; min-width: 74px; background: rgba(255, 248, 238, .95); color: var(--text); box-shadow: 0 3px 0 rgba(120, 80, 50, .2), 0 4px 10px rgba(80, 50, 30, .15); display: flex; flex-direction: column; align-items: center; line-height: 1.1; animation: pop .3s; }
.trick-btn .ti { font-size: 24px; }
.trick-btn .tn { font-size: 12px; font-weight: 700; }
.trick-btn small { font-size: 10px; color: var(--text-soft); font-weight: 600; }
.trick-btn .key { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--text-soft); }
.trick-btn.queued { background: var(--pink); color: #fff; transform: translateY(-3px); }
.trick-btn.queued small { color: #fff; }
.trick-btn.locked { opacity: .7; filter: grayscale(.6); }
.setting.dim { opacity: .6; }
.setting small { font-size: 12px; color: var(--text-soft); }
.compact .trick-bar { bottom: calc(66px + var(--safe-b)); gap: 4px; max-width: calc(100vw - 20px); }
.compact .trick-btn { min-width: 0; width: 52px; padding: 4px 2px 3px; border-radius: 14px; }
.compact .trick-btn .ti { font-size: 20px; }
.compact .trick-btn .tn { display: none; }
.compact .trick-btn small { font-size: 9px; }

.legend button.mystery { background: #f1eaff; color: #8a6fb0; font-weight: 600; opacity: .85; cursor: default; }

/* ---------- iso teksti (superpompun laskenta) ---------- */
.big-text { position: fixed; left: 50%; top: 26%; transform: translate(-50%, -50%) scale(.6); z-index: 46; font-size: 44px; font-weight: 700; color: #fff; text-shadow: 0 3px 0 var(--pink-d), 0 0 18px rgba(255, 111, 181, .8); pointer-events: none; opacity: 0; white-space: nowrap; }
.big-text.show { animation: bigPop .9s ease-out forwards; }
.big-text.strong { font-size: 66px; color: #ffd21f; text-shadow: 0 4px 0 #e8590c, 0 0 24px rgba(255, 210, 31, .9); }
@keyframes bigPop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(.95); } }
.compact .big-text { font-size: 30px; } .compact .big-text.strong { font-size: 44px; }
.item canvas { display: block; margin: 0 auto; }
.pet-name { width: 100%; border: 2px solid #f1dccb; border-radius: 999px; padding: 5px 10px; font-size: 14px; text-align: center; outline: none; user-select: text; -webkit-user-select: text; }
.item .colorpick { justify-content: center; margin: 2px 0; }

/* ---------- kameran etsin ---------- */
.viewfinder { position: fixed; inset: 0; z-index: 38; pointer-events: none; }
.viewfinder > * { pointer-events: auto; }
.vf-frame { position: absolute; inset: 9% 7% 20%; pointer-events: none !important; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28); border-radius: 10px; }
.vf-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid rgba(255, 255, 255, .95); }
.vf-frame .c1 { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.vf-frame .c2 { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.vf-frame .c3 { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.vf-frame .c4 { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.vf-focus { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; margin: -35px 0 0 -35px; border: 2px solid rgba(255, 220, 90, .9); border-radius: 8px; animation: vfFocus 1.6s infinite; }
@keyframes vfFocus { 50% { transform: scale(.85); } }
.vf-top { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; color: #fff; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); font-size: 15px; }
.vf-rec { color: #ff6b6b; }
.vf-controls { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 16px; }
.vf-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .85); font-size: 22px; font-weight: 700; color: #333; }
.vf-btn.on { background: var(--pink); color: #fff; }
.vf-shutter { width: 78px; height: 78px; border-radius: 50%; border: 6px solid #fff; background: rgba(255, 255, 255, .5); box-shadow: 0 0 0 3px rgba(0, 0, 0, .25); }
.vf-shutter:active { background: #fff; transform: scale(.94); }
.vf-hint { position: absolute; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translateX(-50%); color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); white-space: nowrap; }
body.vf-open #topleft, body.vf-open #topright, body.vf-open #actions, body.vf-open .phone-btn, body.vf-open #trickBar, body.vf-open #arrow, body.vf-open #touchBtns, body.vf-open .joy-hint { display: none !important; }
.compact .vf-hint { font-size: 11px; bottom: calc(96px + var(--safe-b)); }
.compact .vf-frame { inset: 12% 5% 22%; }

/* ---------- harvinaiset ---------- */
.rar { display: inline-block; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; margin: 2px 0; }
.rare-top { display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #f3e8ff, #ffe3f1); border-radius: 18px; padding: 10px 14px; margin-bottom: 10px; flex-wrap: wrap; }
.rare-info { flex: 1; min-width: 200px; }
.rare-info .odds { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-weight: 700; margin: 4px 0; }
.rare-card { border: 3px solid transparent; }
.r-harvinainen { border-color: #1f5fe0 !important; }
.r-eepinen { border-color: #9b5de5 !important; box-shadow: 0 0 14px rgba(155, 93, 229, .35); }
.r-legendaarinen { border-color: #ff8c1a !important; box-shadow: 0 0 18px rgba(255, 170, 40, .55); background: linear-gradient(#fff, #fff6dc); }
.rare-card.unknown .name { color: #aaa; }
.drop-wrap { display: flex; justify-content: center; }
.drop-card { margin: 0 auto 10px; max-width: 280px; text-align: center; background: #fff; border-radius: 22px; padding: 12px; border: 4px solid #ccc; animation: dropIn .6s cubic-bezier(.2, 1.6, .4, 1); }
.drop-card canvas { display: block; margin: 0 auto; }
.drop-name { font-size: 22px; font-weight: 700; }
.drop-val { font-weight: 700; color: var(--mint-d); }
.drop-card.r-legendaarinen { animation: dropIn .6s cubic-bezier(.2, 1.6, .4, 1), legendGlow 1.5s infinite alternate; }
@keyframes dropIn { from { transform: scale(.3) rotate(-10deg); opacity: 0; } }
@keyframes legendGlow { to { box-shadow: 0 0 34px rgba(255, 190, 60, .9); } }
.trade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.trade-item { border: 3px solid #eee; background: #fff; border-radius: 12px; padding: 4px; display: flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--text); }
.trade-item.sel { background: #fff0f6; outline: 3px solid var(--pink); }
.trade-item small { font-size: 9.5px; line-height: 1.15; text-align: center; }
.col-row { flex-wrap: wrap; gap: 4px; }
.col-row .row-btns { margin-left: auto; }
.col-row .pill-btn { padding: 5px 10px; font-size: 13px; }
.trade-warn { color: #c2410c; font-weight: 700; }
