/* 色・フォント・パタパタ表示は IATAクイズ（apps/iata-quiz/public/style.css）と同じ */
:root {
  --paper: #FFFFFF;
  --surface: #F2F3F1;
  --ink: #15171C;
  --muted: #5A606B;
  --line: #D5D8DC;
  --flap: #1F2228;
  --flap-ink: #F4F1E6;
  --signal: #FFC527;
  --ok: #17784A;
  --ok-soft: #E7F4EC;
  --ng: #C0322B;
  --ng-soft: #FBEAE8;

  --font-body: "Noto Sans JP", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "Noto Sans JP", sans-serif;
  --font-code: "IBM Plex Mono", ui-monospace, monospace;

  --r-s: 8px;
  --r-m: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}
button { font: inherit; color: inherit; }
button, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.lucide { width: 1.1em; height: 1.1em; stroke-width: 2; flex: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--signal); }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 48px;
  min-height: 100dvh;
}
.screen-enter { animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- labels ---------- */
.eyebrow {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 28px 0 8px;
  font-size: 14px;
  font-weight: 700;
}
.section-label .eyebrow { font-size: 14px; }

/* ---------- split-flap ---------- */
.flap { display: flex; justify-content: center; gap: 8px; }
.flap-tile {
  position: relative;
  width: clamp(64px, 20vw, 92px);
  aspect-ratio: 3 / 4;
  background: var(--flap);
  color: var(--flap-ink);
  border-radius: var(--r-s);
  display: grid;
  place-items: center;
  font-family: var(--font-code);
  font-weight: 700;
  font-size: clamp(46px, 14vw, 68px);
  line-height: 1;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .35), 0 2px 6px rgba(21, 23, 28, .18);
  perspective: 300px;
  overflow: hidden;
}
.flap-tile::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  margin-top: -1px;
  background: rgba(0, 0, 0, .55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.flap-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 50% 0;
  background: linear-gradient(rgba(255, 255, 255, .05), rgba(255, 255, 255, 0));
}
.flap-char { display: block; transform-origin: 50% 50%; }
.flap-char.tick { animation: tick 70ms linear; }
@keyframes tick {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(80deg); opacity: .4; }
  100% { transform: rotateX(0); }
}
.flap-tile.is-blank { background: #2A2D34; }
.flap.sm { gap: 4px; }
.flap.sm .flap-tile { width: 34px; font-size: 26px; border-radius: 4px; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35); }
.flap.sm .flap-tile::after { height: 1px; margin-top: 0; }

/* ---------- controls ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--r-m);
  margin: 0;
  border: 0;
  min-width: 0;
}
.segmented label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 4px;
  border-radius: var(--r-s);
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
}
.segmented label small { font-size: 11px; font-weight: 400; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(21, 23, 28, .16); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--ink); box-shadow: 0 0 0 6px var(--signal); }
.segmented label.is-off { color: #A3A8B0; cursor: not-allowed; }
.segmented label.is-off span { text-decoration: line-through; text-decoration-thickness: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 24px;
  border-radius: var(--r-m);
  border: 1px solid var(--ink);
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s var(--ease), background-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; background: var(--surface); border-color: var(--line); color: var(--muted); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-ghost { border-color: transparent; background: transparent; min-height: 44px; padding: 8px 12px; }
.btn-block { width: 100%; }
.start { margin-top: 32px; }
.list-link { margin-top: 12px; }
.kbd-hint { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
kbd {
  font-family: var(--font-code);
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper);
}
.mouse-only { display: none; }
@media (hover: hover) and (pointer: fine) { .mouse-only { display: block; } }

/* ---------- route（T20 > T11 > D14） ---------- */
.route { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.seg-code { font-family: var(--font-code); font-weight: 700; }
.route-sep { width: 14px; height: 14px; color: var(--muted); }

/* ---------- home ---------- */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 16px; border-radius: 999px; background: var(--surface); }
.lang-switch button { border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(21, 23, 28, .16); }
.home-hero { padding: 24px 0 8px; text-align: center; }
.home-hero h1 { font-size: 30px; line-height: 1.3; margin: 8px 0 24px; letter-spacing: .02em; }
.hero-caption { margin: 16px 0 0; min-height: 1.6em; color: var(--muted); font-size: 15px; display: flex; justify-content: center; align-items: center; gap: 8px; }
.hero-caption .route { color: var(--ink); }
.recent { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.recent li { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recent-score b { font-family: var(--font-code); font-size: 20px; }
.recent-score small { margin-left: 4px; font-size: 12px; color: var(--muted); }
.more-apps { margin: 24px 0 0; text-align: center; font-size: 13px; }
.more-apps a { color: var(--muted); text-underline-offset: 3px; }

/* ---------- quiz ---------- */
.quiz-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -12px; }
.quiz-bar .btn { white-space: nowrap; }
.quiz-meta { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 700; color: var(--muted); }
.quiz-count { font-family: var(--font-code); font-weight: 700; font-size: 15px; padding-right: 12px; }
.progress { height: 4px; background: var(--surface); border-radius: 2px; margin: 8px 0 16px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); transition: width .4s var(--ease); }

