/* 句子小偵探：深夜偵探事務所、芥末黃檔案夾與紙張證物。 */
:root {
  --bg: #081522;
  --bg-2: #12263a;
  --ink: #101828;
  --muted: #5d6472;
  --accent: #ffc145;
  --accent-2: #4ecdc4;
  --accent-3: #f1d79a;
  --good: #238b7c;
  --bad: #c94f5f;
  --card: #fffaf0;
  --line: #12263a;
  --line-soft: rgba(18, 38, 58, 0.18);
  --paper: #f7f0e0;
  --paper-deep: #eadcc0;
  --stamp: #b6404e;
  --shadow: 0 8px 0 rgba(4, 12, 20, 0.34), 0 24px 50px rgba(4, 12, 20, 0.4);
  --shadow-sm: 0 5px 0 rgba(4, 12, 20, 0.26);
  --radius: 24px;
  --radius-sm: 14px;
}

body {
  color: var(--paper);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 12% -6%, rgba(78, 205, 196, 0.2), transparent 42%),
    radial-gradient(ellipse at 88% 4%, rgba(255, 193, 69, 0.16), transparent 38%),
    radial-gradient(ellipse at 50% 110%, rgba(255, 193, 69, 0.1), transparent 55%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 10px);
  background-attachment: fixed;
}

/* 指紋與放大鏡的淡淡痕跡 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-radial-gradient(circle at 4% 96%, rgba(78, 205, 196, 0.055) 0 1px, transparent 1px 13px),
    repeating-radial-gradient(circle at 97% 8%, rgba(255, 193, 69, 0.05) 0 1px, transparent 1px 15px);
}

.topbar {
  z-index: 50;
  background: rgba(7, 18, 30, 0.94);
  border-bottom: 2px solid rgba(255, 193, 69, 0.38);
  color: var(--paper);
}

.brand-name {
  color: var(--paper);
  letter-spacing: 0.06em;
}

.brand-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 193, 69, 0.18);
}

.icon-btn {
  border-color: rgba(7, 18, 30, 0.9);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(255, 193, 69, 0.3);
}

.icon-btn:hover {
  background: var(--accent);
}

.icon-btn-zhuyin {
  background: rgba(255, 193, 69, 0.18);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn-zhuyin[aria-pressed="false"] {
  background: rgba(255, 250, 240, 0.08);
  color: rgba(247, 240, 224, 0.55);
}

/* 每一個畫面都是一份攤在桌上的案件檔案 */
.screen {
  position: relative;
  margin: clamp(34px, 5vw, 46px) auto 30px;
  padding: clamp(20px, 3.4vw, 40px);
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 0%, rgba(255, 193, 69, 0.2), transparent 28%),
    repeating-linear-gradient(0deg, rgba(18, 38, 58, 0.035) 0 1px, transparent 1px 27px),
    var(--paper);
  border: 3px solid var(--line);
  border-radius: 8px 28px 28px 28px;
  box-shadow: var(--shadow);
}

.screen::before {
  content: "01";
  position: absolute;
  top: -30px;
  left: 22px;
  display: grid;
  place-items: center;
  width: 96px;
  height: 30px;
  border: 3px solid var(--line);
  border-bottom: 0;
  border-radius: 13px 13px 0 0;
  background: var(--accent);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

#screen-levels::before {
  content: "02";
}

#screen-play::before {
  content: "03";
}

#screen-result::before {
  content: "04";
}

.screen::after {
  content: "";
  position: absolute;
  top: -13px;
  right: 30px;
  width: 92px;
  height: 24px;
  border: 2px solid rgba(18, 38, 58, 0.28);
  background: rgba(255, 193, 69, 0.62);
  transform: rotate(3deg);
  box-shadow: 0 2px 0 rgba(18, 38, 58, 0.12);
}

.eyebrow {
  color: #0f766e;
  letter-spacing: 0.2em;
}

.hero {
  min-height: min(62vh, 560px);
}

.hero-copy {
  padding-left: clamp(10px, 2vw, 22px);
  border-left: 6px solid var(--accent);
}

.hero-title {
  color: var(--line);
  text-shadow: 3px 3px 0 rgba(255, 193, 69, 0.45);
}

.hero-desc {
  color: #46505f;
}

.hero-meta {
  display: inline-flex;
  padding: 4px 12px;
  border: 2px dashed rgba(18, 38, 58, 0.35);
  border-radius: 999px;
  color: #344052;
}

