/* Värit poimittu lonteva.fi/vision -sivulta */
:root {
  --violet: #7c3aed;
  --violet-2: #8b5cf6;
  --violet-soft: #f3f0ff;
  --ink: #1f2430;
  --ink-2: #303747;
  --muted: #5a5f6d;
  --line: #dde1ee;
  --bg: #f5f7fb;
  --green: #10b981;
  --amber-bg: #fef3c7;
  --amber: #92400e;
  --red: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d111a; }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

/* Mittarit */
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); font-size: 12px; }
.pill { background: var(--ink); color: #fff; font-weight: 700; padding: 5px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; font-size: 14px; }
.pill.late { background: var(--red); }
.meter { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.bar { width: 80px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .25s, background .25s; }
#teamHud { display: flex; gap: 8px; margin-left: auto; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.chip b { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 11px; }
.chip .bar { width: 28px; height: 5px; }
.chip.out b { background: #9ca3af !important; text-decoration: line-through; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 15px; padding: 0; }

#toast { position: absolute; left: 50%; top: 100px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 16px; font-size: 13px; font-weight: 600; width: max-content; max-width: 86%; text-align: center; pointer-events: none; z-index: 3; }

/* Raahattava iPhone */
#phone { position: absolute; z-index: 4; width: 322px; height: min(640px, calc(100% - 70px)); touch-action: none; }
.iphone { height: 100%; background: #0d111a; border-radius: 46px; padding: 10px; position: relative; cursor: grab;
  box-shadow: 0 0 0 2px #4a5268, 0 0 0 4px #1f2430, 0 26px 60px rgba(13,17,26,.5); }
.iphone:active { cursor: grabbing; }
.iphone::before, .iphone::after { content: ''; position: absolute; width: 4px; background: #303747; border-radius: 2px; }
.iphone::before { left: -6px; top: 120px; height: 34px; box-shadow: 0 48px 0 #303747; }
.iphone::after { right: -6px; top: 150px; height: 64px; }
.glass { height: 100%; background: #fff; border-radius: 36px; overflow: hidden; display: flex; flex-direction: column; }
.status { flex: none; height: 40px; display: flex; justify-content: space-between; align-items: center; padding: 4px 24px 0; font-weight: 700; font-size: 13px; position: relative; }
.status .sig { font-size: 10px; letter-spacing: 1px; }
.island { position: absolute; left: 50%; top: 9px; width: 86px; height: 24px; border-radius: 14px; background: #0d111a; transform: translateX(-50%); }
.appbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 14px 10px; font-size: 15px; font-weight: 700; }
.appbar img, .appbar .ico { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.appbar .ico { display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 700; }
.appbar small { display: block; font-size: 10px; font-weight: 600; opacity: .7; letter-spacing: .04em; }
.appbar .q { margin-left: auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.16); }
#panelBody { flex: 1; overflow: auto; padding: 12px 14px; touch-action: pan-y; cursor: auto; }
.tabbar { flex: none; display: none; border-top: 1px solid var(--line); background: #fff; }
.tabbar button { border: 0; background: none;  flex: 1; text-align: center; font-size: 10px; font-weight: 600; color: var(--muted); padding: 6px 0 2px; }
.tabbar button b { display: block; font-size: 15px; }
.tabbar button.on { color: var(--violet); }
.homebar { flex: none; height: 18px; display: grid; place-items: center; background: #fff; }
.homebar i { width: 112px; height: 4px; border-radius: 4px; background: #1f2430; }

/* Vision Platform -sovellus */
.t-vision .status, .t-vision .appbar { background: #13213b; color: #fff; }
.t-vision .appbar small { color: #e0c58d; opacity: 1; }
.t-vision .tabbar { display: flex; }
.t-vision #panelBody { background: #f7f8fc; }
.vcard { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.vcard h2 { font-size: 15px !important; }
.vcard p { margin-bottom: 0 !important; font-size: 13px !important; }

/* Front-sovellus (viestit) */
.t-front .status, .t-front .appbar { background: #0050ff; color: #fff; }
.t-front #panelBody { background: #f5f7fb; }
.mail { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.mail .who { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.mail .who b { width: 30px; height: 30px; border-radius: 50%; background: #eef3ff; color: #0050ff; display: grid; place-items: center; font-size: 13px; flex: none; }
.mail .who strong { display: block; color: var(--ink); font-size: 13px; }
.chan { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #0050ff; background: #eef3ff; padding: 2px 8px; border-radius: 99px; margin-bottom: 8px; }
.chat { background: #eef3ff; border-radius: 16px 16px 16px 4px; padding: 10px 12px; font-size: 14px; line-height: 1.45; margin: 0 24px 12px 0; }
.chat b { display: block; margin-bottom: 2px; }
.ai { font-size: 12px; color: #0b3bb3; background: #eef3ff; border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; }

/* Puhelu */
.t-call .glass, .t-call .status, .t-call .appbar, .t-call .homebar, .t-call #panelBody { background: #16181d; color: #fff; }
.t-call .homebar i { background: #fff; }
.call { text-align: center; padding-top: 8px; }
.call .ring { width: 84px; height: 84px; border-radius: 50%; background: #303747; display: grid; place-items: center; font-size: 36px; margin: 0 auto 10px; animation: ring 0.9s infinite; }
@keyframes ring { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); } 60% { box-shadow: 0 0 0 16px rgba(16,185,129,0); } }
.call h2 { color: #fff; margin-bottom: 2px !important; }
.call .sub { font-size: 12px; opacity: .6; margin-bottom: 14px; }
.call .say { background: #303747; border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.45; text-align: left; margin-bottom: 14px; color: #fff !important; }

/* Kalenteri */
.t-cal .appbar .ico { background: #fff; color: #dc2626; border: 1px solid var(--line); }
.event { border-left: 4px solid #dc2626; background: #fef2f2; border-radius: 6px 12px 12px 6px; padding: 10px 12px; margin-bottom: 12px; }
.event h2 { font-size: 15px !important; }
.event p { margin: 0 !important; font-size: 13px !important; }

/* Lukitusnäyttö */
.t-lock .glass, .t-lock .status, .t-lock .homebar, .t-lock #panelBody { background: #1c3157; color: #fff; }
.t-lock .appbar { display: none; }
.t-lock .homebar i { background: #fff; }
.lock-time { text-align: center; font-size: 56px; font-weight: 700; line-height: 1; margin: 6px 0 2px; }
.lock-date { text-align: center; font-size: 13px; opacity: .75; margin-bottom: 16px; }
.notif { background: rgba(255,255,255,.14); border-radius: 14px; padding: 9px 11px; margin-bottom: 8px; font-size: 12px; line-height: 1.4; display: flex; gap: 9px; align-items: center; }
.notif .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; font-weight: 700; color: #fff; }
.notif img { width: 28px; height: 28px; flex: none; }
.notif b { display: block; font-size: 12px; }
.lock-note { font-size: 13px; line-height: 1.45; margin: 12px 2px; opacity: .92; color: #fff !important; }

#peek { position: absolute; right: 8px; top: 58px; z-index: 3; border: 0; border-radius: 99px; background: var(--violet); color: #fff; font-weight: 700; font-size: 13px; padding: 8px 14px; box-shadow: 0 6px 16px rgba(13,17,26,.25); }

.src { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--violet); background: var(--violet-soft); padding: 3px 8px; border-radius: 99px; }
.src.risk { color: var(--amber); background: var(--amber-bg); }
.from { font-size: 12px; color: var(--muted); margin: 8px 0 2px; }
#panelBody h2 { font-size: 17px; line-height: 1.3; margin: 0 0 6px; }
#panelBody p { font-size: 14px; line-height: 1.5; margin: 0 0 12px; color: var(--ink-2); }
.label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.team { display: grid; gap: 6px; }
.member { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 10px; display: grid;
  grid-template-columns: 26px 1fr; gap: 0 8px; align-items: center; color: var(--ink); }
.member:hover:not(:disabled), .member:focus-visible { border-color: var(--violet-2); background: var(--violet-soft); outline: none; }
.member:disabled { opacity: .45; cursor: not-allowed; }
.member b.av { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 12px; grid-row: span 2; }
.member .nm { font-weight: 700; font-size: 13px; }
.member .nm small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.member .sk { font-size: 11px; color: var(--violet); font-weight: 600; }
.member .bar { grid-column: 1 / -1; width: 100%; height: 4px; margin-top: 5px; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 14px; text-align: center; text-decoration: none; }
.btn.primary { background: var(--violet); color: #fff; }
.btn.primary:hover { background: #6d28d9; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result { border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.result.good { background: #ecfdf5; color: #065f46; }
.result.bad { background: var(--amber-bg); color: var(--amber); }
.result.neutral { background: var(--violet-soft); color: #4c1d95; }
.delta { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }

/* Verho */
#curtain { position: absolute; inset: 0; background: rgba(13,17,26,.92); color: #fff; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 24px; text-align: center; z-index: 5; }
#curtain p { font-size: 18px; font-weight: 600; margin: 0; max-width: 420px; line-height: 1.4; }
#curtain .bar { width: 220px; height: 10px; background: rgba(255,255,255,.2); }
#curtain .bar i { background: var(--violet-2); transition: none; }

/* Aloitus- ja loppuruutu */
#overlay { position: absolute; inset: 0; background: rgba(13,17,26,.72); display: grid; place-items: center; padding: 16px; z-index: 6; overflow: auto; }
.card { background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.4); }
.card img.mark { width: 52px; height: 52px; }
.card .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--violet); margin: 10px 0 4px; }
.card h1 { font-size: 26px; margin: 0 0 8px; line-height: 1.15; }
.card p { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin: 0 0 14px; }
.card ul { text-align: left; font-size: 14px; line-height: 1.5; color: var(--ink-2); padding-left: 20px; margin: 0 0 18px; }
.card .btn + .btn, .card .row { margin-top: 8px; }
.card .row .btn { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px 4px; font-size: 11px; color: var(--muted); }
.stats b { display: block; font-size: 20px; color: var(--ink); }
.grade { display: inline-block; background: var(--violet-soft); color: var(--violet); font-weight: 700; padding: 6px 14px; border-radius: 99px; margin-bottom: 10px; }
.pitch { background: var(--violet-soft); border-radius: 12px; padding: 12px; font-size: 14px; }
.tag { font-size: 10px; letter-spacing: .14em; color: var(--muted); margin-top: 14px; }

/* Puhelin: paneeli alareunaan */
@media (max-width: 720px) {
  #phone { width: min(322px, calc(100% - 24px)); height: min(560px, 68%); }
  #hud { gap: 8px; flex-wrap: nowrap; }
  .meter .bar { width: 44px; }
  #teamHud { gap: 4px; }
  .chip b { width: 20px; height: 20px; font-size: 10px; }
  .chip .bar { width: 22px; }
  .icon-btn { width: 30px; height: 30px; flex: none; }
  .card { padding: 20px; }
  .card h1 { font-size: 22px; }
}

@media (max-width: 350px) { .meter span { display: none; } }

/* Tiivistys, jotta Vision-näkymä mahtuu puhelimen ruudulle vierittämättä */
#phone .member { padding: 5px 10px; border-radius: 10px; }
#phone .team { gap: 5px; }
#phone .member .bar { margin-top: 3px; }
#phone .vcard { padding: 8px 12px; margin-bottom: 8px; }
#phone .label { margin: 8px 0 5px; }
#phone .btn { padding: 10px 14px; }

/* Front: vaalea ilme ja violetti korostus oikean logon mukaan */
.t-front .status, .t-front .appbar { background: #fff; color: var(--ink); }
.t-front .appbar { border-bottom: 1px solid var(--line); }
.t-front .appbar .q { background: #f3f0ff; color: #7c3aed; }
.chan { color: #7c3aed; background: #f3f0ff; }
.mail .who b { background: #f3f0ff; color: #7c3aed; }
.chat { background: #f3f0ff; }

/* Ruudun ohjaimet */
#pad { position: absolute; left: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 3; display: grid; gap: 4px;
  grid-template: "x u y" 48px "l c r" 48px "z d w" 48px / 48px 48px 48px; touch-action: none; }
#pad button, #viewPad button { border: 0; border-radius: 14px; background: rgba(31,36,48,.82); color: #fff; font-size: 18px; touch-action: none;
  box-shadow: 0 4px 12px rgba(13,17,26,.25); }
#pad button:active, #viewPad button:active { background: var(--violet); }
#pad span { display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink); background: rgba(255,255,255,.85); border-radius: 50%; }
#viewPad { position: absolute; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 3; display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.88); border-radius: 18px; padding: 5px; touch-action: none; }
#viewPad button { width: 48px; height: 48px; }
#viewPad span { font-size: 11px; font-weight: 700; color: var(--ink); padding: 0 4px; }

/* Kotinäyttö: sovelluskuvakkeet ja ilmoitusmerkki */
.apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.app { position: relative; border: 0; background: none; padding: 0; display: grid; justify-items: center; gap: 5px; color: #fff; font-size: 11px; font-weight: 600; opacity: .55; }
.app img, .app > b { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; font-weight: 700; }
.app.hot { opacity: 1; }
.app.hot img, .app.hot > b { animation: appPulse 1s infinite; }
@keyframes appPulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,.5); } 50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(255,255,255,0); } }
.badge { position: absolute; top: -6px; right: 4px; min-width: 20px; height: 20px; border-radius: 10px; background: #dc2626; color: #fff; font-size: 12px; font-weight: 700; font-style: normal; display: grid; place-items: center; z-index: 1; }

/* Opastus */
.tip { background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; line-height: 1.4; margin: 0 0 10px; }
.member.match { border-color: var(--violet); box-shadow: 0 0 0 2px rgba(124,58,237,.25); animation: matchPulse 1.2s infinite; }
@keyframes matchPulse { 50% { box-shadow: 0 0 0 5px rgba(124,58,237,.12); } }

/* Delegations- ja Decisions-listat */
.deleg { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; font-size: 11px; color: var(--muted); }
.deleg .av { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.deleg span { flex: 1; min-width: 0; }
.deleg strong { display: block; color: var(--ink); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st { font-style: normal; font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 99px; flex: none; }
.st-prog { background: var(--violet-soft); color: var(--violet); }
.st-done { background: #ecfdf5; color: #065f46; }
.st-risk { background: var(--amber-bg); color: var(--amber); }
.st-back { background: #fee2e2; color: #991b1b; }
.empty { font-size: 13px; color: var(--muted); }
