/* モバイルファースト：小さい画面を基準に作り、広い画面で整える */
:root {
  --bg: #0f1115;
  --card: #181b22;
  --text: #e8eaf0;
  --accent: #4f8cff;
  --muted: #8a90a0;
  --border: #2a2f3a;
  --warn: #f0b429;
  --tap: 44px; /* タップ領域の最小サイズ（Appleの推奨値） */
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  /* ノッチ・ホームバーを避ける */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  padding: 16px 16px 12px;
  font-size: 18px;
  font-weight: 700;
}

/* タブ：スマホでは横スクロールできるようにして、1行に収める */
nav {
  display: flex;
  gap: 8px;
  padding: 0 16px 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

nav button {
  flex: 0 0 auto;
  min-height: var(--tap);
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
nav button.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--chip);
}

main {
  padding: 12px 16px 32px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  overflow-x: auto; /* 表が画面幅を超えても崩れないように */
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 6px;
}

/* 入力欄：font-size を 16px 以上にすると iPhone で拡大ズームされない */
input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid > div { min-width: 0; }

.section-gap { margin-top: 20px; }

.result {
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 700;
  margin: 4px 0 8px;
  word-break: break-all;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.warn {
  color: var(--warn);
  font-size: 14px;
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 15px;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }

/* 狭い画面では1列 */
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; gap: 12px; }
  header { font-size: 17px; }
}

/* 横長のスマホ（横向き）では余白を詰める */
@media (max-height: 500px) and (orientation: landscape) {
  header { padding: 8px 16px; }
  .result { font-size: 28px; }
}

/* FOVスライダー */
input.range {
  min-height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
}

/* 入力欄とボタンの横並び */
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.copy-btn {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--chip);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

/* 結果の数字とコピーボタンを横に並べる */
.result-row { display: flex; align-items: center; gap: 12px; }
.result-row .result { flex: 1; min-width: 0; margin: 0; }

/* ===== サイト共通（ヘッダー・フッター・各ページ） ===== */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.site-header .brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 0;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 10px 2px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }

.tab-nav { margin-top: 12px; }