.hero-blob {
  inset: 6% 3%;
  border: 12px solid var(--accent);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.96), transparent 36%),
    radial-gradient(circle at 50% 60%, #e5f7f4, #b9e6e0 72%, #8fd3cb);
  box-shadow:
    0 0 0 4px var(--line),
    0 0 0 9px rgba(255, 193, 69, 0.3),
    0 20px 38px rgba(18, 38, 58, 0.22);
  transform: rotate(-2deg);
}

.hero-art::after {
  content: "";
  position: absolute;
  right: 5%;
  bottom: 13%;
  z-index: 0;
  width: 23%;
  height: 9%;
  border: 4px solid var(--line);
  border-radius: 999px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 4px 0 rgba(18, 38, 58, 0.2);
}

.hero-art img {
  filter: drop-shadow(0 18px 20px rgba(18, 38, 58, 0.24));
}

.hero-sticker {
  right: 0;
  bottom: 2%;
  border-color: var(--line);
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--line);
  transform: rotate(-6deg);
}

.howto {
  position: relative;
  background:
    linear-gradient(90deg, rgba(78, 205, 196, 0.12), transparent 32%),
    var(--card);
  border-radius: 6px 22px 22px 22px;
}

.howto::before {
  content: "";
  position: absolute;
  top: 16px;
  right: 22px;
  width: 34px;
  height: 34px;
  border: 4px solid var(--accent-2);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--line);
}

.howto::after {
  content: "";
  position: absolute;
  top: 45px;
  right: 14px;
  width: 17px;
  height: 8px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--accent);
  transform: rotate(45deg);
}

.howto-list li::marker {
  color: #0f766e;
  font-weight: 900;
}

.howto-tip {
  padding-top: 10px;
  border-top: 2px dashed rgba(18, 38, 58, 0.2);
}

/* 按鈕像貼上標籤的證物卡 */
.btn {
  border-radius: 14px;
  box-shadow: 0 5px 0 var(--line);
}

.btn-primary {
  color: var(--ink);
  background: var(--accent);
}

.btn-primary:hover {
  background: #ffd06e;
}

.btn-soft {
  background: #dff5f1;
}

.btn-ghost {
  background: var(--card);
}

.btn-danger {
  background: #fbe3e5;
  color: #8d2230;
}

/* 關卡選單：一疊檔案夾 */
.level-card {
  min-height: 142px;
  border-radius: 6px 18px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent 40%),
    linear-gradient(145deg, #fffdf7, #f1e4c8);
  box-shadow: 0 5px 0 rgba(18, 38, 58, 0.2);
}

.level-card::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 16px;
  width: 54px;
  height: 13px;
  border: 3px solid var(--line);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--accent);
}

.level-card:not(:disabled):hover {
  transform: translateY(-4px) rotate(-0.8deg);
  box-shadow: 0 9px 0 rgba(18, 38, 58, 0.24);
}

.level-card[data-current="true"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 45%),
    linear-gradient(145deg, #fff6d9, #f3dfa6);
}

.level-num {
  background: var(--line);
  color: var(--accent);
  border-radius: 8px;
  letter-spacing: 0.08em;
}

.level-name {
  color: var(--line);
}

.level-goal {
  color: #56606e;
}

.level-stars .on {
  color: #d99700;
  text-shadow: 0 2px 0 rgba(18, 38, 58, 0.25);
}

.level-lock {
  top: 10px;
  right: 10px;
  filter: grayscale(0.2);
}

.levels-foot {
  padding-top: 12px;
  border-top: 2px dashed rgba(18, 38, 58, 0.22);
  color: #46505f;
}

/* 遊玩畫面 */
.play-kicker {
  color: #0f766e;
  letter-spacing: 0.16em;
}

.play-title {
  color: var(--line);
}

.play-objective {
  color: #4d5765;
}

.hud-item {
  position: relative;
  border-radius: 6px 12px 12px 12px;
  background: var(--card);
  box-shadow: 0 3px 0 rgba(18, 38, 58, 0.18);
}

.hud-item::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
}

.hud-label {
  color: #5d6472;
}

.hud-item strong {
  color: var(--line);
}

.timer {
  height: 22px;
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: inset 0 2px 0 rgba(18, 38, 58, 0.08);
}

