:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0d12; }
body { font-family: system-ui, "Noto Sans JP", sans-serif; color: #dfe8f2; }

#view, #hud {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}
#view { z-index: 0; }
#hud { z-index: 1; pointer-events: none; }

#fullscreen-btn {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 5; width: 32px; height: 32px; padding: 0; border-radius: 6px;
  background: rgba(10,16,24,0.6); border: 1px solid rgba(210,225,240,0.3);
  color: #cfe0f0; font-size: 15px; line-height: 30px; text-align: center;
  cursor: pointer; touch-action: manipulation;
}

/*
 * ホームへ戻る導線(CONTENT_PRINCIPLES.md §1)。
 * #setup の内側に置いてあるので、飛行中は #setup ごと消える。
 */
#home-link {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  color: #cfe0f0; text-decoration: none; font-size: 13px;
  background: rgba(10,16,24,0.6); border: 1px solid rgba(210,225,240,0.3);
  padding: 5px 10px; border-radius: 6px;
}
#home-link:hover { color: #fff; border-color: rgba(210,225,240,0.6); }

/*
 * 操作の凡例と描画の状態。**画面下は計器の針が並ぶので置かない**
 * (2026-08-18 ユーザー指摘。下中央に置いていて針と重なっていた)。
 * 上端の中央に移し、課題の進捗(#progress)とは縦に並べる。
 */
#panel {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 2; text-align: center; font-size: 12px; color: #93a6ba;
  background: rgba(10,16,24,0.55); border-radius: 8px; padding: 5px 14px;
  max-width: min(62vw, 720px); pointer-events: none;
}
#tier-note { color: #cfe0f0; margin-bottom: 2px; }
.keys { opacity: 0.75; }

#fatal {
  position: fixed; inset: 0; z-index: 5; display: flex;
  align-items: center; justify-content: center; text-align: center;
  background: #0a0d12; color: #ffb4b4; font-size: 16px; padding: 24px;
}
#fatal[hidden] { display: none; }

@media (max-width: 700px) {
  .keys { display: none; }
}

/* ── 設定画面(フリーフライトの出発前) ───────────────────────────── */
#setup {
  position: fixed; inset: 0; z-index: 4; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(180deg, #0d1420 0%, #0a0d12 100%);
  overflow-y: auto;
}
#setup[hidden] { display: none; }
#setup .card {
  width: min(460px, 100%); background: rgba(18,24,34,0.92);
  border: 1px solid rgba(210,225,240,0.18); border-radius: 12px; padding: 22px 24px;
}
#setup h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: .06em; }
#setup .lead { margin: 0 0 14px; color: #9fb4c8; font-size: 13px; }
#setup .sky {
  font-size: 12px; color: #cfe0f0; background: rgba(74,144,217,0.12);
  border: 1px solid rgba(74,144,217,0.3); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 16px; line-height: 1.5;
}
#setup label { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
#setup label.check { gap: 8px; }
#setup select, #setup input[type="range"] {
  flex: 1; background: #10161f; color: #dfe8f2;
  border: 1px solid rgba(210,225,240,0.25); border-radius: 6px; padding: 6px 8px;
  font-size: 16px;
}
#setup .out { min-width: 62px; text-align: right; color: #9fb4c8; font-family: ui-monospace, monospace; font-size: 12px; }
#setup button {
  width: 100%; margin-top: 6px; padding: 11px; font-size: 15px; font-weight: 600;
  color: #0a0d12; background: #7fc4e8; border: none; border-radius: 8px; cursor: pointer;
}
#setup button:hover { background: #9ad4f2; }
#setup .hint { margin: 14px 0 0; font-size: 12px; color: #8ea4b8; line-height: 1.6; }