.quiz-grid { display: grid; gap: 16px; }
.scorebox { text-align: center; position: relative; }
.scorebox .eyebrow { margin-bottom: 8px; }
.darts-left { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.dart-pip {
  width: 30px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #5D636C 0 55%, #1B1D21 55% 75%, var(--signal) 75%);
  transition: opacity .2s;
}
.dart-pip.is-used { opacity: .18; }
.multi-badge {
  display: inline-block; margin: 10px 0 0; padding: 2px 10px;
  border: 1px solid var(--ink); border-radius: 999px;
  font-size: 13px; font-weight: 700;
}
.bust { position: absolute; left: 0; right: 0; bottom: -28px; margin: 0; font-size: 14px; font-weight: 700; color: var(--ng); }

.board-wrap { display: grid; place-items: center; }
.board-svg { width: min(100%, 52dvh, 520px); height: auto; display: block; filter: drop-shadow(0 6px 14px rgba(21, 23, 28, .22)); overflow: visible; }
.board-svg .holes { fill: url(#holes); pointer-events: none; }
.board-svg pattern circle { fill: rgba(0, 0, 0, .3); }
.board-svg .numbers text {
  fill: #F4F1E6; font-family: var(--font-display); font-weight: 700; font-size: 19px;
  text-anchor: middle; dominant-baseline: central;
}
.board-svg .flash { pointer-events: none; opacity: 0; animation: flash .9s var(--ease); }
.board-svg .flash-hit { fill: #FFFFFF; }
.board-svg .flash-ok { fill: #3FD58A; animation-duration: 1.3s; }
.board-svg .flash-ng { fill: #FF5A4E; animation-duration: 1.3s; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: .7; } 100% { opacity: 0; } }

.prompt { margin: 0 0 4px; font-size: 17px; text-align: center; }
.multi { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.option {
  width: 100%;
  display: grid;
  grid-template-columns: 26px 1fr 20px;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px 10px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, opacity .2s;
}
.option:not(:disabled):hover { border-color: var(--ink); }
.option:not(:disabled):active { transform: scale(.99); }
.option:disabled { cursor: default; }
.option-key {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  background: var(--surface); font-family: var(--font-code); font-size: 13px; font-weight: 700;
}
.option-body { display: grid; min-width: 0; }
.option-code { font-family: var(--font-code); font-weight: 700; font-size: 22px; line-height: 1.2; }
.option-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.option-mark { display: grid; place-items: center; }
.option.is-dim { opacity: .4; }
.option.is-correct { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.option.is-correct .option-key { background: var(--ok); color: #fff; }
.option.is-correct .option-mark { color: var(--ok); }
.option.is-also { border-color: var(--ok); border-style: dashed; }
.option.is-wrong { border-color: var(--ng); background: var(--ng-soft); box-shadow: inset 0 0 0 1px var(--ng); animation: shake .3s var(--ease); }
.option.is-wrong .option-key { background: var(--ng); color: #fff; }
.option.is-wrong .option-mark { color: var(--ng); }
/* 「上がれない」は一番下に横長で。その時は区画の3択を1段に並べる */
.options.has-no { grid-template-columns: repeat(3, 1fr); }
.options .no-out { grid-column: 1 / -1; }
.no-out-text { font-family: var(--font-body); font-size: 18px; }
@media (max-width: 479px) { .options.has-no .option { grid-template-columns: 22px 1fr; padding: 8px 6px; } .options.has-no .option-mark { display: none; } .options.has-no .option-code { font-size: 19px; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.thrown { display: flex; justify-content: center; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.thrown li {
  min-width: 64px; padding: 4px 8px; border-radius: 6px; text-align: center;
  font-family: var(--font-code); font-weight: 700; font-size: 15px;
  background: var(--surface); color: var(--muted);
}
.thrown li.is-now { box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.thrown li.is-ok { background: var(--ok-soft); color: var(--ok); }
.thrown li.is-ng { background: var(--ng-soft); color: var(--ng); }
.unreg { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.unreg .lucide { margin-top: 3px; }

.gameshot { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 0 0 12px; }
.gameshot span { font-family: var(--font-display); font-weight: 700; font-size: 34px; letter-spacing: .08em; }
.gameshot small { font-size: 14px; font-weight: 700; }
.gameshot.ok small { color: var(--ok); }
.gameshot.ng small { color: var(--ng); }
.steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.steps li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.step-state b { font-family: var(--font-code); margin-left: 6px; }
.step-pick { display: flex; align-items: center; gap: 6px; font-family: var(--font-code); font-weight: 700; }
.steps .is-ok .step-pick { color: var(--ok); }
.steps .is-ng .step-pick { color: var(--ng); }
.step-pick s { color: var(--muted); }
.reason { margin-top: 14px; padding: 12px 14px; background: var(--surface); border-radius: var(--r-m); }
.reason-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; }
.reason-key { font-size: 12px; color: var(--muted); }
.reason-key b { font-family: var(--font-code); font-size: 18px; color: var(--ink); margin-right: 4px; }
.reason-text { margin: 6px 0 0; font-size: 15px; line-height: 1.7; white-space: pre-wrap; }
.reason-alt { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.next-bar { margin-top: 16px; }

/* ---------- result ---------- */
.result-main { text-align: center; padding-top: 16px; }
.result-score { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 12px 0 20px; font-weight: 700; }
.result-actions { display: grid; gap: 8px; }
.result-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.result-list > li { border-bottom: 1px solid var(--line); }
.result-list summary { display: flex; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer; list-style: none; }
.result-list summary::-webkit-details-marker { display: none; }
.result-list summary b { font-family: var(--font-code); font-size: 18px; }
.result-list summary small { font-size: 12px; color: var(--muted); }
.result-list summary .route { margin-left: auto; }
.result-list summary.is-ok > .lucide { color: var(--ok); }
.result-list summary.is-ng > .lucide { color: var(--ng); }
.result-list details[open] { padding-bottom: 12px; }

/* ---------- search ---------- */
.list-title { font-size: 26px; margin: 12px 0 16px; }
.search-controls { display: grid; gap: 8px; }
.search-result { margin-top: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-m); min-height: 96px; }
.search-head { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.search-head .flap { justify-content: flex-start; }
.routes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 20px; }
.search-result .multi-badge { margin-top: 12px; }
.empty { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.legend { display: flex; gap: 10px; font-size: 12px; font-weight: 400; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
.lg-reg::before { background: var(--ink); }
.lg-open::before { border: 1px solid var(--ink); }
.lg-out::before { background: var(--surface); }
.coverage { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.coverage button {
  width: 100%; aspect-ratio: 1; padding: 0; border-radius: 4px; cursor: pointer;
  font-family: var(--font-code); font-weight: 700; font-size: clamp(10px, 2.9vw, 13px);
}
.coverage .is-reg { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.coverage .is-open { background: var(--paper); color: var(--ink); border: 1px solid #9DA3AC; }
.coverage .is-out { background: var(--surface); color: #B4B8BF; border: 1px solid transparent; text-decoration: line-through; cursor: not-allowed; }
.coverage .is-sel { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--signal); position: relative; z-index: 1; }

/* ---------- スマホ：背の低い機種は詰める ---------- */
@media (max-width: 719px) {
  .start-bar, .next-bar {
    position: sticky; bottom: 0; z-index: 2;
    margin: 16px -16px 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    background: linear-gradient(rgba(255, 255, 255, 0), var(--paper) 30%);
  }
  .start { margin-top: 0; }
}
@media (max-width: 479px) { .sub-label { display: none; } }
@media (max-width: 719px) and (max-height: 740px) {
  .scorebox .eyebrow { display: none; }
  .flap-tile { width: 54px; font-size: 40px; }
  .board-svg { width: min(100%, 46dvh); }
  .option { min-height: 56px; }
}

@media (min-width: 720px) {
  .app { max-width: 720px; padding-top: 32px; }
}

/* ---------- PC：左にボード、右に点数と4択 ---------- */
@media (min-width: 1024px) {
  .app { max-width: 1120px; padding: 48px 40px 64px; }
  .home { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 80px; align-items: start; }
  .home-hero { position: sticky; top: 48px; padding: 40px 0 0; text-align: left; }
  .home-hero h1 { font-size: 48px; margin: 12px 0 40px; }
  .home-hero .flap { justify-content: flex-start; gap: 10px; }
  .home-hero .flap-tile { width: 124px; font-size: 92px; border-radius: 10px; }
  .hero-caption { justify-content: flex-start; font-size: 17px; }
  #setup > .section-label:first-child { margin-top: 0; }

  .quiz-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "board score" "board panel";
    grid-template-rows: auto 1fr;
    column-gap: 56px;
    row-gap: 24px;
    align-items: start;
  }
  .scorebox { grid-area: score; }
  .board-wrap { grid-area: board; }
  .panel { grid-area: panel; }
  .board-svg { width: min(100%, 640px, calc(100dvh - 180px)); }
  .options, .options.has-no { grid-template-columns: 1fr; }
  .option { min-height: 60px; }

  .result { display: grid; grid-template-columns: 340px minmax(0, 1fr); column-gap: 80px; align-items: start; }
  .result-main { position: sticky; top: 48px; text-align: left; }
  .result-score { justify-content: flex-start; }
  .result-review .section-label { margin-top: 0; }

  .search-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 48px; align-items: start; }
  .search-controls { position: sticky; top: 24px; }
  .search-grid .section-label { margin-top: 0; }
  .coverage { grid-template-columns: repeat(15, 1fr); }
  .coverage button { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