.site-footer {
  margin-top: 32px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.site-footer a { color: var(--muted); }

.page { padding: 20px 16px 8px; max-width: 760px; margin: 0 auto; }
.page h1 { font-size: 24px; margin: 8px 0 16px; }
.page h2 { font-size: 18px; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.page h3 { font-size: 16px; margin: 18px 0 6px; }
.page p, .page li { line-height: 1.8; font-size: 15px; }
.page ul, .page ol { padding-left: 22px; }
.page a { color: var(--accent); }

.cta {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  margin-top: 12px;
}

.judge-input { max-width: 260px; }
.judge-result { font-size: 26px; font-weight: 700; margin: 14px 0 4px; }
.judge-result small { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.table-wrap { overflow-x: auto; margin-top: 12px; border-radius: 12px; background: var(--card); }
.table-wrap table { margin: 0; }
.table-wrap th, .table-wrap td { text-align: left; white-space: normal; }
.table-wrap tr.current td { background: var(--chip); color: var(--text); font-weight: 700; }

.card-list { display: grid; gap: 12px; margin-top: 12px; }
.card-list .item { background: var(--card); border-radius: 12px; padding: 14px 16px; }
.card-list .item h3 { margin: 0 0 4px; }
.card-list .item p { margin: 0; font-size: 14px; color: var(--muted); }

.contact-box { background: var(--card); border-radius: 12px; padding: 16px; margin-top: 12px; }
.contact-box dt { color: var(--muted); font-size: 13px; margin-top: 10px; }
.contact-box dd { margin: 2px 0 0; font-size: 16px; word-break: break-all; }
.contact-box dd a { color: var(--accent); }

/* ===== 1ページ構成 ===== */
.intro { margin: 4px 0 8px; line-height: 1.8; font-size: 14px; color: var(--muted); }
section.section { margin-top: 28px; scroll-margin-top: 12px; }
section.section > h2, section.card > h2 {
  font-size: 18px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
section.section h3 { font-size: 16px; margin: 18px 0 6px; }
section.section p, section.section li { line-height: 1.8; font-size: 15px; }
section.section ul { padding-left: 22px; }
section.section a { color: var(--accent); }
main#top > section.card { margin-top: 0; }
main#top > section.card + section.card { margin-top: 20px; }
.site-footer a { display: inline-block; min-height: 32px; line-height: 32px; }

/* ===== ページ構成（ページごと） ===== */
.intro { line-height: 1.8; font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.page > h1 { font-size: 22px; margin: 8px 0 14px; }
.page section.section > h2 { font-size: 18px; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.page section.section { margin-top: 28px; scroll-margin-top: 12px; }
.page section.section p, .page section.section li { line-height: 1.8; font-size: 15px; }
.page section.section ul, .page ul.game-list { padding-left: 22px; line-height: 1.9; }
.page section.section h3 { font-size: 16px; margin: 18px 0 6px; }
.page a { color: var(--accent); }
.page > section.card { margin-top: 0; }
.page > section.card + .section { margin-top: 28px; }
a.link-item { display: block; text-decoration: none; color: inherit; }
a.link-item:hover { border-color: var(--accent); }
.card-list a.item { border: 1px solid var(--border); }
.footer-links { line-height: 2; }
.site-footer { margin-top: 40px; }
.contact-box { margin-top: 12px; }

/* 感度変換とFOV・アスペクト比の切り替えボタン */
.switch-row { margin: 4px 0 16px; }
.switch-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--chip);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}
.switch-btn:hover { background: var(--accent); color: #fff; }

/* ===== お問い合わせフォーム ===== */
.lead { line-height: 1.9; font-size: 15px; margin: 4px 0 20px; }
.lead a { color: var(--accent); }
.contact-form { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.contact-form .field label { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.contact-form .help { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }
.contact-form textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
}
.contact-form textarea:focus, .contact-form input:focus, .contact-form select:focus { outline: none; border-color: var(--accent); }
.required { display: inline-block; margin-left: 6px; font-size: 11px; color: #fff; background: #c9485b; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.form-msg { color: var(--warn); font-size: 14px; margin: 0; min-height: 1em; }
.btn-primary {
  align-self: flex-start;
  min-height: var(--tap);
  padding: 10px 28px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary:hover { filter: brightness(1.1); }


/* ===== テーマ（ダーク既定・ライト） ===== */
:root { color-scheme: dark; --chip: var(--chip); }
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #5b6475;
  --border: #d6dbe6;
  --accent: #2563eb;
  --warn: #9a6700;
  --chip: #e8eefc;
}

/* ===== ヘッダーの言語・テーマ ===== */
.header-tools { display: flex; gap: 8px; align-items: center; }
.header-tools .lang-select { width: auto; min-height: 36px; padding: 4px 28px 4px 10px; font-size: 14px; }
.theme-btn {
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

/* ===== 追加の部品 ===== */
.optional { font-size: 12px; color: var(--muted); margin-left: 6px; }
.notice-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}
.result2 { font-size: 22px; font-weight: 700; margin: 4px 0; }
.card-list a.item .open { color: var(--accent); font-size: 14px; font-weight: 700; }

/* ===== ゲーム検索欄・cm表示 ===== */
.search-box { margin-bottom: 6px; font-size: 14px; }
.cm-row { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 4px; }
.cm-row strong { font-size: 18px; }

/* ===== 感度変換ページの切り替えボタン ===== */
.mode-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.mode-btn {
  min-height: var(--tap);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.mode-btn.active { color: var(--text); border-color: var(--accent); background: var(--chip); }

/* デバイスランキング・プロ感度：リンクとバッジ */
.buy-cell { white-space: normal; }
.buy-link {
  display: inline-block; margin: 2px 4px 2px 0; padding: 3px 10px;
  border-radius: 999px; background: var(--chip); color: var(--text);
  font-size: 13px; text-decoration: none;
}
.buy-link:hover { background: var(--accent); color: #fff; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--chip); font-size: 12px; font-weight: 400;
}
