/* ============================================================
   VTSim — Vienna Test System 飛行員潛質測驗模擬器
   仿 SCHUHFRIED VTS 介面風格
   ============================================================ */
:root {
  --vts-green: #76b82a;
  --vts-green-dark: #5a9220;
  --vts-bg: #ececec;
  --vts-panel: #ffffff;
  --vts-text: #2b2b2b;
  --vts-gray: #8a8a8a;
  --vts-blue: #1f6fb2;
  --vts-red: #d23c3c;
  --vts-dark: #101418;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background: var(--vts-bg);
  color: var(--vts-text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- 頂列 ---------- */
.vts-header {
  background: linear-gradient(180deg, #ffffff 0%, #f2f2f2 100%);
  border-bottom: 4px solid var(--vts-green);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  user-select: none;
}
.vts-logo {
  background: var(--vts-green);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 4px;
}
.vts-header h1 { font-size: 20px; font-weight: 600; }
.vts-header .sub { font-size: 12px; color: var(--vts-gray); }
.vts-header .spacer { flex: 1; }

.btn {
  display: inline-block;
  background: var(--vts-green);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
  padding: 10px 26px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--vts-green-dark); }
.btn:disabled { background: #bbb; cursor: default; }
.btn.secondary { background: #fff; color: var(--vts-text); border: 1px solid #c5c5c5; }
.btn.secondary:hover { background: #f0f0f0; }
.btn.big { font-size: 20px; padding: 14px 46px; }
.btn.danger { background: var(--vts-red); }

/* ---------- 主選單 ---------- */
.home-wrap { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; width: 100%; }
.home-intro {
  background: var(--vts-panel);
  border: 1px solid #d8d8d8;
  border-left: 6px solid var(--vts-green);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.8;
  color: #444;
}
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.test-card {
  background: var(--vts-panel);
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  position: relative;
}
.test-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.12); transform: translateY(-2px); }
.test-card .code {
  display: inline-block;
  background: var(--vts-dark);
  color: #9fe04a;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.test-card h3 { font-size: 18px; margin-bottom: 2px; }
.test-card .nick { color: var(--vts-green-dark); font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.test-card p { font-size: 13px; color: #666; line-height: 1.6; }
.test-card .meta { margin-top: 10px; font-size: 12px; color: var(--vts-gray); display: flex; gap: 14px; }
.test-card .best {
  position: absolute; top: 14px; right: 16px;
  font-size: 12px; color: var(--vts-blue); font-weight: 600;
}

/* ---------- 測驗畫面框架 ---------- */
.test-screen {
  flex: 1; display: flex; flex-direction: column;
  min-height: calc(100vh - 0px);
}
.test-topbar {
  background: var(--vts-dark);
  color: #ddd;
  padding: 8px 20px;
  display: flex; align-items: center; gap: 18px;
  font-size: 14px;
  user-select: none;
}
.test-topbar .t-name { font-weight: 700; color: #9fe04a; }
.test-topbar .t-phase { color: #aaa; }
.test-topbar .spacer { flex: 1; }
.test-topbar .t-timer { font-family: Consolas, monospace; font-size: 16px; color: #fff; }
.test-topbar .quit { background: none; border: 1px solid #555; color: #bbb; border-radius: 4px; padding: 3px 12px; cursor: pointer; font-size: 13px; }
.test-topbar .quit:hover { border-color: #d66; color: #f88; }

.test-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.test-body.dark { background: var(--vts-dark); }
.test-body.light { background: #f4f4f4; }

/* ---------- 指導語頁 ---------- */
.instructions {
  max-width: 760px; margin: 30px auto; background: #fff;
  border: 1px solid #d5d5d5; border-radius: 8px; padding: 30px 38px 34px;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.instructions h2 { font-size: 24px; margin-bottom: 4px; }
.instructions .en { color: var(--vts-gray); font-size: 14px; margin-bottom: 18px; }
.instructions p, .instructions li { font-size: 15px; line-height: 1.9; color: #333; }
.instructions ul, .instructions ol { margin: 8px 0 8px 24px; }
.instructions .hl { background: #eef7e2; border-left: 4px solid var(--vts-green); padding: 10px 14px; border-radius: 4px; margin: 14px 0; font-size: 14px; }
.instructions .keymap { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.instructions .actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 8px;
  background: linear-gradient(180deg,#fff,#e3e3e3);
  border: 1px solid #aaa; border-bottom-width: 3px; border-radius: 6px;
  font-family: Consolas, monospace; font-weight: 700; font-size: 15px;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.keymap-item { display: flex; align-items: center; gap: 7px; font-size: 14px; background:#fafafa; border:1px solid #e2e2e2; border-radius:6px; padding:6px 10px; }
.cdot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.25); }

/* ---------- 結果頁 ---------- */
.result-box {
  max-width: 700px; margin: 36px auto; background: #fff;
  border: 1px solid #d5d5d5; border-radius: 8px; padding: 28px 36px;
}
.result-box h2 { color: var(--vts-green-dark); margin-bottom: 16px; }
table.stats { width: 100%; border-collapse: collapse; margin: 12px 0 18px; }
table.stats th, table.stats td { border: 1px solid #ddd; padding: 9px 14px; font-size: 15px; text-align: left; }
table.stats th { background: #f3f7ec; width: 46%; font-weight: 600; }
.verdict { font-size: 15px; line-height: 1.8; background: #f8f8f8; border-radius: 6px; padding: 12px 16px; margin-bottom: 18px; }
.verdict.good { background: #eef7e2; }
.verdict.bad { background: #fbeeee; }

/* ---------- DT 決斷測驗 ---------- */
.dt-stage { display: flex; flex-direction: column; align-items: center; gap: 38px; padding: 30px 0 10px; }
.dt-lights { display: grid; grid-template-columns: repeat(5, 84px); gap: 26px; }
.dt-circle {
  width: 84px; height: 84px; border-radius: 50%;
  background: #23282e; border: 3px solid #3a414a;
  transition: background .04s;
}
.dt-bottom { display: flex; gap: 320px; align-items: center; }
.dt-pedal {
  width: 150px; height: 64px; border-radius: 8px;
  background: #23282e; border: 3px solid #3a414a;
  display: flex; align-items: center; justify-content: center;
  color: #5a6470; font-size: 13px; letter-spacing: 2px;
}
.dt-pedal.on { background: #e8e8e8; border-color: #fff; color: #333; }
.dt-tonebox { display: flex; gap: 18px; }
.dt-tone {
  width: 70px; height: 64px; border-radius: 8px; background: #1a1f24;
  border: 2px dashed #39414b; color: #56606c; font-size: 12px;
  display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center;
}
.dt-tone.on { border-color: #ffd24a; color: #ffd24a; }
.dt-keylegend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; padding: 10px 0 26px; }
.dt-keylegend .keymap-item { background: #1b2026; border-color: #333a43; color: #cfd6de; }
.dt-keylegend .key { background: linear-gradient(180deg,#3a424c,#272d34); color: #eee; border-color: #555e69; }
.dt-hud { position: absolute; top: 14px; right: 22px; color: #8fa0b3; font-family: Consolas, monospace; font-size: 14px; text-align: right; line-height: 1.7; }
.dt-feedback { position: absolute; top: 14px; left: 22px; font-size: 26px; font-weight: 800; width: 50px; }

/* ---------- 通用 canvas 測驗 ---------- */
canvas.test-canvas { background: var(--vts-dark); border-radius: 8px; }
canvas.test-canvas.light { background: #fff; border: 1px solid #ccc; }

/* ---------- SIMKAP ---------- */
.simkap-wrap { display: flex; gap: 22px; width: 100%; max-width: 1180px; padding: 18px; align-items: flex-start; }
.simkap-left { flex: 1.25; background: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 14px 18px; }
.simkap-left h4 { font-size: 14px; color: #555; margin-bottom: 10px; }
.simkap-target { font-family: Consolas, monospace; font-size: 22px; font-weight: 800; color: var(--vts-red); letter-spacing: 2px; }
.simkap-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed #eee; }
.simkap-row.done { opacity: .35; }
.simkap-cells { display: flex; gap: 5px; flex: 1; }
.simkap-sep { width: 2px; align-self: stretch; background: #d0d0d0; }
.simkap-num {
  font-family: Consolas, monospace; font-size: 17px; text-align: center;
  padding: 6px 5px; border: 1px solid #e0e0e0; border-radius: 5px;
  user-select: none; background: #fafafa; flex: 1;
}
.simkap-num.ro { cursor: default; }
.simkap-num.mark { border: 2px solid var(--vts-red); background: #fff5f5; font-weight: 700; }
.simkap-num.clickable { cursor: pointer; }
.simkap-num.clickable:hover { background: #eef4ff; }
.simkap-num.struck { text-decoration: line-through; color: #bbb; background: #f1f1f1; }
.simkap-num.struck.wrong { color: #d66; background: #fdecec; }
.simkap-right { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.simkap-task {
  background: #fff8e6; border: 2px solid #e8c860; border-radius: 8px; padding: 16px 18px;
  font-size: 17px; line-height: 1.7; min-height: 110px;
}
.simkap-task.idle { background: #f4f4f4; border-color: #ddd; color: #999; font-size: 14px; }
.simkap-answer { display: flex; gap: 8px; margin-top: 12px; }
.simkap-answer input {
  flex: 1; font-size: 22px; font-family: Consolas, monospace; padding: 8px 12px;
  border: 2px solid #bbb; border-radius: 6px; text-align: center;
}
.simkap-tools { display: flex; gap: 10px; }
.simkap-popup {
  background: #fff; border: 1px solid #bbb; border-radius: 8px; padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px;
}
.simkap-popup table { border-collapse: collapse; width: 100%; }
.simkap-popup td, .simkap-popup th { border: 1px solid #e3e3e3; padding: 4px 8px; text-align: center; font-size: 13px; }
.simkap-stats { font-size: 13px; color: #777; }

/* ---------- PST ---------- */
.pst-progress { color: #8fa0b3; font-size: 14px; }
.pst2-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 10px 30px; }
.pst2-cards { display: flex; align-items: center; gap: 26px; }
.pst2-card {
  background: #fff; border: 1px solid #d5d5d5; border-radius: 8px; overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.pst2-cap {
  text-align: center; font-weight: 600; font-size: 16px; padding: 8px 0;
  border-bottom: 1px solid #e5e5e5; color: #333;
}
.pst2-card canvas { display: block; }
.pst2-arrow { font-size: 38px; color: #b5b5b5; }
.pst2-q { font-size: 17px; color: #444; margin-top: 6px; }
.pst2-panel {
  display: grid;
  grid-template-areas:
    ". top ."
    "l1 mid r1"
    "l2 mid r2"
    ". bot .";
  grid-template-columns: 220px 340px 220px;
  align-items: center; justify-items: center; gap: 10px 14px;
  background: #7d8288; border-radius: 10px; padding: 16px 18px;
}
.c-top { grid-area: top; } .c-bot { grid-area: bot; }
.c-l1 { grid-area: l1; justify-self: end; } .c-r1 { grid-area: r1; justify-self: start; }
.c-l2 { grid-area: l2; justify-self: end; } .c-r2 { grid-area: r2; justify-self: start; }
.c-mid { grid-area: mid; }
.c-mid canvas { border-radius: 6px; }
.pst2-opt {
  display: inline-flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid #ccc; border-radius: 8px;
  font-family: inherit; font-size: 15px; font-weight: 600; color: #333;
  padding: 10px 16px; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.pst2-opt:hover { border-color: #999; }
.pst2-opt .radio {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid #888; background: #fff;
}
.pst2-opt.sel { border-color: var(--vts-green); }
.pst2-opt.sel .radio { border-color: var(--vts-green); background: radial-gradient(circle at center, var(--vts-green) 0 55%, #fff 60%); }
.pst2-opt .key { transform: scale(.8); opacity: .7; }

/* ---------- 人格測驗 ---------- */
.pers-wrap { max-width: 720px; margin: 26px auto; background: #fff; border: 1px solid #d5d5d5; border-radius: 8px; padding: 30px 38px; width: 92%; }
.pers-q { font-size: 20px; line-height: 1.8; min-height: 90px; margin: 10px 0 24px; }
.pers-opts { display: flex; gap: 14px; }
.pers-opts .btn { flex: 1; font-size: 18px; padding: 14px 0; }
.pers-progress { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.pers-progress div { height: 100%; background: var(--vts-green); transition: width .2s; }

/* ---------- 記憶測驗 ---------- */
.mem-grid { display: grid; gap: 10px; }
.mem-cell {
  width: 92px; height: 92px; background: #fff; border: 2px solid #ccc; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 44px; cursor: pointer;
  user-select: none;
}
.mem-cell:hover { border-color: var(--vts-green); }
.mem-cell.empty { background: #f0f0f0; }
.mem-q { font-size: 20px; margin: 18px 0; text-align: center; }

/* ---------- 浮動回饋 ---------- */
.flash-fb {
  position: fixed; top: 46%; left: 50%; transform: translate(-50%,-50%);
  font-size: 54px; font-weight: 900; pointer-events: none; z-index: 99;
  animation: fbpop .55s ease-out forwards;
}
@keyframes fbpop { 0% {opacity:0; transform:translate(-50%,-50%) scale(.6);} 20% {opacity:1; transform:translate(-50%,-50%) scale(1.1);} 100% {opacity:0; transform:translate(-50%,-58%) scale(1);} }

.footer-note { text-align: center; font-size: 12px; color: #999; padding: 20px; line-height: 1.7; }

/* 成績紀錄 */
.history-wrap { max-width: 900px; margin: 26px auto; width: 94%; }
.history-wrap table { width: 100%; border-collapse: collapse; background: #fff; }
.history-wrap th, .history-wrap td { border: 1px solid #ddd; padding: 8px 12px; font-size: 14px; }
.history-wrap th { background: #f3f7ec; }

/* ============================================================
   RWD 響應式(平板/手機)
   ============================================================ */
canvas.test-canvas { max-width: calc(100vw - 16px); height: auto; }
.pst2-card canvas { max-width: 42vw; height: auto; }
.key, .tk { touch-action: none; user-select: none; -webkit-user-select: none; }
.tk { cursor: pointer; }
.tk:active { background: linear-gradient(180deg,#d8e8c0,#bcd89a); }

@media (max-width: 900px) {
  .vts-header { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .vts-header h1 { font-size: 17px; }
  .vts-header .sub { font-size: 11px; }
  .btn { font-size: 14px; padding: 8px 14px; }
  .btn.big { font-size: 17px; padding: 12px 26px; }
  .home-wrap { padding: 14px 10px 40px; }
  .test-grid { grid-template-columns: 1fr; }
  .instructions { padding: 18px 16px 22px; margin: 12px auto; width: 94%; }
  .instructions h2 { font-size: 20px; }
  .instructions p, .instructions li { font-size: 14px; }
  .test-topbar { flex-wrap: wrap; padding: 6px 10px; gap: 8px; font-size: 12px; }
  .key { min-width: 30px; height: 30px; font-size: 13px; }
  .result-box { padding: 18px 14px; width: 94%; margin: 16px auto; }
  table.stats th, table.stats td { font-size: 13px; padding: 7px 8px; }

  /* DT 打地鼠 */
  .dt-stage { gap: 20px; padding: 14px 0 4px; }
  .dt-lights { grid-template-columns: repeat(5, 15vw); gap: 3vw; }
  .dt-circle { width: 15vw; height: 15vw; }
  .dt-bottom { gap: 12vw; }
  .dt-pedal { width: 34vw; height: 52px; font-size: 11px; letter-spacing: 0; }
  .dt-tone { width: 60px; height: 52px; font-size: 10px; }
  .dt-keylegend { gap: 8px; padding: 8px 4px 18px; }
  .dt-keylegend .key { min-width: 42px; height: 42px; font-size: 16px; }
  .dt-keylegend .keymap-item { padding: 5px 7px; }
  .dt-hud { font-size: 11px; top: 6px; right: 8px; }
  .dt-feedback { font-size: 20px; top: 6px; left: 8px; }

  /* SIMKAP 刪數字 */
  .simkap-wrap { flex-direction: column; padding: 10px; gap: 12px; }
  .simkap-left { padding: 10px; }
  .simkap-num { font-size: 14px; padding: 5px 1px; }
  .simkap-target { font-size: 18px; }

  /* PST 飛機三軸 */
  .pst2-wrap { padding: 10px 4px 24px; gap: 10px; }
  .pst2-cards { gap: 8px; }
  .pst2-arrow { font-size: 22px; }
  .pst2-cap { font-size: 13px; padding: 5px 0; }
  .pst2-q { font-size: 14px; text-align: center; }
  .pst2-panel {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "mid mid" "top top" "l1 r1" "l2 r2" "bot bot";
    width: 96vw; padding: 10px; gap: 8px;
  }
  .c-top, .c-bot, .c-l1, .c-l2, .c-r1, .c-r2 { justify-self: stretch; }
  .pst2-opt { width: 100%; justify-content: flex-start; font-size: 14px; padding: 12px 10px; }
  .c-mid canvas { max-width: 72vw; height: auto; }

  /* MEM 記憶 */
  .mem-cell { font-size: clamp(24px, 9vw, 44px); }

  /* PERS 人格 */
  .pers-wrap { padding: 18px 14px; width: 94%; margin: 14px auto; }
  .pers-q { font-size: 17px; min-height: 70px; }
  .pers-opts { gap: 8px; }
  .pers-opts .btn { font-size: 16px; padding: 12px 0; }

  /* SMK 觸控按鍵 */
  .smk-touch .tk { min-width: 48px; height: 48px; font-size: 19px; margin: 0 2px; }

  .history-wrap th, .history-wrap td { font-size: 12px; padding: 5px 6px; }
  .footer-note { font-size: 11px; padding: 14px 10px; }
}