/* ── 仮想スティック(タッチ端末のみ) ─────────────────────────────── */
.stick {
  position: fixed; bottom: 150px; width: 116px; height: 116px; z-index: 3;
  border-radius: 50%; border: 1px solid rgba(210,225,240,0.28);
  background: rgba(10,16,24,0.35); touch-action: none; display: none;
}
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: rgba(210,225,240,0.35); pointer-events: none;
}
.stick span {
  position: absolute; bottom: -18px; width: 100%; text-align: center;
  font-size: 10px; color: #7e93a8;
}
#stick-left { left: 18px; }
#stick-right { right: 18px; }

@media (pointer: coarse) {
  .stick { display: block; }
  #panel .keys { display: none; }
}

/* ── モバイル用トグル操作(脚/フラップ/ブレーキ/視点)・設定への導線 ──────
   2026-09-02追加。設計書§10は「フラップ・脚・視点のトグル」をタッチ対応
   必須としているが、これまでキーボード(F/G/V)専用だった。着陸後の停止に
   実用上必須なブレーキ(B)も合わせて追加する。スティックとHUD計器盤
   (canvas下部)の間に隙間が無いため、飛行中だけ空く画面左上
   (#home-linkは#setup内にあり飛行中はhiddenごと消える)へ配置する。
   #setup[hidden] を body:has() で見て「飛行中かどうか」を判定し、
   JS側に新しいbody classを増やさず既存のDOM状態をそのまま使う。 */
#config-toggles, #flight-menu-btn { display: none; position: fixed; z-index: 3; touch-action: manipulation; }
@media (pointer: coarse) {
  body:has(#setup[hidden]) #config-toggles { display: flex; }
  body:has(#setup[hidden]) #flight-menu-btn { display: block; }
  /* 左上のトグル列と#panelが重ならないよう、飛行中の凡例パネルを少し下げる */
  #panel { top: 54px; }
}
#config-toggles {
  top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  gap: 6px;
}
#config-toggles button {
  width: 46px; height: 34px; border-radius: 6px; padding: 0;
  background: rgba(10,16,24,0.6); border: 1px solid rgba(210,225,240,0.3);
  color: #cfe0f0; font-size: 10px; font-weight: 600; letter-spacing: .02em;
  cursor: pointer;
}
#config-toggles button.on {
  background: rgba(127,196,232,0.35); border-color: #7fc4e8; color: #eef8ff;
}
#flight-menu-btn {
  top: max(12px, env(safe-area-inset-top)); right: max(52px, calc(52px + env(safe-area-inset-right)));
  width: 32px; height: 32px; padding: 0; border-radius: 6px;
  background: rgba(10,16,24,0.6); border: 1px solid rgba(210,225,240,0.3);
  color: #cfe0f0; font-size: 15px; line-height: 30px; text-align: center; cursor: pointer;
}

/* ── 縦画面ではフライトシムの操作を成立させない ─────────────────────
   実在のモバイルフライトシム(Infinite Flight等)は例外なく横画面固定。
   同じ方針で、縦画面中は操作系を隠して回転案内に切り替える。 */
