@font-face { font-family: 'PS2P'; src: url('../fonts/ps2p.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'VT323'; src: url('../fonts/vt323.woff2') format('woff2'); font-display: block; }
:root {
  --y: #ffe11a; --yd: #f5c400; --m: #e5157a; --md: #b0085c; --pk: #f25fa8; --g: #1f7a3a; --gd: #135c29; --gl: #7cc47f;
  --o: #f36b21; --c: #fff4d6; --ink: #1b1b1b; --b: #2e4bc6;
  --sh: 5px 5px 0 var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--y); font-family: 'VT323', monospace; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#scanlines { position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.05) 0 1px, transparent 1px 3px); z-index: 1; }
button { font-family: 'PS2P', monospace; cursor: pointer; color: var(--ink); }
.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.show { display: flex; }

/* ---------- buttons ---------- */
.btn { border: 4px solid var(--ink); box-shadow: var(--sh); padding: 14px 18px; font-size: 13px; letter-spacing: 1px; text-align: left; transition: transform .06s; }
.btn:hover, .btn.focus { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); }
.btn:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.btn-yellow { background: var(--y); } .btn-green { background: var(--g); color: var(--y); } .btn-magenta { background: var(--m); color: #fff; }
.btn-cream { background: var(--c); } .btn-orange { background: var(--o); color: #fff; }

/* ---------- loading ---------- */
#loading { background: var(--m); align-items: center; justify-content: center; z-index: 50; }
.load-box { text-align: center; }
.load-title { font-family: 'PS2P'; font-size: 34px; line-height: 1.3; color: var(--y); text-shadow: 4px 4px 0 var(--ink); margin-bottom: 28px; }
.load-bar { width: 280px; height: 26px; border: 4px solid var(--ink); background: var(--c); margin: 0 auto; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--g); transition: width .2s; }
.load-hint { margin-top: 14px; font-size: 22px; color: #fff; }

/* ---------- menu ---------- */
#menu { flex-direction: column; justify-content: space-between; padding: 18px 22px; pointer-events: none; }
#menu > * { pointer-events: auto; }
.menu-top { display: flex; gap: 12px; align-items: stretch; }
.tag { border: 4px solid var(--ink); padding: 8px 12px; font-family: 'PS2P'; font-size: 10px; line-height: 1.5; box-shadow: var(--sh); }
.tag-ink { background: var(--y); } .tag-cream { background: var(--c); font-size: 9px; }
.tag.small { margin-left: auto; background: var(--m); color: #fff; display: flex; align-items: center; }
.menu-center { display: flex; flex-direction: column; align-items: flex-start; max-width: 560px; }
.presents { background: var(--m); color: #fff; border: 3px solid var(--ink); font-family: 'PS2P'; font-size: 9px; padding: 6px 10px; margin-bottom: 6px; }
.title { margin: 0; font-family: 'PS2P'; font-weight: normal; line-height: 1.15; transform: rotate(-4deg); transform-origin: left; }
.title span { display: block; font-size: clamp(34px, 7vw, 66px); color: var(--y); -webkit-text-stroke: 3px var(--ink); text-shadow: 5px 5px 0 var(--ink), 9px 9px 0 var(--m); }
.title span + span { margin-left: 30px; }
.ribbon { margin: 22px 0 18px; background: var(--y); border: 3px solid var(--ink); padding: 6px 12px; font-size: 22px; box-shadow: var(--sh); transform: rotate(-1.5deg); }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; width: 300px; }
.menu-tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.tile { background: var(--g); color: #fff; border: 4px solid var(--ink); box-shadow: var(--sh); padding: 8px 14px; min-width: 120px; }
.tile b { font-family: 'PS2P'; font-size: 16px; color: var(--y); display: block; }
.tile span { font-size: 20px; }
.menu-date { position: absolute; right: 22px; bottom: 22px; background: var(--m); color: #fff; border: 4px solid var(--ink); box-shadow: var(--sh); padding: 10px 14px; text-align: center; }
.menu-date b { font-family: 'PS2P'; font-size: 22px; line-height: 1.2; display: block; }
.menu-date span { font-family: 'PS2P'; font-size: 9px; background: var(--g); display: block; margin-top: 8px; padding: 4px; }

/* ---------- panel ---------- */
#panel, #pause { background: rgba(27,27,27,.55); align-items: center; justify-content: center; z-index: 30; }
.panel-box { width: min(880px, 94vw); max-height: 90vh; background: var(--c); border: 5px solid var(--ink); box-shadow: 9px 9px 0 var(--ink); display: flex; flex-direction: column; }
.panel-box.small { width: min(380px, 92vw); }
.panel-head { display: flex; align-items: center; justify-content: space-between; background: var(--m); border-bottom: 5px solid var(--ink); padding: 10px 14px; }
.panel-head h2 { margin: 0; font-family: 'PS2P'; font-weight: normal; font-size: 16px; color: var(--y); text-shadow: 3px 3px 0 var(--ink); }
.x { background: var(--y); border: 3px solid var(--ink); font-size: 12px; padding: 6px 9px; }
.panel-body { padding: 16px; overflow: auto; font-size: 22px; line-height: 1.15; }
.panel-body.col { display: flex; flex-direction: column; gap: 12px; }
.panel-body h3 { font-family: 'PS2P'; font-size: 12px; font-weight: normal; margin: 16px 0 6px; background: var(--y); display: inline-block; padding: 4px 8px; border: 3px solid var(--ink); }
.panel-body p { margin: 6px 0; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mcard { background: #fff; border: 4px solid var(--ink); box-shadow: var(--sh); padding: 0; text-align: left; font-family: 'VT323'; font-size: 20px; display: flex; flex-direction: column; }
.mcard:hover { transform: translate(-2px,-2px); }
.mcard .mc-top { background: var(--g); color: var(--y); font-family: 'PS2P'; font-size: 9px; padding: 6px 8px; border-bottom: 3px solid var(--ink); }
.mcard .mc-title { font-family: 'PS2P'; font-size: 12px; padding: 10px 8px 4px; line-height: 1.4; }
.mcard .mc-meta { padding: 0 8px 8px; }
.mcard .mc-stars { padding: 4px 8px 8px; color: var(--m); font-size: 26px; letter-spacing: 3px; }
.mcard.locked { opacity: .55; }
.keytable { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.keytable b { font-family: 'PS2P'; font-size: 10px; background: var(--ink); color: var(--y); padding: 5px 7px; align-self: start; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 2px dashed #0003; }
.seg { display: flex; } .seg button { border: 3px solid var(--ink); background: #fff; font-size: 10px; padding: 8px 10px; margin-left: -3px; }
.seg button.on { background: var(--y); }

/* ---------- brief ---------- */
#brief { align-items: center; justify-content: center; background: rgba(229,21,122,.35); z-index: 20; }
.brief-card, .result-card { width: min(680px, 94vw); max-height: 92vh; overflow: auto; background: var(--c); border: 5px solid var(--ink); box-shadow: 10px 10px 0 var(--ink); padding: 20px 22px; position: relative; }
.brief-tag { display: inline-block; background: var(--g); color: var(--y); font-family: 'PS2P'; font-size: 10px; padding: 6px 10px; border: 3px solid var(--ink); }
.brief-card h2 { font-family: 'PS2P'; font-weight: normal; font-size: 20px; line-height: 1.35; margin: 14px 0; color: var(--m); text-shadow: 3px 3px 0 var(--ink); }
.brief-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.brief-meta div { background: var(--y); border: 3px solid var(--ink); padding: 6px 8px; }
.brief-meta small { display: block; font-family: 'PS2P'; font-size: 8px; }
.brief-meta b { font-family: 'PS2P'; font-size: 14px; font-weight: normal; }
#briefText { font-size: 23px; line-height: 1.15; }
.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 10px 0 16px; }
.steps li { counter-increment: s; font-size: 21px; padding: 6px 8px 6px 44px; position: relative; border-left: 5px solid var(--g); margin-bottom: 4px; background: #fff; }
.steps li::before { content: counter(s); position: absolute; left: 6px; top: 5px; font-family: 'PS2P'; font-size: 11px; background: var(--m); color: #fff; width: 26px; height: 22px; display: grid; place-items: center; border: 2px solid var(--ink); }
.brief-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; display: none; }
#hud.show { display: block; }
.hud-tl { position: absolute; left: 14px; top: 14px; max-width: min(460px, 60vw); }
.hud-mission { display: inline-block; background: var(--m); color: #fff; font-family: 'PS2P'; font-size: 10px; padding: 6px 9px; border: 3px solid var(--ink); }
.hud-obj { background: var(--c); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 6px 10px; font-size: 22px; line-height: 1.05; margin-top: -3px; }
.hud-tr { position: absolute; right: 14px; top: 14px; display: flex; gap: 8px; align-items: center; }
.chip { background: var(--y); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-family: 'PS2P'; font-size: 10px; padding: 7px 9px; display: flex; gap: 6px; align-items: center; pointer-events: auto; }
.chip-pink { background: var(--pk); }
.btn-mini { cursor: pointer; }
.batt { width: 26px; height: 12px; border: 2px solid var(--ink); display: inline-block; position: relative; background: #fff; }
.batt i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--g); }
.batt.low i { background: var(--m); }
.stamina { position: absolute; left: 50%; bottom: 100px; width: 140px; height: 10px; margin-left: -70px; border: 3px solid var(--ink); background: #fff; opacity: 0; transition: opacity .3s; }
.stamina.show { opacity: 1; }
.stamina i { display: block; height: 100%; background: var(--o); }
.banner { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--y); border: 3px solid var(--y); padding: 8px 14px; font-family: 'PS2P'; font-size: 11px; display: none; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.banner.show { display: block; }
.banner .ln { display: inline-block; padding: 2px 6px; margin-right: 8px; color: #fff; border: 2px solid #fff; }
.prompt { position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%); background: var(--y); border: 4px solid var(--ink); box-shadow: var(--sh); padding: 10px 14px; font-size: 24px; display: none; white-space: nowrap; }
.prompt.show { display: block; animation: bob 1s infinite; }
.prompt kbd { font-family: 'PS2P'; font-size: 11px; background: var(--ink); color: var(--y); padding: 4px 6px; margin-right: 6px; }
@keyframes bob { 50% { transform: translate(-50%, -3px); } }
#toasts { position: absolute; left: 50%; top: 112px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--c); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 6px 12px; font-size: 22px; animation: tin .25s; max-width: 86vw; text-align: center; }
.toast.warn { background: var(--m); color: #fff; } .toast.good { background: var(--gl); } .toast.info { background: var(--y); }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }
.speech { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); background: #fff; border: 4px solid var(--ink); padding: 8px 14px; font-size: 24px; display: none; }
.speech.show { display: block; }
.speech::after { content: ''; position: absolute; left: 30px; bottom: -14px; border: 7px solid transparent; border-top-color: var(--ink); }
.ff { position: absolute; right: 14px; top: 64px; background: var(--o); color: #fff; font-family: 'PS2P'; font-size: 11px; padding: 6px 8px; border: 3px solid var(--ink); display: none; }
.ff.show { display: block; }
.keys { position: absolute; left: 14px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 19px; color: var(--ink); background: rgba(255,244,214,.85); border: 3px solid var(--ink); padding: 4px 8px; max-width: 70vw; }
.keys b { font-family: 'PS2P'; font-size: 9px; background: var(--ink); color: var(--y); padding: 2px 4px; }
.late { position: absolute; right: 14px; top: 100px; font-family: 'PS2P'; font-size: 14px; background: var(--m); color: var(--y); border: 3px solid var(--ink); padding: 6px 8px; display: none; animation: blink 1s steps(2) infinite; }
.late.show { display: block; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- watch ---------- */
#watch { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(200px); transition: transform .18s; z-index: 6; pointer-events: none; }
#watch.show { transform: translateX(-50%) translateY(0); }
.watch-face { width: 190px; height: 150px; background: var(--ink); border-radius: 26px; border: 8px solid var(--m); box-shadow: 0 0 0 5px var(--ink), 8px 8px 0 5px rgba(0,0,0,.4); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.watch-time { font-family: 'PS2P'; font-size: 30px; color: var(--y); }
.watch-sub { color: var(--gl); font-size: 20px; margin-top: 8px; }

/* ---------- phone ---------- */
#phone { position: fixed; right: 4vw; bottom: -720px; z-index: 8; transition: bottom .2s; }
#phone.show { bottom: 18px; }
.phone-body { width: 320px; height: min(600px, 86vh); background: var(--ink); border-radius: 28px; padding: 12px; box-shadow: 8px 8px 0 rgba(0,0,0,.35); display: flex; flex-direction: column; border: 4px solid #333; }
.phone-status { display: flex; justify-content: space-between; color: #fff; font-family: 'PS2P'; font-size: 9px; padding: 4px 10px 8px; }
.phone-screen { flex: 1; background: var(--c); border-radius: 10px; overflow: auto; font-size: 20px; position: relative; }
.phone-nav { display: flex; justify-content: center; gap: 40px; padding-top: 8px; }
.phone-nav button { background: none; border: none; color: #fff; font-size: 16px; }
.ph-home { padding: 14px; background: linear-gradient(var(--y), var(--yd)); min-height: 100%; }
.ph-clock { font-family: 'PS2P'; font-size: 30px; text-align: center; margin: 10px 0 2px; }
.ph-date { text-align: center; font-size: 19px; margin-bottom: 4px; }
.ph-count { text-align: center; background: var(--ink); color: var(--y); padding: 4px; font-size: 20px; margin: 6px 0 12px; border: 2px solid var(--ink); }
.ph-count.late { background: var(--m); color: #fff; }
.apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.app { background: #fff; border: 3px solid var(--ink); padding: 8px 2px; text-align: center; font-family: 'VT323'; font-size: 17px; box-shadow: 3px 3px 0 var(--ink); }
.app i { font-style: normal; display: block; font-size: 26px; }
.ph-app { padding: 10px; }
.ph-app h4 { margin: 0 0 8px; font-family: 'PS2P'; font-weight: normal; font-size: 11px; background: var(--g); color: var(--y); padding: 6px; border: 3px solid var(--ink); }
.ph-app select { font-family: 'VT323'; font-size: 19px; width: 100%; margin-bottom: 6px; border: 3px solid var(--ink); background: #fff; }
.ph-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.ph-tabs button { flex: 1; font-size: 8px; padding: 6px 2px; border: 3px solid var(--ink); background: #fff; }
.ph-tabs button.on { background: var(--y); }
table.tt { width: 100%; border-collapse: collapse; font-size: 18px; }
table.tt th { font-family: 'PS2P'; font-size: 7px; background: var(--ink); color: var(--y); padding: 4px 2px; text-align: left; }
table.tt td { padding: 2px 3px; border-bottom: 1px solid #0002; }
table.tt tr.past { opacity: .35; } table.tt tr.next { background: var(--y); font-weight: bold; }
table.tt .tc { color: #fff; background: var(--o); padding: 0 3px; font-size: 14px; }
table.tt .tb { color: #fff; background: var(--b); padding: 0 3px; font-size: 14px; }
.gps li { list-style: none; padding: 3px 4px 3px 22px; position: relative; border-left: 4px solid var(--g); margin-left: 8px; }
.gps { padding: 0; margin: 0; }
.gps li::before { content: ''; position: absolute; left: -9px; top: 9px; width: 10px; height: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
.gps li.here { background: var(--y); font-weight: bold; }
.gps li.here::before { background: var(--m); }
.gps li.tgt { color: var(--m); }
.gps li.done { opacity: .45; }
.ph-dead { height: 100%; background: #111; color: #555; display: grid; place-items: center; text-align: center; font-family: 'PS2P'; font-size: 11px; line-height: 2; }
.eta { display: flex; justify-content: space-between; padding: 5px 6px; border-bottom: 2px dashed #0002; }
.eta b { font-family: 'PS2P'; font-size: 10px; color: #fff; padding: 3px 5px; border: 2px solid var(--ink); }

/* ---------- transition / result ---------- */
#trans { background: var(--m); align-items: center; justify-content: center; z-index: 25; opacity: 0; transition: opacity .25s; }
#trans.show { opacity: 1; }
.trans-card { text-align: center; color: #fff; }
#transIcon { font-size: 54px; }
#transText { font-family: 'PS2P'; font-size: 16px; color: var(--y); text-shadow: 3px 3px 0 var(--ink); margin: 14px 0 8px; line-height: 1.5; padding: 0 20px; }
#transSub { font-size: 24px; }
#result { align-items: center; justify-content: center; background: rgba(27,27,27,.5); z-index: 30; }
.result-head { font-family: 'PS2P'; font-size: 26px; color: var(--y); text-shadow: 4px 4px 0 var(--ink); background: var(--g); border: 4px solid var(--ink); padding: 14px; text-align: center; }
.result-head.bad { background: var(--m); }
.stars { text-align: center; font-size: 54px; color: var(--yd); -webkit-text-stroke: 2px var(--ink); margin: 6px 0; letter-spacing: 8px; }
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.res-grid div { background: #fff; border: 3px solid var(--ink); padding: 6px 8px; }
.res-grid small { display: block; font-family: 'PS2P'; font-size: 7px; }
.res-grid b { font-family: 'PS2P'; font-size: 12px; font-weight: normal; }
#resText { font-size: 22px; }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 7; display: none; }
body.touch #touch.show { display: block; }
#stick { position: absolute; left: 24px; bottom: 30px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,244,214,.45); border: 4px solid var(--ink); pointer-events: auto; }
#knob { position: absolute; left: 37px; top: 37px; width: 48px; height: 48px; border-radius: 50%; background: var(--y); border: 4px solid var(--ink); }
.tbtns { position: absolute; right: 14px; bottom: 20px; display: grid; grid-template-columns: repeat(4, 62px); gap: 8px; pointer-events: auto; }
.tb { height: 54px; border: 3px solid var(--ink); background: var(--c); font-size: 8px; box-shadow: 3px 3px 0 var(--ink); }
.tb small { font-size: 6px; } .tb-y { background: var(--y); } .tb-m { background: var(--m); color: #fff; } .tb-g { background: var(--g); color: var(--y); }
body.touch .keys { display: none; }
body.touch .prompt { bottom: 200px; }

@media (max-width: 760px) {
  .menu-tiles, .menu-date, .tag-cream { display: none; }
  .menu-buttons { width: 100%; }
  .brief-meta { grid-template-columns: repeat(2, 1fr); }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  .phone-body { width: 92vw; }
  #phone { right: 4vw; }
  .hud-obj { font-size: 18px; }
}

@media (max-width: 560px) {
  .hud-tl { top: 60px; max-width: 92vw; }
  .hud-obj { font-size: 17px; }
  .banner { top: 108px; font-size: 9px; }
  #toasts { top: 150px; width: 92vw; }
  .toast { font-size: 18px; }
  #stick { width: 112px; height: 112px; left: 16px; bottom: 24px; }
  #knob { left: 28px; top: 28px; }
  .tbtns { grid-template-columns: repeat(2, 58px); right: 10px; bottom: 16px; gap: 7px; }
  .tb { height: 46px; }
  body.touch .prompt { bottom: 250px; font-size: 19px; white-space: normal; max-width: 90vw; text-align: center; }
  .speech { font-size: 19px; max-width: 86vw; }
  .ff { top: 108px; }
  .late { top: 140px; }
  #phone.show { bottom: 8px; }
  .phone-body { height: 78vh; }
  .title span + span { margin-left: 12px; }
  .ribbon { font-size: 18px; }
  #menu { padding: 12px; }
  .tag-ink, .tag.small { font-size: 8px; }
}
