/* The in-game phone (R4 gate 11, chapter H, specs/phone-shell.json). */
#phone.phone-overlay { display: grid; place-items: center; background: rgba(15, 26, 32, 0.55); gap: 10px; align-content: center; }
#phone.phone-overlay[hidden] { display: none; }
.phone-device {
  position: relative; width: min(88vw, 390px); height: min(calc(100dvh - 86px), 780px); min-height: 420px;
  background: #15191d; border-radius: 46px; padding: 14px 12px 22px; box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45), inset 0 0 0 2px #3a4046;
  display: grid; grid-template-rows: 1fr auto; box-sizing: border-box;
}
.phone-island { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 104px; height: 26px; border-radius: 14px; background: #050607; z-index: 3; }
.phone-screen {
  position: relative; border-radius: 34px; overflow: hidden; background: linear-gradient(180deg, #F6F1E7 0%, #EAF2F3 100%);
  display: grid; grid-template-rows: 44px 1fr; color: var(--ink); font-family: "Cairo", sans-serif; min-height: 0;
}
.phone-status { display: flex; align-items: center; justify-content: space-between; padding: 12px 26px 0; font-weight: 700; font-size: 0.9rem; }
.ps-icons { display: flex; gap: 6px; align-items: center; }
.ps-signal { width: 16px; height: 10px; background: linear-gradient(90deg, #26313b 25%, transparent 25% 37%, #26313b 37% 62%, transparent 62% 74%, #26313b 74%); clip-path: polygon(0 100%, 100% 0, 100% 100%); }
.ps-battery { width: 22px; height: 10px; border: 2px solid #26313b; border-radius: 3px; position: relative; box-sizing: border-box; }
.ps-battery::after { content: ''; position: absolute; inset: 1px 4px 1px 1px; background: #2E9E57; border-radius: 1px; }
.phone-home { overflow: auto; padding: 8px 14px 16px; }
.phone-home[hidden], .phone-app[hidden] { display: none; }
.phone-greeting { margin: 4px 6px 8px; font-size: 1.15rem; }
.phone-notes { display: grid; gap: 6px; margin-bottom: 10px; }
.phone-notes[hidden] { display: none; }
.phone-note { text-align: start; background: rgba(255, 255, 255, 0.85); border: 0; border-radius: 14px; padding: 8px 12px; font: inherit; color: inherit; min-height: 44px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.phone-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; }
.app-tile { position: relative; display: grid; justify-items: center; gap: 4px; background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; min-height: 44px; cursor: pointer; }
.app-icon { width: 56px; height: 56px; display: block; }
.app-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.18)); }
.app-label { font-size: 0.74rem; font-weight: 600; line-height: 1.2; text-align: center; }
.app-badge { position: absolute; top: 0; inset-inline-start: calc(50% + 14px); min-width: 20px; height: 20px; border-radius: 10px; background: #E2563F; color: #fff; font-size: 0.72rem; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }
.app-badge[hidden] { display: none; }
.phone-app { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.app-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; padding: 4px 10px; border-bottom: 1px solid rgba(0,0,0,0.08); }
.app-bar h2 { margin: 0; font-size: 1.05rem; text-align: center; }
.app-back, .app-home { min-height: 44px; min-width: 44px; border: 0; border-radius: 12px; background: rgba(23, 42, 50, 0.07); font: inherit; font-weight: 600; color: inherit; padding: 0 10px; }
.app-body { overflow: auto; padding: 10px 14px 18px; min-height: 0; overscroll-behavior: contain; }
.phone-home-ind { justify-self: center; margin-top: 8px; width: 132px; height: 8px; border-radius: 6px; background: #8b939b; border: 0; padding: 0; position: relative; }
.phone-home-ind::before { content: ''; position: absolute; inset: -18px -8px; }
.phone-close { min-height: 44px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; box-shadow: var(--shadow); }
.phone-toast { position: absolute; left: 12px; right: 12px; bottom: 14px; background: rgba(23, 42, 50, 0.92); color: #fff; border-radius: 14px; padding: 10px 14px; font-size: 0.9rem; z-index: 5; }
.phone-toast[hidden] { display: none; }

/* shared app parts */
.app-body button, .app-body .button-like, .app-body select, .app-body input[type="search"], .app-body input[type="text"] { min-height: 44px; font: inherit; border-radius: 12px; }
.app-body button, .app-body .button-like { min-width: 44px; border: 1px solid rgba(23,42,50,0.15); background: #fff; color: var(--ink); padding: 0 12px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-grid; place-items: center; }
.app-body button.primary, .app-body .button-like.primary { background: #16605A; color: #fff; border-color: #16605A; }
.app-body button.danger { background: #C53B2C; color: #fff; border-color: #C53B2C; }
.app-body button.danger.ghost { background: #fff; color: #C53B2C; }
.app-body button.ghost { background: transparent; }
.app-body button:disabled { opacity: 0.45; }
.app-body .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.app-body .row > input[type="search"], .app-body .row > input[type="text"], .app-body .row > select { flex: 1 1 140px; border: 1px solid rgba(23,42,50,0.2); padding: 0 10px; background: #fff; }
.app-h { margin: 4px 0 8px; font-size: 1.05rem; }
.app-sub { margin: 14px 0 6px; font-size: 0.95rem; color: #2F5B5E; }
.muted { color: #5b6b72; font-size: 0.88rem; }
.empty { padding: 12px; background: rgba(255,255,255,0.7); border-radius: 12px; }
.app-error { color: #A8321F; background: #FFF1EE; padding: 10px; border-radius: 12px; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.row-btn { width: 100%; display: grid !important; grid-template-columns: 1fr; justify-items: start; text-align: start; gap: 2px; padding: 8px 12px !important; }
.row-btn span { font-weight: 400; font-size: 0.85rem; color: #5b6b72; }
.seg.on, .tabs .seg.on, .switch.on { background: #16605A !important; color: #fff !important; }
.segs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.set-row input[type="range"] { width: 48%; min-height: 44px; }
.sens-preview { height: 70px; border-radius: 12px; background: #e3eef0; display: grid; place-items: center; touch-action: none; margin: 6px 0; }
.sens-cube { width: 34px; height: 34px; background: #16605A; border-radius: 6px; }
.danger-zone { margin-top: 26px; padding-top: 10px; border-top: 2px dashed rgba(197, 59, 44, 0.35); }

/* tasks */
.task-card { background: #fff; border-radius: 16px; padding: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.task-card h4 { margin: 2px 0 4px; }
.task-now { margin: 0; color: #16605A; font-weight: 700; font-size: 0.85rem; }
.task-hint { background: #F2F8F7; border-radius: 10px; padding: 8px; }
.task-list li { margin: 4px 0; }

/* calls */
.contact-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.contact-card, .call-screen { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 10px; }
.contact-avatar { width: 64px; height: 64px; border-radius: 50%; background: #16605A; color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; }
.contact-avatar.big { width: 96px; height: 96px; font-size: 2.3rem; }
.call-transcript { background: #fff; border-radius: 14px; padding: 10px; min-height: 60px; }
.phone-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.phone-list li { background: #fff; border-radius: 12px; padding: 8px; display: grid; gap: 2px; }
.phone-list li.missed .tag { color: #C53B2C; }
.phone-list .tag { font-weight: 700; font-size: 0.8rem; color: #16605A; }
.phone-msg { background: rgba(255,255,255,0.8); border-radius: 12px; padding: 8px; }

/* notes */
.my-note { width: 100%; box-sizing: border-box; font: inherit; border-radius: 12px; border: 1px solid rgba(23,42,50,0.2); padding: 8px; resize: vertical; }
.clue-paper { width: 70%; max-width: 220px; display: block; margin: 6px auto; border-radius: 6px; box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.clue-text { font-size: 1.3rem; font-weight: 700; text-align: center; }
.row-btn.clue b { font-size: 1.1rem; }

/* map */
.map-canvas { width: 100%; aspect-ratio: 1; border-radius: 14px; background: #F4F1EA; touch-action: manipulation; }
.map-label { text-align: center; font-weight: 700; margin: 4px 0; }
.map-key { font-size: 0.8rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.map-key span { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.k-me { background: #1E6FD9; } .k-door { background: #B9875A; } .k-task { background: #E2563F; }

/* bag */
.bag-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.bag-cell { display: grid !important; gap: 6px; padding: 10px !important; min-height: 110px; }
.bag-item { width: 54px; height: 54px; border-radius: 12px; display: block; background: #e8e2d6; }
.bag-item.big { width: 96px; height: 96px; margin: 8px auto; }
.bag-item.i-golden-key { background: radial-gradient(circle at 35% 40%, #F6D365 0 20%, transparent 21%), linear-gradient(90deg, transparent 40%, #D9A62B 40% 90%, transparent 90%) 0 55% / 100% 18% no-repeat, #FFF6DC; }
.bag-item.i-maze-key { background: radial-gradient(circle at 35% 40%, #8FB8E8 0 20%, transparent 21%), linear-gradient(90deg, transparent 40%, #3A7BD5 40% 90%, transparent 90%) 0 55% / 100% 18% no-repeat, #EAF2FC; }
.bag-item.i-coins { background: radial-gradient(circle at 40% 45%, #F2C230 0 26%, #C99A18 27% 31%, transparent 32%), #FFF8E1; }

/* calculator */
.calc-display { display: block; text-align: right; font-size: 2rem; font-weight: 700; padding: 10px 12px; background: #fff; border-radius: 14px; min-height: 56px; overflow-wrap: anywhere; }
.calc-display.err { font-size: 1rem; color: #C53B2C; }
.calc-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.calc-key { min-height: 56px !important; font-size: 1.3rem !important; }
.calc-key.op { background: #FDEBD9 !important; }
.calc-key.wide { grid-column: span 3; }

/* clock */
.clock-face { display: block; margin: 0 auto; width: 180px; height: 180px; }
.clock-digital, .timer-display { text-align: center; font-size: 1.8rem; font-weight: 700; margin: 4px 0; }
.timer-state { text-align: center; color: #16605A; font-weight: 600; }

/* chats */
.chat-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.chat-row { grid-template-columns: auto 1fr auto !important; grid-template-areas: 'a n u' 'a l u'; align-items: center; column-gap: 10px !important; }
.chat-row .avatar { grid-area: a; }
.chat-row b { grid-area: n; }
.chat-row .chat-last { grid-area: l; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chat-unread { grid-area: u; background: #2E9E57; color: #fff !important; border-radius: 12px; min-width: 22px; height: 22px; display: grid; place-items: center; font-weight: 700; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #3A7BD5; color: #fff; display: inline-grid; place-items: center; font-weight: 700; flex: none; }
.chat-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; font-size: 1rem; }
.chat-view { display: grid; gap: 6px; max-height: 46vh; overflow: auto; padding: 4px; }
.bubble-line { max-width: 82%; padding: 8px 12px; border-radius: 16px; line-height: 1.5; }
.bubble-line.them { background: #fff; justify-self: start; border-end-start-radius: 4px; }
.bubble-line.me { background: #D7F2E3; justify-self: end; border-end-end-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border-radius: 999px !important; background: #EEF5F4 !important; }
.chat-compose input { flex: 1 1 150px; }
.file-view { white-space: pre-wrap; background: #fff; padding: 10px; border-radius: 12px; font: inherit; }

/* instagram, snapchat, youtube */
.tabs .seg { flex: 1 1 0; }
.feed { display: grid; gap: 14px; }
.post { background: #fff; border-radius: 16px; overflow: hidden; padding-bottom: 8px; }
.post-head { display: flex; align-items: center; gap: 8px; padding: 8px; }
.post-img-btn { padding: 0 !important; border: 0 !important; width: 100%; display: block !important; border-radius: 0 !important; }
.post-img, .story-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #dde6e8; }
.missing { display: grid; place-items: center; color: #7a6a5a; background: #F2EBDD; aspect-ratio: 4 / 3; border-radius: 8px; }
.post h4, .post p { margin: 4px 10px; }
.post-acts { padding: 0 8px; }
.like.on { color: #C0306B !important; }
.story-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.story-dot { flex: none; width: 92px; min-height: 92px !important; border-radius: 50% !important; border: 3px solid #C05A8A !important; font-size: 0.72rem !important; padding: 6px !important; }
.story-dot.seen { border-color: #b7bec4 !important; }
.story-bar { display: flex; gap: 3px; margin-bottom: 6px; }
.story-bar i { flex: 1; height: 3px; background: #c9d0d4; border-radius: 2px; }
.story-bar i.on { background: #C05A8A; }
.story-reply { background: #F7EEF4; border-radius: 12px; padding: 8px; }
.yt-video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; }
.yt-list { display: grid; gap: 10px; }
.yt-item { display: grid !important; grid-template-columns: 120px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: start; justify-items: start; padding: 6px !important; }
.yt-thumb { grid-row: span 2; width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; }
.yt-item span { font-weight: 400; font-size: 0.82rem; color: #5b6b72; }

/* camera and gallery */
.cam-preview { width: 100%; aspect-ratio: 3 / 2; background: #222; border-radius: 14px; display: block; }
.cam-state { font-weight: 700; text-align: center; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-cell { padding: 0 !important; aspect-ratio: 1; overflow: hidden; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-full { width: 100%; height: auto; max-height: 50vh; object-fit: contain; display: block; border-radius: 10px; background: #111; }

/* arshidny */
.ar-head { display: grid; gap: 8px; }
.ar-profile { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: #fff; }
.qr-big { width: 80%; max-width: 280px; display: block; margin: 8px auto; image-rendering: pixelated; background: #fff; }
.rec-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.rec { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.rec dt { font-weight: 700; color: #2F5B5E; }
.rec dd { margin: 0; }

/* touch button size and handedness (phone settings) */
body.touch-small .touch .joy { transform: scale(0.85); transform-origin: bottom left; }
body.touch-large .touch .joy { transform: scale(1.18); transform-origin: bottom left; }
body.touch-small .touch .act { transform: scale(0.85); }
body.touch-large .touch .act { transform: scale(1.18); }
body.left-handed .touch .joy { left: auto; right: 22px; transform-origin: bottom right; }
body.left-handed .touch .act { right: auto; left: 22px; }

@media (orientation: landscape) and (max-height: 520px) {
  .phone-device { width: min(92vw, 760px); height: calc(100dvh - 70px); min-height: 0; border-radius: 30px; padding: 10px; }
  .phone-island { display: none; }
  .phone-grid { grid-template-columns: repeat(8, 1fr); }
  .phone-screen { border-radius: 22px; grid-template-rows: 32px 1fr; }
  .phone-status { padding-top: 6px; }
}

.hud-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-inline-start: 6px; border-radius: 10px; background: #E2563F; color: #fff; font-size: 0.75rem; font-weight: 700; padding: 0 5px; }
.hud-badge[hidden] { display: none; }
.my-post { margin: 0; background: #fff; border-radius: 10px; overflow: hidden; }
.my-post img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.my-post figcaption { font-size: 0.72rem; padding: 2px 4px; }

/* The round map in place of the mission banner (R4 gate 13). The banner stays in the page for the camera's HUD
   stamp, but is not shown. */
#objective { display: none !important; }
.minimap { position: absolute; top: max(12px, env(safe-area-inset-top)); inset-inline-start: max(12px, env(safe-area-inset-right)); width: 148px; padding: 0; border: 0; background: none; display: grid; justify-items: center; gap: 4px; cursor: pointer; z-index: 4; }
.minimap-canvas { width: 148px; height: 148px; border-radius: 50%; box-shadow: 0 6px 18px rgba(0,0,0,0.28); background: #E9E4DA; display: block; }
.minimap-tag { max-width: 170px; background: rgba(23, 42, 50, 0.82); color: #fff; font: 600 0.78rem/1.4 Cairo, sans-serif; padding: 2px 10px; border-radius: 10px; text-align: center; }
@media (max-width: 480px) { .minimap { width: 118px; } .minimap-canvas { width: 118px; height: 118px; } .minimap-tag { font-size: 0.7rem; } }

/* Recenter the camera behind the player (R4 gate 14). With a mouse it sits under the round map; on touch it sits
   above the action button, under the right thumb (mirrored for left-handed play). Hidden in the car. */
.recenter-btn { position: absolute; top: 252px; right: 24px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,253,248,0.94); color: var(--ink); font-size: 1.35rem; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,0.18); z-index: 3; }
body.touch-mode .recenter-btn { top: auto; bottom: 156px; right: 48px; }
body.touch-mode.left-handed .recenter-btn { right: auto; left: 48px; }
body.in-car .recenter-btn { display: none; }
/* On touch the action prompt sits above the thumb controls, not across the joystick ring (R4 gate 14). */
.prompt { pointer-events: none; }
body.touch-mode .prompt { bottom: 214px; max-width: 64vw; white-space: normal; text-align: center; }
/* Landscape phones: a smaller round map, the recenter button beside the action button, the prompt low in the middle
   between the two thumbs. */
@media (orientation: landscape) and (max-height: 500px) {
  .minimap { width: 104px; } .minimap-canvas { width: 104px; height: 104px; } .minimap-tag { font-size: 0.68rem; }
  body.touch-mode .recenter-btn { bottom: 66px; right: 136px; }
  body.touch-mode.left-handed .recenter-btn { right: auto; left: 136px; }
  body.touch-mode .prompt { bottom: 24px; }
}
