/* vroom web — 夜のメーターパネル（アプリ lib/ui/theme.dart の色） */
:root {
  --bg: #060708;
  --panel: #111316;
  --edge: #2a2d32;
  --text: #f2f1ec;
  --sub: #8c9097;
  --dim: #5e636a;
  --red: #e0261e;
  --lamp: #ff6a21;
  --tach: 300px;
  --ctl-h: 200px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  overflow: hidden; overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body {
  background: radial-gradient(120% 90% at 50% 32%, #15171a 0%, var(--bg) 70%) fixed, var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }

#app {
  position: fixed; inset: 0; margin: 0 auto; max-width: 520px;
  display: flex; flex-direction: column;
  padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* 上の行 */
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; flex: none; gap: 8px; }
.title { margin: 0; font-size: 13px; font-weight: 600; color: var(--sub); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: baseline; gap: 8px; }
.title .brand { padding-right: 3px; font-size: 15px; font-weight: 800; color: var(--text); letter-spacing: .06em; font-style: italic; }
.tools { display: flex; gap: 2px; flex: none; }
.iconbtn { width: 44px; height: 44px; border: 0; background: none; padding: 11px; border-radius: 10px; cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; display: block; fill: var(--sub); }
.iconbtn svg .w { fill: none; stroke: var(--sub); stroke-width: 1.8; stroke-linecap: round; }
.iconbtn:focus-visible { outline: 2px solid var(--lamp); }
#muteBtn .off { display: none; }
#muteBtn[aria-pressed="true"] .on { display: none; }
#muteBtn[aria-pressed="true"] .off { display: block; }

/* エンジン切替 */
.switch {
  flex: none; height: 60px; display: flex; padding: 3px; gap: 2px; margin-top: 2px;
  border-radius: 12px; border: .8px solid var(--edge);
  background: linear-gradient(#030304, #1b1d21);
}
.seg {
  flex: 1 1 0; min-width: 0; border: .6px solid transparent; border-radius: 9px; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer;
  transition: background .16s, border-color .16s;
}
.seg b { font-size: 13px; font-weight: 600; color: var(--sub); line-height: 1.15; white-space: nowrap; }
.seg small { font-size: 10px; letter-spacing: .06em; color: var(--dim); line-height: 1.4; }
.seg i { display: block; width: 14px; height: 2.5px; border-radius: 2px; background: #2a1a12; margin-top: 4px; }
.seg[aria-checked="true"] { background: linear-gradient(#34383e, #1c1f23); border-color: #4a4e55; box-shadow: 0 2px 4px #000; }
.seg[aria-checked="true"] b { color: var(--text); }
.seg[aria-checked="true"] small { color: var(--sub); }
.seg[aria-checked="true"] i { background: var(--lamp); box-shadow: 0 0 6px rgba(255,106,33,.8); }
.seg:focus-visible { outline: 2px solid var(--lamp); outline-offset: -2px; }

/* モード切替 */
.modes {
  flex: none; height: 40px; display: flex; padding: 3px; gap: 2px; margin-top: 6px;
  border-radius: 11px; border: .8px solid var(--edge); background: linear-gradient(#030304, #1b1d21);
}
.mode {
  flex: 1 1 0; min-width: 0; border: .6px solid transparent; border-radius: 8px; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--sub); white-space: nowrap; transition: background .16s, border-color .16s;
}
.mode[aria-checked="true"] { background: linear-gradient(#34383e, #1c1f23); border-color: #4a4e55; box-shadow: 0 2px 4px #000; color: var(--text); }
.mode:focus-visible { outline: 2px solid var(--lamp); outline-offset: -2px; }

/* メーター */
.stage { flex: 1 1 auto; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 10px 2px; }
.tach { position: relative; width: var(--tach); height: var(--tach); flex: none; will-change: transform; }
.tach canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* 針とガラスは文字盤の印字（ランプ・回転数・速度・ギア）より手前。吹き出しはさらに手前 */
#needle { z-index: 2; }
#glass { z-index: 3; }
.pop { z-index: 4; }
.readout {
  position: absolute; left: 50%; top: 73.5%; transform: translate(-50%, -50%);
  font-size: calc(var(--tach) * .0525); font-weight: 500; letter-spacing: .03em; color: #f6efe4;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 calc(var(--tach) * .01) rgba(255,255,255,.35);
  line-height: 1; white-space: nowrap;
}
/* 走る: 速さ・ギア・0-100（メーターの中） */
.hud { display: none; }
.drive .hud { display: flex; }
.speed {
  position: absolute; left: 50%; top: 63.5%; transform: translate(-50%, -50%);
  align-items: baseline; gap: calc(var(--tach) * .012); line-height: 1; white-space: nowrap;
}
.speed b { font-size: calc(var(--tach) * .1); font-weight: 600; color: #f6efe4; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.speed small { font-size: calc(var(--tach) * .038); color: var(--sub); }
.gearind {
  position: absolute; left: 26%; top: 73.5%; transform: translate(-50%, -50%);
  width: calc(var(--tach) * .09); height: calc(var(--tach) * .09); border-radius: calc(var(--tach) * .014);
  align-items: center; justify-content: center; background: #030405; box-shadow: inset 0 0 0 1px #2c2f34;
  font-size: calc(var(--tach) * .062); font-weight: 700; line-height: 1; color: var(--sub);
}
.gearind.in { color: var(--lamp); text-shadow: 0 0 calc(var(--tach) * .015) rgba(255,106,33,.7); }
.t100 {
  position: absolute; left: 50%; top: 84%; transform: translate(-50%, -50%);
  font-size: calc(var(--tach) * .04); color: var(--sub); white-space: nowrap; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.t100.run { color: var(--text); }
.t100.done { color: var(--lamp); }
.pop {
  position: absolute; left: 50%; top: 41%; transform: translate(-50%, -50%); opacity: 0; pointer-events: none;
  font-size: calc(var(--tach) * .06); font-weight: 700; white-space: nowrap; line-height: 1;
  padding: calc(var(--tach) * .018) calc(var(--tach) * .04); border-radius: 999px;
  background: rgba(10,11,13,.85); border: 1px solid rgba(255,106,33,.55); color: #ffb27a;
}
.pop.warn { border-color: rgba(224,38,30,.7); color: #ff7a70; }
.pop.show { animation: pop 1.1s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.9); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}
.lamp {
  position: absolute; left: 50%; top: 26.5%; width: calc(var(--tach) * .028); height: calc(var(--tach) * .028);
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, #3a1513 0%, #240c0b 45%, #140707 100%);
}
.lamp.on { background: radial-gradient(circle, #ffd2c8 0%, #ff3b2e 45%, #b0120c 100%); box-shadow: 0 0 calc(var(--tach) * .03) calc(var(--tach) * .008) rgba(224,38,30,.75); }
.hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.18); background: rgba(10,11,13,.82); color: var(--text);
  font-size: 16px; font-weight: 600; padding: 14px 22px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.hint::before { content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -2px;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23f2f1ec' d='M4 9h4l5-4v14l-5-4H4z'/%3E%3Cpath fill='none' stroke='%23f2f1ec' stroke-width='2' stroke-linecap='round' d='M16 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E"); }

/* 下: スタートボタンとペダル */
.controls { flex: none; height: var(--ctl-h); display: flex; align-items: flex-end; justify-content: space-between; padding: 0 6px 2px 10px; }
.startbtn {
  --s: calc(var(--ctl-h) * .5);
  position: relative; width: var(--s); height: var(--s); min-width: 88px; min-height: 88px; max-width: 118px; max-height: 118px;
  margin-bottom: calc(var(--ctl-h) * .16); border: 0; padding: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, #e6e8eb 0%, #7d8288 35%, #2b2e33 70%, #a4a9af 100%);
  box-shadow: 0 5px 8px rgba(0,0,0,.8);
  transition: transform .07s;
}
.startbtn::before { content: ""; position: absolute; inset: 7%; border-radius: 50%; background: #0b0c0e; }
.startbtn .ring { position: absolute; inset: 9.5%; border-radius: 50%; border: calc(var(--s) * .0225) solid #2a1a12; }
.startbtn.on .ring { border-color: var(--lamp); box-shadow: 0 0 6px rgba(255,106,33,.85), inset 0 0 4px rgba(255,106,33,.6); }
.startbtn.off .ring { border-color: #8a4a26; animation: breathe 2.4s ease-in-out 4; opacity: .55; }
.startbtn.stopping .ring { border-color: #5a3018; }
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .85; } }
.startbtn .face {
  position: absolute; inset: 13%; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #3a3e44, #111316 75%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.startbtn .face small { font-size: 11px; font-weight: 600; color: var(--sub); letter-spacing: .05em; margin-bottom: 2px; }
.startbtn .face b { font-size: 13px; font-weight: 700; letter-spacing: .1em; color: rgba(242,241,236,.88); }
.startbtn:active, .startbtn.down { transform: scale(.955); }
.startbtn:active .face, .startbtn.down .face { background: radial-gradient(circle at 35% 28%, #26292e, #0c0d0f 75%); }
.startbtn.nudge { animation: nudge .5s ease-in-out 2; }
@keyframes nudge { 50% { transform: scale(1.08); } }
.startbtn:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; }

/* シフトレバー（Hパターン） */
.gate { display: none; position: relative; touch-action: none; cursor: grab; outline: none; }
.drive .gate { display: block; }
.gate canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.knob {
  position: absolute; left: 0; top: 0; width: var(--kn, 40px); height: var(--kn, 40px); border-radius: 50%; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--kn, 40px) * .42); font-weight: 700; line-height: 1; color: rgba(242,241,236,.85);
  background: radial-gradient(circle at 36% 30%, #7a8088 0%, #3a3e44 38%, #15171a 78%, #0b0c0e 100%);
  box-shadow: 0 5px 9px rgba(0,0,0,.75), inset 0 1px 1px rgba(255,255,255,.25), inset 0 -2px 3px rgba(0,0,0,.6);
  transition: transform .09s ease-out; will-change: transform;
}
.knob.in { color: var(--lamp); text-shadow: 0 0 6px rgba(255,106,33,.8); }
.gate.drag { cursor: grabbing; }
.gate.drag .knob { transition: none; }
.gate.clack { animation: clack .12s ease-out; }
.gate.grind { animation: grind .28s linear; }
@keyframes clack { 30% { transform: translate(0, 1.5px); } }
@keyframes grind { 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }

.pedal { position: relative; height: 100%; aspect-ratio: .62; cursor: pointer; touch-action: none; transition: opacity .25s; outline: none; }
.pedal canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.pedal.inactive { opacity: .45; }
.drive .controls { gap: 8px; padding-left: 4px; }
.drive .startbtn { --s: 72px; min-width: 72px; min-height: 72px; flex: none; margin-bottom: calc(var(--ctl-h) * .06); }
.drive .startbtn .face small { font-size: 10px; }
.drive .startbtn .face b { font-size: 11px; }
.drive .gate { flex: 1 1 0; min-width: 0; max-width: 250px; height: 96%; align-self: flex-end; }
.drive .pedal { flex: none; }

.toast {
  position: absolute; left: 50%; bottom: calc(var(--ctl-h) + 12px); transform: translateX(-50%);
  background: rgba(20,22,26,.94); border: 1px solid var(--edge); color: var(--text);
  font-size: 14px; padding: 9px 16px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}

/* 遊び方シート */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; touch-action: pan-y; }
.sheet-wrap[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 520px; max-height: 85%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: #121418; border-top: 1px solid var(--edge); border-radius: 16px 16px 0 0;
  padding: 16px 20px max(20px, env(safe-area-inset-bottom)); line-height: 1.7; font-size: 15px;
}
.sheet h2 { font-size: 16px; margin: 6px 0 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.closebtn { border: 1px solid var(--edge); background: #1b1e23; border-radius: 999px; padding: 0 18px; min-height: 44px; min-width: 80px; cursor: pointer; font-size: 15px; }
.howto { padding-left: 1.3em; margin: 6px 0 10px; }
.keys { color: var(--sub); font-size: 14px; margin: 0 0 14px; }
.credit { color: var(--sub); font-size: 13px; margin: 0; }
.credit a { color: #8cc8ff; }
.foot { color: var(--dim); font-size: 12px; margin: 16px 0 0; }

/* 横向きのスマホ: 左にボタン・真ん中にメーター・右にペダル */
.wide #app {
  max-width: none; display: grid; column-gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, 1fr);
  grid-template-rows: 44px 52px minmax(0, 1fr);
  grid-template-areas: "title modes tools" "start switch pedal" "start stage pedal";
}
.wide .top { display: contents; }
.wide .title { grid-area: title; align-self: center; min-width: 0; flex-direction: column; align-items: flex-start; gap: 0; font-size: 11px; line-height: 1.25; }
.wide .title .brand { font-size: 14px; }
.wide .tools { grid-area: tools; justify-self: end; align-self: center; }
.wide .modes { grid-area: modes; height: 36px; margin: 0; align-self: center; }
.wide .switch { grid-area: switch; height: 52px; margin-top: 0; }
.wide .stage { grid-area: stage; padding: 6px 0 0; }
.wide .controls { display: contents; }
.wide .startbtn { grid-area: start; align-self: end; justify-self: center; margin-bottom: 18px; }
.wide .pedal { grid-area: pedal; align-self: end; justify-self: center; height: var(--ctl-h); }
.wide .toast { bottom: auto; top: 50px; }
.wide.drive .startbtn { --s: 76px; min-width: 76px; min-height: 76px; align-self: start; margin: 2px 0 0; }
.wide.drive .gate { grid-area: start; align-self: end; justify-self: center; width: 100%; max-width: 250px; height: calc(100% - 90px); }

@media (min-width: 700px) and (min-height: 600px) {
  .title { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .startbtn.off .ring, .startbtn.nudge { animation: none; }
}
/* 幅の狭いスマホ（iPhone SE 1世代など）の縦: シフトの幅を空ける */
@media (max-width: 359px) {
  .title { font-size: 12px; gap: 6px; }
  .drive .controls { gap: 6px; padding-right: 2px; }
  .drive .startbtn { --s: 62px; min-width: 62px; min-height: 62px; }
  .drive .startbtn .face small { display: none; }
  .drive .pedal { aspect-ratio: .55; }
}
