:root {
  --red: #a52f3f;
  --red-dark: #7c1f2c;
  --red-soft: #f6dfe2;
  --mustard: #e0a526;
  --mustard-dark: #a9760d;
  --mustard-soft: #fbecc4;
  --cream: #fbf3df;
  --paper: #fffaf0;
  --ink: #2d2621;
  --ink-soft: #5f554c;
  --line: #e3d4ba;
  --teal: #2f7f78;
  --teal-soft: #dcefeb;
  --plum: #6b4778;
  --plum-soft: #eee4f1;
  --good: #2c7a4b;
  --good-soft: #e2f3e6;
  --bad: #a52f3f;
  --bad-soft: #f8e1e4;
  --zone: #a52f3f;
  --zone-soft: #f6dfe2;
  --zone-deep: #7c1f2c;
  --shadow-sm: 0 1px 2px rgba(60, 36, 20, .08), 0 2px 8px rgba(60, 36, 20, .06);
  --shadow: 0 8px 24px rgba(84, 46, 22, .12), 0 2px 6px rgba(84, 46, 22, .08);
  --shadow-lg: 0 24px 60px rgba(84, 46, 22, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --appbar-h: 68px;
  --footer-h: 58px;
  --max: 1180px;
  --font: "Noto Sans TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", "Hiragino Sans TC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.65;
  overflow: hidden;
}

body[data-zone="1"] { --zone: #a52f3f; --zone-soft: #f6dfe2; --zone-deep: #7c1f2c; }
body[data-zone="2"] { --zone: #c9851f; --zone-soft: #fbecc4; --zone-deep: #7d5308; }
body[data-zone="3"] { --zone: #2f7f78; --zone-soft: #dcefeb; --zone-deep: #1d5954; }
body[data-zone="4"] { --zone: #74355f; --zone-soft: #eee4f1; --zone-deep: #4b2f55; }

h1, h2, h3, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red-dark); text-underline-offset: .2em; }
a:hover { color: var(--red); }
strong, b { font-weight: 800; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #1769aa;
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--mustard-soft); color: var(--ink); }

.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(1100px 640px at 12% -5%, #fff8e9 0%, rgba(255, 248, 233, 0) 62%),
    radial-gradient(900px 600px at 96% 10%, #f7e8d1 0%, rgba(247, 232, 209, 0) 58%),
    linear-gradient(180deg, #fdf7e9 0%, #f8eedb 56%, #f4e5cc 100%);
}
.bg::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .38;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(165, 47, 63, .28) 0 1.5px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(224, 165, 38, .34) 0 1.5px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(47, 127, 120, .2) 0 1.5px, transparent 2px);
  background-size: 34px 34px, 43px 43px, 57px 57px;
  pointer-events: none;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, .18) 0 2px, transparent 2px 10px);
  opacity: .5;
  pointer-events: none;
}
.bg__img {
  position: absolute;
  right: -8vw;
  bottom: -6vh;
  width: min(64vw, 920px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--zone-soft) 0%, rgba(251, 243, 223, 0) 68%);
  opacity: .85;
  transition: background .4s ease;
}

.appbar {
  position: relative;
  flex: 0 0 auto;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--appbar-h);
  padding: 8px max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-right));
  background: rgba(255, 250, 240, .93);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(84, 46, 22, .05);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  border-radius: 10px;
}
.brand:hover { color: var(--ink); }
.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  color: #fff6e3;
  font-size: 22px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), var(--shadow-sm);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand__text strong { font-size: 17px; letter-spacing: .02em; white-space: nowrap; }