#rotate-prompt {
  display: none; position: fixed; inset: 0; z-index: 6; background: #0a0d12;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: #dfe8f2; text-align: center; padding: 24px;
}
@media (pointer: coarse) and (orientation: portrait) {
  body:has(#setup[hidden]) #rotate-prompt { display: flex; }
  body:has(#setup[hidden]) #config-toggles,
  body:has(#setup[hidden]) #flight-menu-btn,
  body:has(#setup[hidden]) .stick { display: none !important; }
}
#rotate-prompt .rotate-icon { font-size: 44px; display: inline-block; animation: rotate-hint 1.6s ease-in-out infinite; }
@keyframes rotate-hint { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }
#rotate-prompt p { max-width: 280px; line-height: 1.6; color: #9fb4c8; font-size: 13px; }
#rotate-prompt button {
  width: min(280px,80vw); padding: 11px; font-size: 15px; font-weight: 600;
  color: #0a0d12; background: #7fc4e8; border: none; border-radius: 8px; cursor: pointer;
}

/* ── 課題の進捗と結果 ─────────────────────────────────────────────── */
#progress {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: rgba(10,16,24,0.62); border: 1px solid rgba(210,225,240,0.28);
  border-radius: 8px; padding: 6px 14px; font-size: 13px; color: #dfe8f2;
  font-family: ui-monospace, monospace; white-space: nowrap;
}
#progress[hidden] { display: none; }

#result {
  position: fixed; inset: 0; z-index: 4; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6,10,16,0.82); overflow-y: auto;
}
#result[hidden] { display: none; }
#result .card {
  width: min(560px, 100%); background: rgba(18,24,34,0.96);
  border: 1px solid rgba(210,225,240,0.2); border-radius: 12px; padding: 20px 22px;
}
#result h2 { margin: 0 0 6px; font-size: 22px; }
#result p { margin: 0 0 10px; }
#result .muted { color: #9fb4c8; font-size: 13px; }
#result button {
  width: 100%; margin-top: 12px; padding: 10px; font-size: 14px; font-weight: 600;
  color: #0a0d12; background: #7fc4e8; border: none; border-radius: 8px; cursor: pointer;
}
#ranking table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
#ranking th, #ranking td { text-align: left; padding: 5px 8px; border-bottom: 1px solid rgba(210,225,240,0.14); }
#ranking th { color: #8ea4b8; font-weight: 500; font-size: 11px; }
#ranking td { font-family: ui-monospace, monospace; }
#ranking button {
  width: auto; margin: 0; padding: 3px 10px; font-size: 12px;
  background: rgba(127,196,232,0.18); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.4); border-radius: 5px;
}
#setup .note-line { font-size: 12px; color: #9fb4c8; margin: -6px 0 12px; }
#setup .note-line[hidden] { display: none; }

/* 格納庫でランキングを覗く(タイムアタックの課題を選んだときだけ出る) */
#setup #setup-rank-line { margin: 10px 0 0; text-align: center; }
#setup button.link-btn {
  width: auto; margin: 0; padding: 4px 10px; font-size: 12px; font-weight: 500;
  background: rgba(127,196,232,0.14); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.35); border-radius: 6px;
}
#setup button.link-btn:hover { background: rgba(127,196,232,0.26); }
#setup-ranking:empty { display: none; }
#setup-ranking { margin-top: 8px; }
#setup-ranking table { width: 100%; border-collapse: collapse; font-size: 12px; }
#setup-ranking th, #setup-ranking td {
  text-align: left; padding: 4px 6px; border-bottom: 1px solid rgba(210,225,240,0.12);
}
#setup-ranking th { color: #8ea4b8; font-weight: 500; font-size: 11px; }
#setup-ranking td { font-family: ui-monospace, monospace; }
#setup-ranking .muted { color: #8ea4b8; font-size: 12px; margin: 0; }
#setup-ranking button { width: auto; margin: 0; padding: 2px 8px; font-size: 11px;
  background: rgba(127,196,232,0.16); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.35); border-radius: 5px; }
#setup input[type="text"] {
  flex: 1; background: #10161f; color: #dfe8f2;
  border: 1px solid rgba(210,225,240,0.25); border-radius: 6px; padding: 6px 8px;
  font-size: 16px;
}

