/* 画面とキーボードが一度に見えるよう、低い画面では幅を抑える（16:10 の画面＋スタンドとキーボード分） */
.stage { --stage-w: min(900px, max(480px, (100vh - 210px) * 1.6)); }
@supports (height: 100svh) { .stage { --stage-w: min(900px, max(480px, (100svh - 210px) * 1.6)); } }
.monitor { max-width: var(--stage-w); margin: 0 auto; }
.screen { position: relative; aspect-ratio: 16 / 10; background: #1b1b1b; border: 12px solid #1b1b1b; border-radius: 14px 14px 4px 4px; overflow: hidden; user-select: none; color-scheme: light; transition: filter .25s; }
/* 電源ボタンを押している間は画面が暗くなっていき、離すと戻る */
.screen.hold { filter: brightness(.45); transition: filter 2.5s linear; }
.screen.off { filter: brightness(0); transition: filter .15s; }
.screen :focus-visible { outline-color: #c03a22; }
/* 暗い配色では、モニターの黒い枠が背景に溶けるため、細い輪郭を足す */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .screen { box-shadow: 0 0 0 1px rgba(255,255,255,.14); } }
:root[data-theme="dark"] .screen { box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.stand { width: 22%; height: 22px; margin: 0 auto; background: linear-gradient(#2a2a2a, #1b1b1b); clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%); }
/* ブラウザ */
.browser { position: absolute; inset: 0; background: #fff; color: #222; display: flex; flex-direction: column; font-family: var(--font-body); }
.tabs { background: #dfe1e5; display: flex; align-items: flex-end; padding: 6px 8px 0; gap: 4px; flex: none; }
.tab { background: #fff; border-radius: 8px 8px 0 0; padding: 6px 10px; font-size: .76rem; display: flex; align-items: center; gap: 10px; max-width: 220px; min-width: 0; white-space: nowrap; }
.tab #tabTitle { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tab .x { appearance: none; position: relative; flex: none; border: 0; background: transparent; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: .8rem; line-height: 18px; padding: 0; color: #555; }
@media (hover: hover) { .tab .x:hover { background: #ddd; } }
.tab .x.nudge { animation: nudge 1s ease infinite; }
@keyframes nudge { 50% { background: #d4442c; color: #fff; } }
.addr { background: #fff; padding: 6px 10px; border-bottom: 1px solid #ddd; flex: none; }
.addr span { display: block; background: #f1f3f4; border-radius: 99px; padding: 3px 14px; font-size: .75rem; color: #555; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { flex: 1; overflow: hidden; position: relative; }
.news { padding: 18px 22px; }
.news h4 { margin: 0 0 12px; font-family: var(--font-head); }
.news button { appearance: none; display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #eee; border-radius: 0; padding: 9px 0; font: inherit; font-size: .82rem; color: #1a4ea8; cursor: pointer; }
@media (hover: hover) { .news button:hover { text-decoration: underline; } }
/* 偽警告（全画面） */
.scam { position: absolute; inset: 0; background: #0a3a8c; color: #fff; z-index: 5; display: none; font-family: "Segoe UI", var(--font-body); overflow: hidden; }
.scam.on { display: block; }
.scam.full { z-index: 10; }
.scam:focus, .call:focus, .done:focus { outline: none; }
.scam :focus-visible, .call :focus-visible { outline-color: #fff; }
.scam .dlg :focus-visible { outline-color: #1b1b1b; }
.scam .flash { position: absolute; inset: 0; border: 6px solid #e33; animation: fl .5s steps(2) infinite; pointer-events: none; }
@keyframes fl { 50% { border-color: transparent; } }
.scam .head { background: #fff; color: #0a3a8c; font-weight: 700; padding: 6px 12px; font-size: .78rem; }
.scam .body { padding: 14px 18px; font-size: clamp(.78rem, 1.4vw, .82rem); line-height: 1.7; }
.scam .big { font-size: clamp(1.05rem, 2.4vw, 1.4rem); font-weight: 800; line-height: 1.5; }
.scam .tel { appearance: none; display: inline-block; border: 0; background: #fff; color: #c00; font-family: inherit; font-weight: 800; font-size: clamp(1.2rem, 3vw, 1.7rem); line-height: inherit; padding: 4px 14px; margin: 8px 0; cursor: pointer; border-radius: 4px; }
.scam .scan { height: 8px; background: rgba(255,255,255,.2); margin: 8px 0; }
.scam .scan span { display: block; height: 100%; background: #f5c400; width: 0; transition: width .3s; }
.scam .fakebtns { display: flex; flex-wrap: wrap; gap: 8px; }
.scam .fakebtns button { background: #fff; color: #0a3a8c; border: 0; padding: 4px 14px; cursor: pointer; font: inherit; font-size: .75rem; }
/* 全画面を解除した後は、警告がブラウザの中に収まらないことがあるため、中を送れるようにする */
.scam:not(.full) { overflow-y: auto; overscroll-behavior: contain; }
/* 偽の窓は、画面の幅に応じて左右の位置をずらし、はみ出さないようにする（--dx は 0〜1） */
.dlg { --dw: min(70%, 320px); position: absolute; width: var(--dw); left: calc((100% - var(--dw)) * var(--dx, .2)); background: #f3f3f3; color: #222; border: 1px solid #888; box-shadow: 0 8px 24px rgba(0,0,0,.45); font-size: .78rem; z-index: 6; }
.dlg .t { background: #fff; padding: 6px 10px; font-weight: 700; border-bottom: 1px solid #ccc; }
.dlg .b { padding: 10px; line-height: 1.6; }
.dlg .f { padding: 0 10px 10px; display: flex; justify-content: flex-end; gap: 8px; }
.dlg .f button { padding: 3px 12px; cursor: pointer; font: inherit; font-size: .76rem; }
/* タスクマネージャー */
.taskmgr { position: absolute; top: 12%; left: 18%; right: 18%; max-height: 80%; overflow-y: auto; overscroll-behavior: contain; background: #fff; color: #222; border: 1px solid #888; z-index: 35; display: none; font-size: .8rem; line-height: 1.6; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.taskmgr.on { display: block; }
.taskmgr .t { background: #f0f0f0; padding: 6px 12px; font-weight: 700; }
.taskmgr .row { appearance: none; display: flex; align-items: center; width: 100%; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 0; border-bottom: 1px solid #eee; border-radius: 0; background: #fff; color: #222; font: inherit; text-align: left; cursor: pointer; }
.taskmgr .row.sel { background: #cce4ff; }
.taskmgr .row:focus-visible { outline-offset: -3px; }
.taskmgr .f { padding: 10px 12px; text-align: right; }
.taskmgr .f button { font: inherit; padding: 4px 14px; cursor: pointer; }
@media (max-width: 700px) { .taskmgr { top: 6%; left: 5%; right: 5%; max-height: 88%; } }
/* 通話 */
.call { position: absolute; inset: 0; background: #22282f; color: #eee; z-index: 30; display: none; padding: 20px; font-size: .86rem; overflow: auto; overscroll-behavior: contain; }
.call.on { display: block; }
.call .m { background: rgba(255,255,255,.08); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; max-width: 86%; line-height: 1.7; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
/* 結果 */
.done { position: absolute; inset: 0; background: #faf3d6; color: #1b1b1b; z-index: 40; display: none; flex-direction: column; align-items: center; text-align: center; padding: 20px; overflow-y: auto; }
/* 中央に置き、収まらないときは上から表示してスクロールできるようにする */
.done::before, .done::after { content: ""; flex: 1 0 0; }
.done.on { display: flex; }
.done .tm { font-family: var(--font-head); font-weight: 700; font-size: clamp(2.4rem, 8vw, 4rem); }
/* 結果の画面は常に明るい背景なので、文字とボタンの色も固定する */
.done .muted { color: #5f5f5f; }
.done .btn.line { color: #1b1b1b; border-color: #1b1b1b; background: transparent; }
.done .btn.line:hover { background: #1b1b1b; color: #faf3d6; }
/* 見つけた脱出の方法（CYH.ends の小さな札。まだの方法は伏せておき、もう一度遊ぶきっかけにする） */
.done .ends-card { max-width: 400px; margin: 4px 0 0; }
.done .ends-card .ec-btns { justify-content: center; }
@media (prefers-reduced-motion: reduce) {
  .scam .flash { animation: none; }
  .tab .x.nudge { animation: none; background: #c03a22; color: #fff; }
  .call .m { animation: none; }
  .kbd.wake button { animation: none; }
  .kbd button.cue { animation: none; box-shadow: 0 0 0 3px var(--accent-soft); }
}
/* キーボード */
.kbd { display: flex; justify-content: space-between; gap: 6px; max-width: var(--stage-w); margin: 18px auto 0; flex-wrap: wrap; }
.kbd button { appearance: none; border: 1px solid var(--line); border-bottom-width: 4px; background: var(--surface); color: var(--ink); border-radius: 8px; padding: 10px 16px; min-height: 48px; font-family: var(--mono); font-size: .85rem; cursor: pointer; min-width: 64px; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.kbd button:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
/* 偽の警告が出るまでは、キーは押しても何も起きないため、控えめに見せる。警告が出たら目を覚ます */
.kbd button:disabled { opacity: .45; cursor: default; }
.kbd.wake button { animation: wake .5s cubic-bezier(.3,1.6,.5,1) both; }
.kbd.wake .grp:last-child button { animation-delay: .08s; }
@keyframes wake { from { transform: translateY(4px) scale(.94); } }
/* しばらく動けないときの手がかり：Esc をゆっくり点滅させる */
.kbd button.cue { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); animation: cue 1.3s ease infinite; }
@keyframes cue { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }
.kbd .grp { display: flex; gap: 6px; }
/* 長押しの途中で、文字の選択やスクロールに切り替わらないようにする */
.power { position: relative; }
.power.down { transform: translateY(2px); border-bottom-width: 2px; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
/* 電源ボタン：押すと、押し続けている間の様子を画面に見せる */
.powbar { position: absolute; left: 50%; bottom: 14%; z-index: 30; width: min(80%, 320px); transform: translateX(-50%); display: none; gap: 8px; padding: 12px 14px; border-radius: 12px; background: rgba(0,0,0,.82); color: #fff; font-size: .85rem; text-align: center; }
.powbar i { display: block; height: 6px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.powbar i::before { content: ""; display: block; height: 100%; width: 0; background: #f07468; }
.screen.hold .powbar { display: grid; }
.screen.hold .powbar i::before { width: 100%; transition: width 2.5s linear; }
@media (pointer: coarse) {
  .tab { padding: 3px 4px 3px 12px; }
  .tab .x { width: 38px; height: 38px; line-height: 38px; font-size: 1rem; }
  .tab .x::before { content: ""; position: absolute; inset: -3px; }
  .news button { padding: 12px 0; }
  .scam .fakebtns button, .dlg .f button, .taskmgr .f button { min-height: 44px; min-width: 64px; }
  .scam .tel { min-height: 44px; }
  .taskmgr .row { min-height: 46px; }
  .done .btn, .call .btn { min-height: 44px; }
}

/* 縦長の画面（スマートフォンの縦持ち）：モニターの台を外し、画面を縦長にして大きく見せる。
   キーボードの段と一緒に、ヘッダーの下に収まる高さにする */
@media (orientation: portrait) and (max-width: 700px) {
  .wrap.stage-pad { padding-inline: 12px; }
  .monitor { max-width: none; }
  .screen { aspect-ratio: auto; height: clamp(340px, 100vh - 164px, 760px); height: clamp(340px, 100svh - 164px, 760px); border-width: 6px; border-radius: 14px; }
  .stand { display: none; }
  .kbd { max-width: none; margin-top: 10px; flex-wrap: nowrap; }
  .kbd button { padding: 10px 12px; }
  .news { padding: 14px 16px; }
  .news button { font-size: .9rem; }
  .dlg { --dw: 86%; }
}
/* タブレットの縦持ち：16:10 では低すぎるため、4:3 にする */
@media (orientation: portrait) and (min-width: 701px) {
  .screen { aspect-ratio: 4 / 3; }
}
/* 横持ちのスマートフォン：高さが足りないため、キーボードを画面の右に縦に並べる */
@media (orientation: landscape) and (max-height: 500px) {
  .stage { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
  .monitor { max-width: none; margin: 0; }
  .screen { aspect-ratio: auto; height: max(240px, 100vh - 100px); height: max(240px, 100svh - 100px); border-width: 6px; border-radius: 12px; }
  .stand { display: none; }
  .kbd { flex-direction: column; justify-content: center; margin: 0; max-width: none; flex-wrap: nowrap; gap: 10px; }
  .kbd .grp { flex-direction: column; align-items: stretch; gap: 10px; }
  .power { align-self: center; }
  .scam .body { padding: 10px 14px; }
  /* 電話番号が警告の下端で切れないよう、見出しを一行にし、段落の余白を詰める */
  .scam .head { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .scam .body p { margin: 0 0 6px; }
  .done { padding: 8px 12px; font-size: .84rem; line-height: 1.55; }
  .done .tm { font-size: 1.8rem; line-height: 1.25; }
  .done p { margin: 4px 0; }
  .done .ends-card { padding: 8px 10px; }
}

/* 元は support-scam.js が style 属性で付けていた指定（CSP の style-src に 'unsafe-inline' を付けないため、ここへ移した） */
.done .how { max-width: 28em; }
.call .warn { margin-top: 16px; color: #f07468; font-weight: 700; }
.call #hang { background: #eee; color: #111; border-color: #eee; }