.timer-fill {
  border-radius: 5px;
  background:
    repeating-linear-gradient(90deg, rgba(18, 38, 58, 0.18) 0 1px, transparent 1px 16px),
    linear-gradient(90deg, var(--accent-2), var(--accent) 72%, #f09b45);
}

.timer.is-low .timer-fill {
  background:
    repeating-linear-gradient(90deg, rgba(18, 38, 58, 0.18) 0 1px, transparent 1px 16px),
    linear-gradient(90deg, #f0a35a, var(--bad));
}

.q-dot {
  height: 8px;
  border: 1px solid rgba(18, 38, 58, 0.12);
  border-radius: 3px;
}

.q-dot.done {
  background: var(--accent-2);
}

.q-dot.now {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(18, 38, 58, 0.18);
}

.question-host {
  position: relative;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 193, 69, 0.18), transparent 25%),
    repeating-linear-gradient(0deg, rgba(18, 38, 58, 0.028) 0 1px, transparent 1px 25px),
    var(--card);
  border-radius: 6px 26px 26px 26px;
  box-shadow: 0 7px 0 rgba(18, 38, 58, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.question-host::after {
  content: "";
  position: absolute;
  top: -20px;
  right: -18px;
  width: 62px;
  height: 62px;
  border: 8px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--line);
  opacity: 0.9;
  pointer-events: none;
  transform: rotate(-10deg);
}

.question-host::before {
  content: "";
  position: absolute;
  top: 34px;
  right: -33px;
  width: 28px;
  height: 10px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--accent);
  transform: rotate(45deg);
  pointer-events: none;
}

.level-loading {
  margin: 0;
  padding: 58px 24px;
  color: var(--line);
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
}

.level-loading::before {
  content: "";
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 16px;
  border: 4px solid rgba(18, 38, 58, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: case-spin 0.9s linear infinite;
}

[data-motion="off"] .level-loading::before {
  animation: none;
  border-top-color: var(--accent);
}

@keyframes case-spin {
  to { transform: rotate(1turn); }
}

.q-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.q-lens {
  position: relative;
  width: 24px;
  height: 24px;
  flex: none;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: rgba(78, 205, 196, 0.28);
}

.q-lens::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: -6px;
  width: 12px;
  height: 5px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--accent);
  transform: rotate(45deg);
}

.q-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #5d6472;
}

.q-prompt {
  position: relative;
  padding-left: 14px;
  color: var(--line);
}

.q-prompt::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  bottom: 0.18em;
  width: 6px;
  border-radius: 3px;
  background: var(--accent);
}

.evidence-line {
  position: relative;
  padding-left: 26px;
  background: #fffdf7;
  border: 2px dashed rgba(18, 38, 58, 0.42);
  box-shadow: 0 3px 0 rgba(18, 38, 58, 0.1);
}

.evidence-line::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 2px solid var(--stamp);
  border-radius: 50%;
  transform: translateY(-50%);
}

.q-hint {
  color: #5d6472;
  font-size: 13px;
}

/* 句子選項卡 */
.sentence-choices {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.sentence-card {
  position: relative;
  justify-content: flex-start;
  min-height: 82px;
  padding: 16px 16px 16px 44px;
  border-radius: 4px 16px 16px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), transparent 48%),
    #fffdf7;
  text-align: left;
}

.sentence-card::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 10px;
  width: 16px;
  height: 16px;
  border-top: 2px solid rgba(18, 38, 58, 0.18);
  border-right: 2px solid rgba(18, 38, 58, 0.18);
}

.sentence-card .key {
  top: 8px;
  left: 9px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink);
  font-size: 11px;
}

.sentence-text {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  line-height: 1.7;
}

.sentence-choices.is-long {
  grid-template-columns: 1fr;
}

/* 標點證物卡 */
.punctuation-choices {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.punct-card {
  flex-direction: column;
  gap: 3px;
  min-height: 116px;
  padding: 12px 8px;
  border-radius: 16px 16px 16px 4px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 193, 69, 0.24), transparent 58%),
    #fffdf7;
}