/* ── チュートリアル(設計書§23)──────────────────────────────────── */
/* HUD の左上の枠(12,12 から 168×92)と重ならない位置に置く */
#tutorial {
  position: fixed; left: 12px; top: 116px; z-index: 3; width: min(340px, 46vw);
  background: rgba(10,16,24,0.82); border: 1px solid rgba(127,196,232,0.35);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.55;
}
@media (pointer: coarse) {
  /* 2026-09-02発見: 左下の仮想スティックの真上にチュートリアル案内が
     被さり、チュートリアル中は移動スティックが操作できなくなっていた。
     HUD計器盤は2026-08-18に同種の問題をsideInsetで対処済みだったが、
     このパネルは対応漏れだった。スティックの右側へ逃がす。 */
  /* 2026-09-04 ユーザー指摘: 画面上部(機体・滑走路が見える範囲)に
     大きく居座っていて視界を占有していた。スティックの下端(bottom:150px、
     app.js の sideInset=146 と対になる「計器盤に被らない」安全な高さ)と
     揃えて左下寄りに下ろす。上へ伸びる分には計器盤の列(画面最下部)と
     ぶつからない。
     同日、さらに下げてほしいとの追加指摘。計器盤(hud.js dialLayout)の
     半径は最大52pxで頭打ちなので、計器盤の天面は画面最下端から最大でも
     120px(=2×52+16)の高さにしかならない。130pxならどの画面幅でも
     計器盤と重ならない範囲で、これ以上は下げられない。 */
  #tutorial { left: calc(150px + env(safe-area-inset-left)); top: auto; bottom: calc(130px + env(safe-area-inset-bottom)); }
}
#tutorial[hidden] { display: none; }

/* ── 移動・リサイズ用ハンドル(2026-09-04 ユーザー要望)───────────────
   タッチ端末でだけ出す。上のつまみを長押しすると移動、右端の縦グリップを
   つかむと幅を変えられる(実処理は app.js の bindTutorialUI)。
   「つかめる場所がわかりやすいデザインに」との要望どおり、
   iOS/Android のボトムシートで馴染みのある横棒のつまみと、
   分割線でよく使う縦グリップの見た目を使う。 */
#tut-draghandle, #tut-resize { display: none; }
@media (pointer: coarse) {
  #tut-draghandle, #tut-resize { display: flex; }
}
#tut-draghandle {
  align-items: center; justify-content: center;
  padding: 3px 0 9px; margin-top: -3px;
  touch-action: none; cursor: grab;
  -webkit-user-select: none; user-select: none;
}
#tut-draghandle .grip {
  width: 36px; height: 5px; border-radius: 3px;
  background: rgba(223,232,242,0.4); transition: background .15s, transform .15s;
}
#tutorial.dragging #tut-draghandle .grip {
  background: #7fc4e8; transform: scaleX(1.15);
}
#tut-resize {
  position: absolute; top: 8px; bottom: 8px; right: 1px; width: 22px;
  align-items: center; justify-content: center;
  touch-action: none; cursor: ew-resize;
  -webkit-user-select: none; user-select: none;
}
#tut-resize::before {
  content: ""; width: 4px; height: 44px; max-height: 55%; border-radius: 2px;
  background: rgba(223,232,242,0.34); transition: background .15s, transform .15s;
}
#tutorial.resizing #tut-resize::before {
  background: #7fc4e8; transform: scaleY(1.08);
}
#tutorial.dragging, #tutorial.resizing {
  background: rgba(10,16,24,0.86); border-color: rgba(127,196,232,0.7);
}
#tutorial .tut-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
#tut-progress {
  font-family: ui-monospace, monospace; font-size: 12px; color: #7fc4e8;
  border: 1px solid rgba(127,196,232,0.4); border-radius: 5px; padding: 2px 7px;
}
#tutorial button {
  margin-left: auto; padding: 4px 9px; font-size: 11px; cursor: pointer;
  background: rgba(127,196,232,0.16); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.4); border-radius: 5px;
}
#tutorial button + button { margin-left: 0; }
#tutorial button:hover { background: rgba(127,196,232,0.3); }
#tut-step { margin: 0 0 4px; font-size: 15px; color: #fff; }
#tut-say { margin: 0 0 9px; color: #b9cbdd; }
#tut-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.keycap {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: #9fb4c8;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(210,225,240,0.22);
  border-radius: 6px; padding: 3px 8px;
}
.keycap b {
  font-family: ui-monospace, monospace; font-size: 12px; color: #dfe8f2;
  background: rgba(255,255,255,0.09); border-radius: 3px; padding: 0 5px;
}
/* 実際に押されている操作を光らせる */
.keycap.on { border-color: #7fc4e8; color: #eaf4fb; background: rgba(127,196,232,0.22); }
.keycap.on b { background: #7fc4e8; color: #0a0d12; }
#tut-gauge {
  position: relative; margin-top: 9px; height: 18px; border-radius: 4px;
  background: rgba(255,255,255,0.07); overflow: hidden;
  font-size: 11px; font-family: ui-monospace, monospace;
}
#tut-gauge[hidden] { display: none; }
#tut-gauge span { position: relative; z-index: 1; display: block; padding: 2px 7px; color: #dfe8f2; }
#tut-gauge i { position: absolute; inset: 0 auto 0 0; background: rgba(127,196,232,0.32); }
#tut-hint { margin: 8px 0 0; font-size: 12px; color: #ffd79a; }
#tut-hint[hidden] { display: none; }

@media (max-width: 700px), (pointer: coarse) {
  #tutorial { width: min(300px, 62vw); font-size: 12px; padding: 9px 10px; }
  #tut-step { font-size: 13px; }
}

/* モードの3択(自分で / なぞる / お手本) */
#tutorial .tut-modes { display: flex; gap: 4px; margin-bottom: 9px; }
#tutorial .tut-modes button {
  flex: 1; margin: 0; padding: 5px 0; font-size: 11px; text-align: center;
}
#tutorial .tut-modes button.on {
  background: #7fc4e8; color: #0a0d12; border-color: #7fc4e8; font-weight: 700;
}

