:root {
  --pink: #ff2d7a;
  --pink-deep: #c8165c;
  --pink-soft: #ffc2da;
  --ink: #161616;
  --ink-soft: #3d3440;
  --paper: #ffffff;
  --cobalt: #2536ff;
  --lemon: #ffe14d;
  --green: #19c37d;
  --lemon-deep: #c9a200;

  --f-sans: "Chiron GoRound TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --f-pen: "Huninn", "Chiron GoRound TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;

  --line: 3px;
  --radius: 22px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--ink);
  background-color: var(--pink);
  /* 機台外殼的網點塗裝 */
  background-image: radial-gradient(rgba(22, 22, 22, 0.09) 1.2px, transparent 1.6px);
  background-size: 14px 14px;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--lemon); color: var(--ink); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--paper); }
button { font: inherit; color: inherit; letter-spacing: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.machine {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 招牌燈 ---------- */
.marquee {
  display: flex;
  justify-content: space-between;
  padding: 18px 6px 14px;
}
.bulb {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  animation: chase 1.6s steps(1) infinite;
}
.bulb:nth-child(odd) { background: var(--lemon); animation-delay: -0.8s; }
@keyframes chase { 50% { background: var(--pink-soft); } }

/* ---------- 共用：螢幕貼紙 ---------- */
.screen {
  position: relative;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 28px;
  box-shadow:
    0 0 0 7px var(--paper),
    0 0 0 calc(7px + var(--line)) var(--ink),
    0 18px 30px -12px rgba(0, 0, 0, 0.45);
  margin: 10px 10px 0;
  overflow: hidden;
}

/* ---------- 封面 ---------- */
.cover-screen { padding: 26px 22px 30px; }

.cover-strip {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.mini {
  padding: 3px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  transform: rotate(calc((var(--i) - 3.5) * 2.2deg));
}

.cover-title {
  margin: 0;
  font-weight: 900;
  font-size: clamp(42px, 13.2vw, 62px);
  line-height: 1.16;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.cover-title .ai {
  display: inline-block;
  padding: 0 0.14em;
  margin: 0 0.04em;
  background: var(--cobalt);
  color: var(--paper);
  border-radius: 0.18em;
  transform: rotate(-4deg);
  letter-spacing: -0.02em;
}
.cover-sub {
  margin: 18px 0 0;
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.console {
  display: grid;
  place-items: center;
  padding: 36px 0 22px;
}

/* 實體大按鈕：底座是真的元素，按下時按鈕帽往下沉 */
.arcade {
  position: relative;
  width: 168px; height: 168px;
  border: 0;
  padding: 0;
  background: none;
  border-radius: 50%;
}
.arcade::before {
  content: "";
  position: absolute;
  inset: 10px -10px -14px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 16px 24px -8px rgba(0, 0, 0, 0.5);
}
.arcade-cap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lemon);
  border: var(--line) solid var(--ink);
  overflow: hidden;
  isolation: isolate;
  font-weight: 900;
  font-size: 25px;
  letter-spacing: 0.06em;
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s;
  animation: nudge 2.8s var(--ease-out) infinite 1.2s;
}
.arcade-cap::before { content: ""; position: absolute; inset: 0; background: var(--lemon-deep); clip-path: inset(80% 0 0 0); z-index: -1; }
.arcade-cap::after { content: ""; position: absolute; top: 11%; left: 20%; width: 38%; height: 20%; border-radius: 50%; background: rgba(255, 255, 255, 0.8); transform: rotate(-24deg); z-index: -1; }
@media (hover: hover) { .arcade:hover .arcade-cap { transform: translateY(2px); } }
.arcade:active .arcade-cap { transform: translateY(9px); animation: none; }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 78% { transform: translateY(5px); } 86% { transform: none; } }

.cover-note {
  margin: 8px 6px 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
  text-align: center;
}

/* ---------- 作答 ---------- */
.quiz-screen { padding: 18px 18px 22px; }
.quiz-screen.enter-fwd .q-text, .quiz-screen.enter-fwd .opt { animation: in-fwd 0.42s var(--ease-out) both; }
.quiz-screen.enter-back .q-text, .quiz-screen.enter-back .opt { animation: in-back 0.42s var(--ease-out) both; }
.quiz-screen .opt { animation-delay: calc(0.04s + var(--i) * 0.035s) !important; }
@keyframes in-fwd { from { opacity: 0; transform: translateX(26px); } }
@keyframes in-back { from { opacity: 0; transform: translateX(-26px); } }

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 0 14px 0 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 700;
}
@media (hover: hover) { .btn-back:hover { background: var(--pink-soft); } }
.btn-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.qcount {
  margin: 0 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.qno {
  display: inline-block;
  padding: 2px 12px;
  background: var(--ink);
  color: var(--lemon);
  border-radius: 10px;
  font-weight: 900;
  font-size: 22px;
  line-height: 1.3;
  transform: rotate(3deg);
}
.qtotal { font-weight: 700; font-size: 15px; color: var(--ink-soft); }

.q-text {
  margin: 18px 0 18px;
  font-weight: 900;
  font-size: clamp(24px, 7vw, 30px);
  line-height: 1.45;
  text-wrap: balance;
  outline: none;
}

.options { display: grid; gap: 12px; }

/* 選項＝拍貼的「框」：黑線白底，角落一塊色標 */
.opt {
  --c: var(--lemon);
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px 14px 14px;
  text-align: left;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 6px 14px -8px rgba(22, 22, 22, 0.45);
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.6;
  transition: transform 0.18s var(--ease-out), background-color 0.18s;
}
.opt::before {
  content: "";
  flex: none;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  background: var(--c);
  transform: rotate(-8deg);
}
@media (hover: hover) { .opt:hover { transform: translateY(-2px); } }
.opt:active { transform: translateY(1px) scale(0.99); }
.opt-text { flex: 1; }
.opt-stamp {
  position: absolute;
  top: -12px; right: 8px;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--lemon);
  opacity: 0;
  transform: scale(1.8) rotate(-30deg);
  transition: opacity 0.2s, transform 0.28s var(--ease-out);
}
.opt-stamp svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.opt.is-picked { background: var(--c); }
.opt.is-picked::before { background: var(--paper); }
.opt.is-picked .opt-stamp { opacity: 1; transform: scale(1) rotate(-12deg); }
.opt.ink-cobalt.is-picked { color: var(--paper); }
.opt.ink-cobalt.is-picked .opt-stamp { background: var(--paper); color: var(--ink); }

.ink-lemon { --c: var(--lemon); }
.ink-cobalt { --c: var(--cobalt); }
.ink-green { --c: var(--green); }
.ink-pink { --c: var(--pink); }
.mini { background: var(--c); }

/* 出片口與 12 格貼紙格（進度） */
.tray {
  margin: 22px 10px 0;
  padding: 14px 14px 0;
  background: var(--ink);
  border-radius: 22px 22px 16px 16px;
}
.cells {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s;
}
.cell.is-current { border: 2px solid var(--lemon); color: var(--lemon); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { border-color: transparent; } }
.cell.is-done { border: 2px solid var(--paper); color: var(--ink); }
.cell.is-done[data-ink="lemon"] { background: var(--lemon); }
.cell.is-done[data-ink="cobalt"] { background: var(--cobalt); color: var(--paper); }
.cell.is-done[data-ink="green"] { background: var(--green); }
.cell.is-done[data-ink="pink"] { background: var(--pink); }
.cell.is-done.is-current { animation: none; outline: 2px solid var(--lemon); outline-offset: 2px; }
.cell.just-stamped { animation: stamp 0.34s var(--ease-out); }
@keyframes stamp { from { transform: scale(1.5) rotate(-14deg); } }

.slot {
  height: 16px;
  margin: 14px 12% 0;
  border-radius: 8px 8px 0 0;
  background: #000;
  box-shadow: inset 0 4px 6px rgba(255, 255, 255, 0.12);
}

/* ---------- 出片中 ---------- */
.print-screen {
  min-height: 56vh;
  display: grid;
  place-items: center;
}
.countdown {
  margin: 0;
  width: 190px; height: 190px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lemon);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 8px var(--paper), 0 0 0 12px var(--ink);
}
.countdown span {
  display: block;
  font-weight: 900;
  font-size: 124px;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.countdown span:empty { display: none; }
.countdown span.pop { animation: pop 0.5s var(--ease-out); }
@keyframes pop { from { transform: scale(1.7); opacity: 0; } 60% { opacity: 1; } }
.flash { position: absolute; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
.tray-print { padding-bottom: 0; }
.slot-open { margin-top: 0; }

/* ---------- 結果：一張印出來的貼紙 ---------- */
.view-result { padding-top: 0; }
.tray-out { margin: 4px 10px 0; padding: 12px 14px 12px; border-radius: 22px; position: relative; z-index: 2; }
.tray-out .slot { margin: 0 8%; height: 14px; border-radius: 7px; }
.eject-wrap { position: relative; margin: -20px 0 0; padding: 44px 14px 44px; clip-path: inset(0 -60px -120px -60px); }
.eject-wrap .sticker { margin: 0; }

.sticker {
  --on-c: var(--ink);
  position: relative;
  margin: 8px 10px 0;
  padding: 16px 16px 22px;
  background-color: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 26px;
  box-shadow:
    0 0 0 8px var(--paper),
    0 0 0 calc(8px + var(--line)) var(--ink),
    0 26px 40px -16px rgba(0, 0, 0, 0.55);
  transform: rotate(-1.2deg);
  overflow: hidden;
}
.sticker.ink-cobalt, .sticker.ink-pink { --on-c: var(--paper); }
/* 亮面貼紙的斜向反光 */
.sticker::after {
  content: "";
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.55) 48%, transparent 54%);
  pointer-events: none;
  transform: translateX(-120%);
}
.sticker.eject { animation: eject 1.1s var(--ease-out) both; }
.sticker.eject::after { animation: sheen 1.4s ease-out 0.9s both; }
@keyframes eject { from { transform: translateY(-105%) rotate(0deg); } 70% { transform: translateY(0) rotate(0deg); } to { transform: rotate(-1.2deg); } }
@keyframes sheen { 70% { opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

.photo {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 14px 16px 92px;
  background-color: var(--c);
  background-image: radial-gradient(rgba(22, 22, 22, 0.12) 1.4px, transparent 1.8px);
  background-size: 12px 12px;
  border: var(--line) solid var(--ink);
  border-radius: 18px;
}
.photo-art { width: 128px; height: 128px; filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.25)); transform: rotate(-5deg); }
.photo-art .art { width: 100%; height: 100%; }
.pen-quote {
  position: absolute;
  left: 12px; right: 12px; bottom: 14px;
  margin: 0;
  padding: 8px 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 14px;
  font-family: var(--f-pen);
  font-size: clamp(16px, 4.6vw, 21px);
  line-height: 1.45;
  text-align: center;
  transform: rotate(1.8deg);
}

