/* ========================================
   電気メガネ サウンドテストツール
   共通スタイル
   本家 https://megane.8796.jp/ のデザインを踏襲
   ======================================== */

/* CSS変数 - 本家のダークテーマ踏襲 */
:root {
  /* 本家踏襲カラー（グラスモーフィズム） */
  --surface: rgba(15, 23, 42, 0.85);
  --surface-solid: #0f172a;
  --border: rgba(148, 163, 184, 0.3);
  --text-primary: #f8fafc;
  --text-muted: #cbd5f5;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --bg-body: #020617;

  /* 互換用エイリアス */
  --color-primary: var(--text-primary);
  --color-accent: var(--accent);
  --color-accent-hover: var(--accent-strong);
  --color-bg: var(--bg-body);
  --color-bg-card: var(--surface);
  --color-text: var(--text-primary);
  --color-text-light: var(--text-muted);
  --color-text-muted: var(--text-dim);
  --color-text-inverse: #0f172a;
  --color-border: var(--border);
  --color-header-bg: rgba(15, 23, 42, 0.6);
  --color-footer-bg: rgba(15, 23, 42, 0.6);
  --color-success: #4ade80;
  --color-warning: #fbbf24;
  --color-danger: #f87171;

  /* サイズ */
  --header-height: 56px;
  --footer-height: 80px;
  --content-max-width: 800px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* 操作パネル */
  --control-panel-height: 52px;
  --control-panel-bg: rgba(15, 23, 42, 0.9);

  /* アニメーション */
  --transition-fast: 150ms;
  --transition-normal: 250ms;
  --transition-slow: 400ms;

  /* フォント */
  --font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
}

/* リセット */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-strong);
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ========================================
   ヘッダー
   ======================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  background: rgba(15, 23, 42, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header__logo p {
  margin: 0;
  white-space: nowrap;
}

.site-title-link {
  color: inherit;
  text-decoration: none;
}

.site-title-link:hover {
  opacity: 0.8;
}

.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s;
  padding: 4px;
  border-radius: 6px;
}

.home-link:hover {
  color: var(--accent);
  background: rgba(148, 163, 184, 0.1);
}

/* ========================================
   メインコンテンツ
   ======================================== */
.main {
  flex: 1;
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
}

/* セクション共通 */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent);
}

.section-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ========================================
   ヒーローセクション
   ======================================== */
.hero-section {
  position: relative;
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--header-height) + 2rem) 1.5rem 2rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 50%, rgba(56, 189, 248, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  text-align: center;
  z-index: 1;
}

.hero-title {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 0%, #38bdf8 50%, #a855f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* スタートボタン */
.start-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-inverse);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(56, 189, 248, 0.5);
}

.start-button:active {
  transform: translateY(0);
}

.start-button__icon {
  font-size: 1.5rem;
}

/* コンパクト注意事項 */
.hero-notices {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
}