/*
 * キーの札の状態:
 *   press   … 今すぐ押す(急ぎ度で色が濃くなる)
 *   ok      … 押していて合っている
 *   release … 押しているが今は要らない
 *   on      … 押している(自分でモードの表示)
 */
.keycap.press {
  border-color: rgba(255,196,110,calc(0.4 + 0.6 * var(--urg, 0.5)));
  background: rgba(255,176,74,calc(0.10 + 0.28 * var(--urg, 0.5)));
  color: #ffe2b8;
  animation: keypulse 0.9s ease-in-out infinite;
}
.keycap.press b { background: #ffb44a; color: #221503; }
.keycap.ok { border-color: #7ee0a5; background: rgba(126,224,165,0.18); color: #dcf7e7; animation: none; }
.keycap.ok b { background: #7ee0a5; color: #05200f; }
.keycap.release { border-color: rgba(255,130,130,0.6); background: rgba(255,110,110,0.14); color: #ffd2d2; }
.keycap.release b { background: #ff8a8a; color: #2a0808; }
@keyframes keypulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) { .keycap.press { animation: none; } }

/* なぞり具合 */
#tut-accuracy {
  position: relative; margin-top: 7px; height: 18px; border-radius: 4px;
  background: rgba(255,255,255,0.07); overflow: hidden;
  font-size: 11px; font-family: ui-monospace, monospace;
}
#tut-accuracy[hidden] { display: none; }
#tut-accuracy span { position: relative; z-index: 1; display: block; padding: 2px 7px; color: #dfe8f2; }
#tut-accuracy i { position: absolute; inset: 0 auto 0 0; background: rgba(126,224,165,0.34); transition: width .2s; }

/* ── 計器の説明(設計書§24)────────────────────────────────────────── */
#panel #btn-help {
  margin-top: 4px; padding: 3px 10px; font-size: 11px; cursor: pointer;
  pointer-events: auto;
  background: rgba(127,196,232,0.16); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.4); border-radius: 5px;
}
#panel #btn-help:hover { background: rgba(127,196,232,0.3); }

#instruments {
  position: fixed; inset: 0; z-index: 6; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6,10,16,0.86); overflow-y: auto;
}
#instruments[hidden] { display: none; }
#instruments .card {
  width: min(760px, 100%); max-height: 92vh; overflow-y: auto;
  background: rgba(18,24,34,0.97); border: 1px solid rgba(210,225,240,0.2);
  border-radius: 12px; padding: 20px 22px;
}
#instruments .ins-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
#instruments h2 { margin: 0; font-size: 20px; }
#instruments .ins-head button {
  margin-left: auto; padding: 6px 12px; font-size: 12px; cursor: pointer;
  background: rgba(127,196,232,0.18); color: #cfe0f0;
  border: 1px solid rgba(127,196,232,0.42); border-radius: 6px;
}
#instruments .ins-lead { margin: 0 0 16px; font-size: 13px; color: #9fb4c8; }