.r-name {
  margin: 18px 0 18px;
  font-weight: 900;
  font-size: clamp(36px, 11vw, 48px);
  line-height: 1.15;
  outline: none;
}
.r-desc { margin: 0; font-size: 16.5px; line-height: 1.85; text-wrap: pretty; }

/* 四維度量尺 */
.meters {
  margin: 22px 0 0;
  padding: 16px 14px 6px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  display: grid;
  gap: 8px;
}
.meter-top { display: flex; justify-content: space-between; align-items: baseline; }
.meter-label { font-weight: 900; font-size: 18px; }
.meter-val { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.meter-track {
  position: relative;
  height: 16px;
  margin-top: 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), rgba(22, 22, 22, 0.18) calc(12.5% - 1px) 12.5%);
  overflow: visible;
}
.meter-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--cobalt);
}
.meter-fill.neg { background: var(--pink); }
.meter-mid {
  position: absolute;
  left: 50%; top: -6px; bottom: -6px;
  width: 3px;
  margin-left: -1.5px;
  background: var(--ink);
  border-radius: 2px;
}
.meter-dot {
  position: absolute;
  top: 50%;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--lemon);
  border: 3px solid var(--ink);
  z-index: 1;
}
.meter-ends {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.end-high { text-align: right; }

/* 幻覺指數 */
.halluc {
  margin: 14px 0 0;
  padding: 14px 14px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 18px;
}
.halluc-head { display: flex; justify-content: space-between; align-items: baseline; }
.halluc-label { margin: 0; font-size: 18px; font-weight: 900; }
.halluc-num { margin: 0; font-weight: 900; font-size: 34px; line-height: 1; color: var(--lemon); font-variant-numeric: tabular-nums; }
.halluc-max { font-size: 16px; color: rgba(255, 255, 255, 0.7); margin-left: 2px; }
.halluc-cells {
  list-style: none;
  margin: 12px 0 10px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}
.halluc-cells li {
  height: 18px;
  border-radius: 5px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
}
.halluc-cells li.on { background: var(--lemon); border: 2px solid var(--lemon); transform: rotate(-4deg); }
.halluc-cells li.on:nth-child(even) { transform: rotate(3deg); }
.halluc-text { margin: 0; font-size: 15px; line-height: 1.75; }
.halluc-text strong { display: block; color: var(--lemon); font-weight: 900; }

/* 優點／bug／搭檔／更新建議：貼紙下方一張沒有傾斜的白紙，標籤用塗鴉筆 */
.traits {
  margin: 4px 10px 0;
  padding: 18px 18px 20px;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  display: grid;
  gap: 14px;
}
.trait { display: grid; gap: 2px; }
.trait dt {
  font-family: var(--f-pen);
  font-size: 21px;
  line-height: 1.4;
  color: var(--ink);
}
.trait dt::after {
  content: "";
  display: block;
  width: 3.2em;
  height: 6px;
  margin-top: 1px;
  background: var(--lemon);
  border-radius: 3px;
  transform: rotate(-1.5deg);
}
.trait dd { margin: 0; font-size: 16px; line-height: 1.8; }
.partner-art { display: inline-block; width: 30px; height: 30px; margin-right: 6px; vertical-align: -9px; }
.partner-art .art { width: 100%; height: 100%; }

/* 角色插畫 */
.art { display: block; overflow: visible; }
.art * { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.art .p { fill: var(--paper); }
.art .y { fill: var(--lemon); }
.art .b { fill: var(--cobalt); }
.art .g { fill: var(--green); }
.art .r { fill: var(--pink); }
.art .s { fill: var(--pink-soft); }
.art .k { fill: var(--ink); }
.art .f { stroke: none; }
.art .t { stroke-width: 3; }
.art .d { stroke-dasharray: 2 9; }
.art .w { stroke-width: 13; fill: none; }
.art .w2 { stroke: var(--lemon); stroke-width: 6; fill: none; }
.mini .art { width: 100%; height: 100%; }
.mini .art * { stroke-width: 6; }
.mini .art .t, .mini .art .d { stroke-width: 4; }
.mini .art .w { stroke-width: 16; }
.mini .art .w2 { stroke-width: 8; }
.q-text .keep { white-space: nowrap; }
.pen-quote .seg { display: inline-block; }

/* 塗鴉筆：手繪底線與圈圈 */
.r-name { position: relative; display: inline-block; }
.doodle { position: absolute; fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.doodle-underline { left: -2%; bottom: -12px; width: 104%; height: 16px; stroke: var(--pink); stroke-width: 3.5; }
.halluc-num { position: relative; }
.doodle-loop { left: -14px; top: -14px; width: calc(100% + 20px); height: calc(100% + 26px); stroke: var(--lemon); stroke-width: 2.5; opacity: 0.9; }

/* 結果按鈕 */
.result-actions { display: grid; gap: 12px; margin: 34px 4px 0; }
.btn-share, .btn-retry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  border-radius: 999px;
  border: var(--line) solid var(--ink);
  font-weight: 900;
  font-size: 19px;
  transition: transform 0.15s var(--ease-out);
}
.btn-share { background: var(--lemon); box-shadow: 0 10px 18px -10px rgba(22, 22, 22, 0.6); }
.btn-retry { background: var(--paper); min-height: 52px; font-size: 17px; }
@media (hover: hover) { .btn-share:hover, .btn-retry:hover { transform: translateY(-2px); } }
.btn-share:active, .btn-retry:active { transform: translateY(1px); }
.btn-save:disabled { opacity: 0.6; cursor: progress; }
.btn-share svg, .btn-retry svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  padding: 10px 18px;
  width: max-content;
  max-width: min(360px, calc(100% - 32px));
  background: var(--ink);
  color: var(--paper);
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.3s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media screen and (min-width: 600px) {
  .machine { padding-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