.hero-notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: help;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.hero-notice:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* 設定スイッチ */
.hero-settings {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.setting-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.switch-toggle {
  position: relative;
  width: 48px;
  height: 26px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: background 0.2s;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.switch-toggle input:checked + .switch-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-toggle input:checked + .switch-slider::before {
  transform: translateX(22px);
  background: #fff;
}

.setting-switch__label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.setting-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 1.15rem;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.setting-share:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
}

.setting-share__icon {
  transform: translateY(-1px);
}

/* ========================================
   注意セクション
   ======================================== */
.notice-section {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.notice-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.notice-card--warning {
  border-color: var(--color-warning);
  background: rgba(251, 191, 36, 0.1);
}

.notice-card--safe {
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.notice-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.notice-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.notice-text strong {
  color: var(--text-primary);
}

/* ========================================
   デバイス設定セクション
   ======================================== */
.device-section {
  padding: 1.5rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* 折りたたみ式デバイス設定 */
.device-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.device-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
}

.device-summary::-webkit-details-marker {
  display: none;
}

.device-summary .section-title {
  margin: 0;
  font-size: 1rem;
}

.device-toggle-icon {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.device-details[open] .device-toggle-icon {
  transform: rotate(180deg);
}

.device-content {
  padding: 0 1.25rem 1.25rem;
}

.device-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.device-header .section-title {
  margin: 0;
}

.device-refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.device-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: var(--text-primary);
}

.device-settings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.device-setting {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.device-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  width: 140px;
  flex-shrink: 0;
}

.device-label__icon {
  font-size: 1rem;
}

.device-select {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.device-select:hover {
  border-color: var(--accent);
}

.device-select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
}

.device-select option {
  background: #1a1a2e;
  color: var(--text-primary);
}

.device-note {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
}

/* デバッグログ */
.debug-log-details {
  margin-top: 1rem;
}

.debug-log-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.debug-log {
  margin-top: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #0f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-log-clear {
  margin-top: 0.5rem;
  padding: 4px 12px;
  font-size: 0.75rem;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
}

.debug-log-clear:hover {
  border-color: var(--accent);
}

/* ========================================
   特徴セクション
   ======================================== */
.features-section {
  padding: 2rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.feature-card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.feature-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.feature-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ========================================
   テスト一覧セクション
   ======================================== */
.test-list-section {
  padding: 2rem 1.5rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.test-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.test-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: relative;
}

.test-item:hover {
  transform: translateX(4px);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.test-item__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.test-item__content {
  flex: 1;
  min-width: 0;
}

.test-item__name {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.test-item__desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ヘルプボタン */
.test-item__help {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.test-item__help:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
}

.test-item.show-tooltip .test-item__help {
  background: var(--accent);
  color: #fff;
}

/* ツールチップ */
.test-item__tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  padding: 1rem;
  background: var(--surface-solid);
  border: 1px solid var(--accent);
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}

.test-item.show-tooltip .test-item__tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ========================================
   操作説明セクション
   ======================================== */
.instructions-section {
  padding: 2rem 1.5rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 600px) {
  .instructions-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.instruction-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.instruction-icon {
  font-size: 1.75rem;
}

.instruction-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.instruction-text small {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ========================================
   使い方セクション
   ======================================== */
.usage-section {
  padding: 2rem 1.5rem 4rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.usage-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.usage-item {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.usage-item h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.usage-item p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ========================================
   ページ切替
   ======================================== */
.page {
  min-height: 100vh;
  min-height: 100dvh;
}

.page--test {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
}

/* ========================================
   テスト画面
   ======================================== */
.test-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#test-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* デバイス情報表示 */
.device-info {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  z-index: 50;
  display: none;
  max-width: 200px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.device-info--mirror {
  left: auto;
  right: 12px;
}

/* SBSモード時の左目用デバイス情報位置調整 */
.page--test.is-sbs-mode .device-info:not(.device-info--mirror) {
  left: 12px;
  right: auto;
}

/* SBSモード時の右目用デバイス情報位置調整 */
.page--test.is-sbs-mode .device-info--mirror {
  left: calc(50% + 12px);
  right: auto;
}

.device-info__row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.device-info__icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ========================================
   操作パネル（常時表示）
   ======================================== */
.control-panel {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  height: var(--control-panel-height);
  background: var(--control-panel-bg);
  border: 1px solid var(--border);
  border-radius: 30px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 200;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.control-panel--mirror {
  /* SBSモード時の右目用、デフォルト非表示 */
  display: none;
  left: 75%;
}

.control-btn--exit {
  color: #ef4444;
}

.control-btn--exit:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.control-btn:hover,
.control-btn.is-hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn--play {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: var(--color-text-inverse);
  font-size: 1.2rem;
}

.control-btn--play:hover,
.control-btn--play.is-hover {
  background: var(--accent-strong);
  border-color: transparent;
}

.control-btn__icon {
  line-height: 1;
}

.control-btn--share {
  color: #1da1f2;
  font-weight: bold;
}

.control-btn--share:hover {
  background: rgba(29, 161, 242, 0.2);
  border-color: #1da1f2;
}

/* ========================================
   音量コントロール
   ======================================== */
.volume-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.control-btn--volume {
  font-size: 1.1rem;
}

.control-btn--volume.is-muted {
  color: var(--text-secondary);
}

.volume-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: width 0.2s;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.volume-slider::-webkit-slider-thumb:hover,
.volume-slider.is-hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-track {
  background: var(--border);
  border-radius: 2px;
  height: 4px;
}

/* 音源切替ボタン */
.control-btn--source {
  font-size: 1.1rem;
}

.control-btn--source.is-demo {
  color: #f59e0b;
}

/* 単体テストモード時はナビゲーションボタンを非表示 */
.page--test.is-single-mode .control-btn--nav {
  display: none;
}

/* SBSモード時のパネル位置調整 */
.page--test.is-sbs-mode .control-panel {
  left: 25%;
}

.page--test.is-sbs-mode .control-panel--mirror {
  display: flex !important;
  left: 75%;
}

/* ========================================
   設定ポップアップ
   ======================================== */
.settings-popup {
  position: fixed;
  bottom: calc(24px + var(--control-panel-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 210;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.settings-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.settings-popup__title {
  font-weight: 700;
  color: var(--text-primary);
}

.settings-popup__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.settings-popup__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-popup__content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 設定項目 */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item__label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.setting-item__value {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 700;
}

.setting-item input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--surface-solid);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.setting-item input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

/* ノイズタイプ選択ボタン */
.setting-item__buttons {
  display: flex;
  gap: 8px;
}

.setting-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.setting-btn:hover {
  border-color: var(--accent);
}

.setting-btn.is-active {
  color: var(--color-text-inverse);
  background: var(--accent);
  border-color: var(--accent);
}

/* SBSモード時のポップアップ位置 */
.page--test.is-sbs-mode .settings-popup {
  left: 25%;
}

/* SBSモード時の右目用設定ポップアップ */
.page--test.is-sbs-mode .settings-popup.settings-popup--mirror {
  left: 75%;
}

.settings-popup--mirror {
  position: fixed;
  bottom: calc(24px + var(--control-panel-height) + 16px);
  left: 75%;
  transform: translateX(-50%);
  width: min(320px, calc(50vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 210;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.settings-popup--mirror .settings-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.settings-popup--mirror .settings-popup__title {
  font-weight: 700;
  color: var(--text-primary);
}

.settings-popup--mirror .settings-popup__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.settings-popup--mirror .settings-popup__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-popup--mirror .settings-popup__content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========================================
   モーダル
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(400px, 100%);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-align: center;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.modal__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.modal__text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.modal__checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  cursor: pointer;
}

.modal__checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.modal__buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.modal__button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-inverse);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.modal__button:hover {
  background: var(--accent-strong);
}

.modal__button:active {
  transform: scale(0.98);
}

.modal__button--secondary {
  color: var(--text-muted);
  background: var(--surface-solid);
  border: 1px solid var(--border);
}

.modal__button--secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* SBSモード時のモーダル */
.modal-overlay.is-sbs-mode {
  flex-direction: row;
  gap: 2rem;
}

.modal-overlay.is-sbs-mode .modal {
  flex: 0 0 calc(50% - 3rem);
  max-width: 360px;
}

/* ========================================
   テスト名表示（アニメーション）
   ======================================== */
.test-name-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 900;
  color: var(--text-primary);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 150;
  opacity: 0;
  animation: fadeInOut 1.5s ease-in-out forwards;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

/* SBSモード時のテスト名表示 */
.test-name-display.is-sbs-mode {
  left: 25%;
}

.test-name-display.is-sbs-mode.is-mirror {
  left: 75%;
}

/* ========================================
   心電図グラフ用キャンバススタイル
   ======================================== */
.ecg-line {
  stroke: #4ade80;
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 4px #4ade80);
}

.ecg-grid {
  stroke: rgba(74, 222, 128, 0.2);
  stroke-width: 1;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 480px) {
  .header {
    padding: 0.5rem 1rem;
  }
  
  .header__logo {
    font-size: 1rem;
  }
  
  .hero-section {
    min-height: 40vh;
    padding-top: calc(var(--header-height) + 1rem);
  }
  
  .start-button {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
  }
  
  .control-panel {
    bottom: 16px;
    padding: 6px 12px;
    gap: 4px;
  }
  
  .control-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
  
  .control-btn--play {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
  
  .settings-popup {
    bottom: calc(16px + var(--control-panel-height) + 12px);
  }
}