.ins-item {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 14px 0; border-top: 1px solid rgba(210,225,240,0.12);
}
.ins-art { flex: 0 0 96px; }
.ins-art--text {
  width: 96px; min-height: 60px; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 11px; color: #8ea4b8; line-height: 1.5;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(210,225,240,0.18); border-radius: 8px;
  padding: 8px;
}
.ins-body { flex: 1; min-width: 0; }
.ins-body h3 { margin: 0 0 2px; font-size: 15px; color: #fff; }
.ins-sub { margin: 0 0 8px; font-size: 12px; color: #7fc4e8; font-family: ui-monospace, monospace; }
.ins-body p { margin: 0 0 6px; font-size: 13px; line-height: 1.65; color: #c3d3e2; }
.ins-body .ins-marks { color: #9fb4c8; }
.ins-body .ins-tip {
  color: #ffd79a; font-size: 12px;
  background: rgba(255,196,110,0.08); border-left: 2px solid rgba(255,196,110,0.5);
  padding: 6px 10px; border-radius: 0 5px 5px 0;
}
.ins-body strong { color: #fff; font-weight: 700; }

@media (max-width: 700px) {
  .ins-item { flex-direction: column; gap: 10px; }
  .ins-art, .ins-art--text { flex: none; }
}

/* ── なぞりの案内(優先順位で上から大きく・設計書§23.8)────────────
 * 要らないキーは出さない。画面に出ているものは全部「押すもの」。
 * **上にあるものほど優先度が高く、大きさは段階(離散)で決まる**
 * (rank-0 が最大。calc(--urg) のような連続補間はしない — ユーザー指摘、
 * 2026-08-19「大きさをじわじわ変えないでほしい」)。並び順自体は
 * ヒステリシス付きで、僅かな差では入れ替わらない(app.js/tutorial.js側)。
 */
#tut-guide { margin-top: 9px; }
#tut-guide[hidden] { display: none; }

.tg-act {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px; border-radius: 9px;
  background: rgba(255,176,74,0.14);
  border: 1px solid rgba(255,196,110,0.55);
}
/* 押せていれば緑へ(色が分からなくても、下の帯が減るので分かる) */
.tg-act.down {
  background: rgba(126,224,165,0.16);
  border-color: rgba(126,224,165,0.6);
  box-shadow: none;
}

.tg-cap {
  flex: 0 0 auto; text-align: center;
  font-family: ui-monospace, monospace; font-weight: 800;
  line-height: 1.15;
  color: #221503; background: #ffb44a;
  border-radius: 6px;
}
.tg-act.down .tg-cap { background: #7ee0a5; color: #05200f; }

.tg-body { flex: 1; min-width: 0; }
.tg-txt { display: block; color: #ffe2b8; line-height: 1.35; }
.tg-act.down .tg-txt { color: #dcf7e7; }

/* 「あとどれだけ押し続けるか」。空になったら離す */
.tg-left {
  margin-top: 4px; border-radius: 3px;
  background: rgba(0,0,0,0.32); overflow: hidden;
}
.tg-left i {
  display: block; height: 100%; background: #ffc46e;
  transition: width .1s linear;
}
.tg-act.down .tg-left i { background: #7ee0a5; }

/* ── 大きさの段階(rank-0 が最上位=最大。4段より下は最小のまま) ─── */
.tg-act.rank-0 { padding: 11px 12px; box-shadow: 0 0 0 1px rgba(255,196,110,0.4), 0 3px 14px rgba(255,150,40,0.2); }
.tg-act.rank-0 .tg-cap { font-size: 30px; min-width: 52px; padding: 6px 10px; }
.tg-act.rank-0 .tg-txt { font-size: 14px; }
.tg-act.rank-0 .tg-left { height: 7px; }

.tg-act.rank-1 { padding: 9px 11px; }
.tg-act.rank-1 .tg-cap { font-size: 24px; min-width: 44px; padding: 5px 9px; }
.tg-act.rank-1 .tg-txt { font-size: 13px; }
.tg-act.rank-1 .tg-left { height: 6px; }

.tg-act.rank-2 { padding: 7px 10px; }
.tg-act.rank-2 .tg-cap { font-size: 20px; min-width: 38px; padding: 4px 8px; }
.tg-act.rank-2 .tg-txt { font-size: 12px; }
.tg-act.rank-2 .tg-left { height: 5px; }

.tg-act.rank-3 { padding: 6px 9px; }
.tg-act.rank-3 .tg-cap { font-size: 17px; min-width: 32px; padding: 3px 7px; }
.tg-act.rank-3 .tg-txt { font-size: 11px; }
.tg-act.rank-3 .tg-left { height: 4px; }

.tg-none {
  padding: 8px 10px; border-radius: 8px; text-align: center;
  font-size: 12px; color: #9fd8b6;
  background: rgba(126,224,165,0.10); border: 1px solid rgba(126,224,165,0.3);
}

@media (max-width: 700px), (pointer: coarse) {
  .tg-act.rank-0 .tg-cap { font-size: 24px; min-width: 42px; }
  .tg-act.rank-1 .tg-cap { font-size: 20px; min-width: 36px; }
  .tg-act.rank-2 .tg-cap { font-size: 17px; min-width: 31px; }
  .tg-act.rank-3 .tg-cap { font-size: 15px; min-width: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  .tg-left i { transition: none; }
}

/* ── モバイル(タッチ端末)の操作ガイドをさらに縮小・半透明化 ──────────
   2026-09-04 ユーザー指摘「画面を占有している」。上の (max-width:700px)
   だけでは横向きスマホの多く(iPhone 15 横向きで852pxなど)が幅700pxを
   超えるため発火せず、操作ガイドがPCと同じ大きさのまま画面の広い範囲を
   覆っていた。タッチ端末は pointer:coarse で確実に捕まえ、もう一段
   小さくしたうえで背景を薄くし、奥の機体や地形が透けて見えるようにする。
   文字だけは text-shadow を足して背景が薄くても読めるようにする。 */
@media (pointer: coarse) {
  #tutorial {
    width: min(230px, 42vw); font-size: 11px; padding: 7px 9px;
    background: rgba(10,16,24,0.5); border-color: rgba(127,196,232,0.22);
  }
  #tut-step { font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
  #tut-say { text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
  #tut-hint { text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
  #tutorial button { background: rgba(127,196,232,0.1); }
  .keycap { background: rgba(255,255,255,0.02); }

  .tg-act {
    background: rgba(255,176,74,0.08); border-color: rgba(255,196,110,0.35); box-shadow: none;
  }
  .tg-act.down { background: rgba(126,224,165,0.08); }
  .tg-txt { text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
}

/* little-bit: focus-visible(2026-08-29追加)
   キーボード操作でいまどこにいるかが見えないアプリが24中20あった
   (サイト品質棚卸し B-5)。:where() で詳細度0にしてあるので、
   個別に focus スタイルを持つ要素はそちらが勝つ。
   色はサイト共通のアクセント(#e8825a)。明るい地でも暗い地でも見える。 */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid #e8825a;
  outline-offset: 2px;
}
