﻿:root {
  --bg: #f6f1e7; --card: #fffdf8; --ink: #1d2433; --muted: #5f6675; --line: #e2dccf;
  --accent: #e2552d; --accent-d: #c2421d; --ref: #8d95a6; --ok: #1f9d6b;
  --g: #2f9e5b; --y: #e0b030; --o: #e9822e; --r: #d2483b;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; line-height: 1.5 }
a { color: #b23d1a }
a:hover { color: var(--accent-d) }
button { font: inherit; color: inherit; cursor: pointer }
img { max-width: 100% }

/* header & footer */
.site-head { display: flex; align-items: center; gap: 12px; max-width: 980px; width: 100%; margin: 0 auto; padding: 10px 16px }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.25rem; letter-spacing: -.01em; margin-right: auto }
.logo { width: 34px; height: 34px }
.site-nav { display: none; gap: 4px }
.site-nav a, .site-menu-list a { text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: .95rem }
.site-nav a:hover, .site-menu-list a:hover { background: #ece5d6 }
.site-nav a[aria-current], .site-menu-list a[aria-current] { background: var(--ink); color: #fff }
.site-menu { position: relative }
.site-menu summary { list-style: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; cursor: pointer }
.site-menu summary::-webkit-details-marker { display: none }
.site-menu summary svg { width: 24px; height: 24px; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; fill: none }
.site-menu-list { position: absolute; right: 0; top: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; min-width: 180px; box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 30 }
@media (min-width: 720px) { .site-nav { display: flex } .site-menu { display: none } }
.site-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 0 12px 24px }
.site-foot { border-top: 1px solid var(--line); padding: 20px 16px 28px; text-align: center; color: var(--muted); font-size: .88rem }
.site-foot p { margin: 6px auto; max-width: 640px }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-bottom: 8px }
.foot-links a { color: var(--ink) }

/* buttons */
.btn, .btn-main, .btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 700; font-size: 1rem; text-decoration: none; line-height: 1.2 }
.btn, .btn-main { background: var(--accent); color: #fff }
.btn:hover, .btn-main:hover { background: var(--accent-d); color: #fff }
.btn.ghost, .btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink) }
.btn.ghost:hover, .btn-ghost:hover { background: var(--ink); color: #fff }
:focus-visible { outline: 3px solid #3d7bd9; outline-offset: 2px }

/* game */
.game-wrap { max-width: 720px; margin: 0 auto 28px; min-height: 470px }
.g { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 14px; box-shadow: 0 2px 10px rgba(40,30,10,.05) }
.g-bar { display: flex; align-items: center; gap: 6px }
.g-tabs { display: flex; background: #efe9dc; border-radius: 999px; padding: 3px; flex: 1 1 auto; min-width: 0 }
.g-tabs button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px 4px; font-weight: 700; font-size: .84rem; color: var(--muted); white-space: nowrap }
.g-tabs button[aria-selected="true"] { background: var(--ink); color: #fff }
.g-tools { display: flex; gap: 4px }
.g-ico, .g-units { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; padding: 0 }
.g-units { font-weight: 800; font-size: .9rem }
.g-ico svg { width: 20px; height: 20px; fill: var(--ink) }
.g-ico:hover, .g-units:hover { background: #efe9dc }
.g-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 4px 2px; font-size: .85rem; color: var(--muted); font-weight: 600; gap: 8px }
.g-dots { display: flex; gap: 5px }
.g-dots i { width: 12px; height: 12px; border-radius: 50%; background: #e4ddcd; display: block }
.g-dots i.d-cur { background: var(--ink) }
.g-dots .d-g { background: var(--g) } .g-dots .d-y { background: var(--y) } .g-dots .d-o { background: var(--o) } .g-dots .d-r { background: var(--r) }
.g-q { text-align: center; margin: 6px 4px 8px }
.g-title { font-size: 1.3rem; margin: 0; line-height: 1.25; font-weight: 700 }
.g-title b { color: var(--accent-d) }
.g-sub { margin: 3px 0 0; color: var(--muted); font-size: .9rem }

.scene { position: relative; height: 300px; border-radius: 12px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: ns-resize;
  background: linear-gradient(#fbf8f1, #f1ebdd); outline-offset: -3px }
.scene.locked { cursor: default }
.sil { position: absolute; left: 0; top: 0; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; will-change: transform, width, height }
.sil-ref { background: var(--ref) }
.sil-tgt { background: none; -webkit-mask: none; mask: none; z-index: 2 }
.sil-tgt::before { content: ""; position: absolute; inset: 0; background: var(--accent); -webkit-mask-image: var(--m); mask-image: var(--m); -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat }
.locked .sil-tgt::before { opacity: .35 }
.sil-ghost { background: var(--ok); opacity: .9; z-index: 3 }
.handle { position: absolute; right: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.2) }
.handle::after { content: ""; position: absolute; inset: 5px; border-top: 2.5px solid var(--accent); border-right: 2.5px solid var(--accent) }
.locked .handle { display: none }
.ground { position: absolute; left: 0; right: 0; height: 2px; background: #cfc6b3 }
.lab { position: absolute; top: 6px; text-align: center; font-size: .8rem; line-height: 1.25; max-width: 48%; pointer-events: none; white-space: nowrap }
.lab b { display: block; font-size: .85rem; overflow: hidden; text-overflow: ellipsis }
.lab span { color: var(--muted); font-variant-numeric: tabular-nums }
.lab-tgt b { color: var(--accent-d) }
.lab-tgt span { color: var(--ink); font-weight: 700 }
.locked .lab-tgt span { color: var(--ok) }
.scene-hint { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); background: rgba(29,36,51,.78); color: #fff; font-size: .8rem; padding: 4px 10px; border-radius: 999px; pointer-events: none; transition: opacity .3s }
.scene.touched .scene-hint, .scene.locked .scene-hint { opacity: 0 }

.g-ctl { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px }
.btn-round { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); font-size: 1.6rem; font-weight: 700; line-height: 1; display: grid; place-items: center; touch-action: manipulation; -webkit-user-select: none; user-select: none }
.btn-round:active { background: #efe9dc }
.g-ctl .btn-main { min-width: 150px; padding: 14px 26px; font-size: 1.05rem }

.g-res { margin: 12px 4px 0; text-align: center }
.r-top { display: flex; align-items: center; justify-content: center; gap: 12px }
.r-pts { font-size: 2.4rem; font-weight: 800; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums }
.r-tier { text-align: left; font-weight: 800; font-size: 1.1rem; line-height: 1.2 }
.r-tier small { display: block; font-weight: 500; color: var(--muted); font-size: .85rem }
.r-real { margin: 10px 0 4px }
.r-fact { margin: 0 auto 12px; color: var(--muted); font-size: .92rem; max-width: 560px }

.g-end { text-align: center; padding: 8px 4px }
.e-total { font-size: 1.2rem; color: var(--muted); font-weight: 700 }
.e-total span { font-size: 3.2rem; color: var(--ink); font-weight: 800 }
.e-tier { margin: 0; font-weight: 800; font-size: 1.15rem }
.e-list { list-style: none; padding: 0; margin: 14px auto; max-width: 420px; text-align: left }
.e-list li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line) }
.e-n { flex: 1 } .e-p { font-weight: 800; font-variant-numeric: tabular-nums }
.e-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin: 12px 0 }
.e-next { margin: 0; color: var(--muted) } .e-next b { color: var(--ink); font-variant-numeric: tabular-nums }
.muted { color: var(--muted) }
.g-err { text-align: center; padding: 40px 10px; color: var(--muted) }

/* modal, toast, tutorial */
.modal { position: fixed; inset: 0; background: rgba(20,24,34,.5); display: grid; place-items: center; z-index: 50; padding: 14px }
.modal-box { background: var(--card); border-radius: 16px; max-width: 460px; width: 100%; max-height: 88vh; overflow: auto; padding: 18px 20px 20px; position: relative }
.modal-box h2 { margin: 0 0 8px; font-size: 1.3rem }
.modal-box h3 { margin: 16px 0 6px; font-size: 1rem }
.modal-x { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 1.8rem; line-height: 1; width: 40px; height: 40px }
.help { padding-left: 20px } .help li { margin: 6px 0 }
.st { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; font-size: .75rem; color: var(--muted) }
.st b { display: block; font-size: 1.35rem; color: var(--ink) }
.hist { margin-top: 8px }
.hb { display: flex; align-items: center; gap: 8px; font-size: .78rem; margin: 3px 0 }
.hb span { width: 64px; color: var(--muted); text-align: right }
.hb i { background: var(--ink); color: #fff; font-style: normal; padding: 1px 6px; border-radius: 4px; text-align: right; min-width: 22px }
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; z-index: 60; font-weight: 600 }
.tip { position: absolute; z-index: 45; background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 26px rgba(0,0,0,.25); font-size: .93rem }
.tip p { margin: 0 0 10px }
.tip div { display: flex; justify-content: flex-end; gap: 8px }
.tip button { border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 700 }
.tip-skip { background: transparent; color: #cfd4de }
.tip-next { background: var(--accent); color: #fff }
.tut-hi { outline: 3px dashed #3d7bd9; outline-offset: 3px }

/* text pages */
.doc-text { max-width: 720px; margin: 0 auto; padding: 4px 6px }
.doc-text h1 { font-size: 1.8rem; line-height: 1.2; margin: 14px 0 8px; letter-spacing: -.01em }
.doc-text h2 { font-size: 1.3rem; margin: 26px 0 8px }
.doc-text h3 { font-size: 1.05rem; margin: 18px 0 4px }
.lede { font-size: 1.1rem; color: var(--muted); margin-top: 0 }
.crumbs { font-size: .85rem; color: var(--muted); margin: 10px 0 0 }
.home-text { border-top: 1px solid var(--line); padding-top: 8px }
.tbl { border-collapse: collapse; width: 100%; font-size: .92rem; margin: 10px 0 }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top }
.tbl.credits { font-size: .82rem; display: block; overflow-x: auto }
.day-list { list-style: none; padding: 0 }
.day-list a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; text-decoration: none; color: var(--ink); background: var(--card) }
.day-list a:hover { border-color: var(--ink) }
.day-list span { display: block; color: var(--muted); font-size: .88rem }
.a-play { display: flex; flex-wrap: wrap; gap: 10px }
.a-spoiler { color: var(--muted); font-style: italic }
.a-list { list-style: none; padding: 0 }
.a-item { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line) }
.a-item h3 { margin: 0 0 2px }
.a-item p { margin: 2px 0 }
.a-sil { flex: none; width: 72px; height: auto; max-height: 72px; object-fit: contain; filter: invert(38%) sepia(66%) saturate(2100%) hue-rotate(345deg) brightness(92%); margin-top: 4px }
.a-item > div { min-width: 0 }
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0 }

/* contact form */
form[data-feedback-form] { display: grid; gap: 12px; margin-top: 14px }
.fb-row { display: grid; gap: 12px }
@media (min-width: 600px) { .fb-row { grid-template-columns: 1fr 1fr } }
.fb-field label { display: block; font-weight: 600; margin-bottom: 4px }
.fb-field input, .fb-field textarea { width: 100%; padding: 10px 12px; border: 1px solid #cfc7b6; border-radius: 10px; font: inherit; background: #fff }
.fb-field textarea { min-height: 150px; resize: vertical }
.fb-hint { color: var(--muted); font-weight: 400 }
form[data-feedback-form] button[type="submit"] { justify-self: start }

@media (min-width: 720px) {
  .g { padding: 14px 18px 18px }
  .g-title { font-size: 1.5rem }
  .scene { height: 430px }
  .lab { font-size: .85rem }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important } }