.punct-wrap {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.punct-mark {
  color: var(--line);
  font-family: var(--font-body);
  font-size: clamp(38px, 6vw, 54px);
  font-weight: 900;
  line-height: 1.05;
}

.punct-name {
  color: #5d6472;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.punct-card:hover:not(:disabled) .punct-mark {
  color: #0f766e;
}

/* 句子排序 */
.order-board {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.order-piece {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid rgba(18, 38, 58, 0.22);
  border-left: 5px solid var(--accent-2);
  border-radius: 4px 12px 12px 4px;
  background: #fffdf7;
  box-shadow: 0 2px 0 rgba(18, 38, 58, 0.08);
}

.order-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.order-text {
  font-size: clamp(15px, 1.9vw, 18px);
  font-weight: 700;
  line-height: 1.6;
}

.order-choices {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.order-card {
  min-height: 64px;
  border-radius: 4px 14px 14px 14px;
  background: #fffdf7;
}

.order-sequence {
  color: var(--line);
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* 回饋像蓋上案件章 */
.feedback-burst {
  border-color: var(--accent);
  background: #12263a;
  color: var(--paper);
  box-shadow: 0 10px 0 rgba(4, 12, 20, 0.32), 0 24px 50px rgba(4, 12, 20, 0.48);
  transform: rotate(-1deg);
}

.feedback-burst.bad {
  background: #3b1620;
  border-color: #f0a35a;
}

.feedback-text {
  color: var(--paper);
}

.feedback-explain {
  color: #ffe8b7;
}

/* 結果頁 */
.result-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 193, 69, 0.3), transparent 38%),
    var(--card);
  border-radius: 6px 24px 24px 24px;
}

.result-card::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 18px;
  width: 54px;
  height: 54px;
  border: 5px double var(--stamp);
  border-radius: 50%;
  opacity: 0.5;
  transform: rotate(-14deg);
}

.result-title {
  color: var(--line);
}

.star.on {
  color: var(--accent);
  text-shadow: 0 4px 0 var(--line);
}

.result-stats div {
  background: #fffdf7;
  border-color: rgba(18, 38, 58, 0.28);
}

.result-stats strong {
  color: var(--line);
}

/* 設定與安裝說明 */
.dialog-panel {
  border-radius: 6px 22px 22px 22px;
  background:
    repeating-linear-gradient(0deg, rgba(18, 38, 58, 0.03) 0 1px, transparent 1px 26px),
    var(--card);
}

.dialog-head h2 {
  color: var(--line);
}

.switch:checked {
  background: var(--accent-2);
}

.toast {
  border-color: var(--accent);
  background: var(--line);
}

.site-footer {
  background: #06111d;
  border-top: 2px solid rgba(255, 193, 69, 0.28);
  color: #aebdcc;
}

.site-footer a {
  color: var(--accent);
}

.skip-link {
  background: var(--accent);
  color: var(--ink);
}

/* 注音開啟時，讓證據卡多留一點行高 */
body.zhuyin-on .sentence-text[data-zy],
body.zhuyin-on .order-text[data-zy],
body.zhuyin-on .q-prompt[data-zy],
body.zhuyin-on .q-passage[data-zy] {
  line-height: 2;
}

@media (max-width: 860px) {
  .screen {
    margin-top: 40px;
    border-radius: 6px 22px 22px 22px;
  }

  .screen::before {
    top: -27px;
    height: 27px;
    width: 84px;
  }

  .screen::after {
    right: 18px;
    width: 72px;
  }

  .hero-copy {
    padding-left: 0;
    border-left: 0;
  }

  .hero-art::after {
    right: 10%;
  }

  .question-host::after,
  .question-host::before {
    display: none;
  }
}

@media (max-width: 620px) {
  body::before {
    opacity: 0.35;
  }

  .screen {
    width: auto;
    margin: 34px 8px 20px;
    padding: 18px 14px 22px;
  }

  .screen::before {
    left: 14px;
    width: 74px;
    height: 24px;
    top: -24px;
    font-size: 10px;
  }

  .screen::after {
    top: -10px;
    right: 10px;
    width: 58px;
    height: 18px;
  }

  .hero-title {
    text-shadow: 2px 2px 0 rgba(255, 193, 69, 0.4);
  }

  .hero-sticker {
    right: 2%;
    bottom: 0;
  }

  .howto::before,
  .howto::after {
    display: none;
  }

  .question-host {
    padding: 14px;
    border-radius: 4px 20px 20px 20px;
  }

  .sentence-choices,
  .punctuation-choices,
  .order-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sentence-choices,
  .sentence-choices.is-long {
    grid-template-columns: 1fr;
  }

  .sentence-card {
    min-height: 70px;
    padding: 14px 12px 14px 40px;
  }

  .punct-card {
    min-height: 96px;
  }

  .punct-mark {
    font-size: 34px;
  }

  .order-choices {
    grid-template-columns: 1fr;
  }

  .feedback-burst {
    margin-inline: 14px;
    padding: 18px 20px;
  }
}