.brand__text small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.sysbar { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:hover { background: var(--mustard-soft); border-color: #d9bf8d; transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.is-on { background: var(--zone-soft); border-color: var(--zone); color: var(--zone-deep); }

.notice {
  position: relative;
  z-index: 39;
  margin: 10px auto 0;
  width: min(calc(100% - 24px), 760px);
  padding: 10px 16px;
  border: 1px solid #d9bf8d;
  border-radius: 12px;
  background: #fff6dd;
  color: #6b4a08;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.game {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-left)) 24px max(16px, env(safe-area-inset-right));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.screen { display: none; animation: screen-in .3s ease both; }
.screen.is-active { display: block; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--zone-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { background: linear-gradient(180deg, #b23a49, var(--red)); color: #fff8e8; border-color: var(--red-dark); box-shadow: 0 5px 0 var(--red-dark), var(--shadow-sm); }
.btn--primary:hover { background: linear-gradient(180deg, #bd4352, #9c2b3a); }
.btn--primary:active { box-shadow: 0 2px 0 var(--red-dark); transform: translateY(3px); }
.btn--ghost { background: rgba(255, 250, 240, .78); border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover { background: var(--paper); color: var(--ink); }
.btn--soft { background: var(--zone-soft); border-color: color-mix(in srgb, var(--zone) 26%, #fff); color: var(--zone-deep); }
.btn--danger { background: #fff0f1; border-color: #d99aa2; color: #8c1e2c; }
.btn--xl { min-height: 52px; padding-inline: 26px; font-size: 17px; }
.btn--sm { min-height: 44px; padding: 6px 12px; font-size: 13px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.pill b { color: var(--ink); }
.pill--soft { background: var(--zone-soft); border-color: color-mix(in srgb, var(--zone) 22%, #fff); color: var(--zone-deep); }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--zone);
  color: #fff9ea;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--zone-soft);
  color: var(--zone-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
.inline-note { margin: 6px 0 14px; color: var(--ink-soft); font-size: 14px; min-height: 1.2em; }
.inline-note.is-warn { color: #8c1e2c; font-weight: 700; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 100;
  padding: 12px;
  border-radius: 12px;
  background: #fff0f1;
  color: #8c1e2c;
  font-weight: 800;
  text-align: center;
}

dialog {
  max-width: calc(100vw - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
}
dialog::backdrop { background: rgba(45, 30, 20, .52); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog { width: min(560px, calc(100vw - 24px)); }
.dialog--wide { width: min(620px, calc(100vw - 24px)); }
.dialog--small { width: min(420px, calc(100vw - 24px)); }
.dialog__form {
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 820px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}
.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf7, #fbf3df);
}
.dialog__head h2 { font-size: 19px; line-height: 1.3; }
.dialog__body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.dialog__body > p { margin-bottom: 10px; }
.dialog__body > p:last-child { margin-bottom: 0; }
.dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fffdf7;
}
.dialog__foot--two { justify-content: space-between; }
.dialog__hr { border: 0; border-top: 1px dashed var(--line); margin: 14px 0; }
.dialog__version { margin-top: 12px; color: #75695d; font-size: 11px; text-align: center; }

.setting { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.setting:last-of-type { border-bottom: 0; }
.setting__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.setting__row label { font-weight: 800; font-size: 14px; }
.setting--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting--row strong { font-size: 14px; }
.setting__note { color: var(--ink-soft); font-size: 12px; line-height: 1.45; margin-top: 2px; }
.range { width: 100%; height: 44px; margin-top: 4px; accent-color: var(--zone); cursor: pointer; }
.switch {
  position: relative;
  width: 56px;
  height: 44px;
  flex: 0 0 56px;
  padding: 0;
  border: 0;
  background: transparent;
}
.switch::before {
  content: "";
  position: absolute;
  top: 7px; left: 3px;
  width: 50px; height: 30px;
  border: 1px solid #cbb794;
  border-radius: 999px;
  background: #e7dbc4;
  transition: background .2s ease;
  pointer-events: none;
}
.switch span {
  position: absolute;
  z-index: 1;
  top: 10px; left: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  transition: transform .2s ease;
  pointer-events: none;
}
.switch[aria-checked="true"]::before { background: var(--zone); border-color: var(--zone-deep); }
.switch[aria-checked="true"] span { transform: translateX(20px); }
.setting-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin: 6px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf7;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.setting-btn:hover { background: var(--mustard-soft); }
.setting-btn--danger { color: #8c1e2c; border-color: #e3b8bd; }
.setting-btn__state { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.about-box { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; }
.about-box summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 800; font-size: 14px; }
.about-box p { margin-top: 8px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.65; }

.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti__bit {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: .9;
  animation: confetti-fall var(--dur, 2.6s) cubic-bezier(.2, .7, .3, 1) forwards;
  animation-delay: var(--delay, 0s);
}

.site-footer {
  position: relative;
  flex: 0 0 auto;
  z-index: 30;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 240, .96);
  color: var(--ink-soft);
  text-align: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.site-footer p { font-size: 12px; line-height: 1.5; }
.site-footer a { color: var(--red-dark); font-weight: 700; }

@media (max-width: 560px) {
  .brand__mark { width: 44px; height: 44px; flex-basis: 44px; font-size: 19px; }
  .brand__text strong { font-size: 15px; }
  .brand__text small { font-size: 10px; }
  .sysbar { gap: 4px; }
  .game { padding-top: 14px; }
}
@media (max-width: 380px) {
  .brand__text small { display: none; }
  .brand__text strong { font-size: 14px; }
  .site-footer p { font-size: 11px; }
}

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