/* 夜更けの路面電車 */
:root {
  --accent: #3a4fb8; --accent-ink: #ffffff; --accent-soft: #e3e7fb;
  --lamp: #e0a531; --night: #0d1330; --night-2: #1a2350; --paper: #fdf6e3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent: #ffd27a; --accent-ink: #1a1a2e; --accent-soft: #3a3320; --lamp: #ffd27a; }
}
:root[data-theme="dark"] { --accent: #ffd27a; --accent-ink: #1a1a2e; --accent-soft: #3a3320; --lamp: #ffd27a; }

.yd-title-art { display: block; width: 100%; height: auto; border-radius: 16px; }
.yd-title .mn-title { letter-spacing: .02em; }
.yd-start { margin-top: 4px; }
.yd-mini { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.yd-daily .mn-daily-num { font-size: 22px; flex: none; }
.yd-towns { display: grid; gap: 8px; }
.yd-town { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; }
.yd-town:hover:not(:disabled) { border-color: var(--accent); }
.yd-town.cleared { border-color: color-mix(in srgb, var(--lamp) 60%, var(--line)); }
.yd-town.locked { opacity: .55; cursor: default; }
.yd-town-ic { font-size: 24px; width: 32px; text-align: center; flex: none; }
.yd-town-name { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.yd-town-name small { color: var(--text-sub); font-size: 12.5px; }

.yd-intro .yd-story { background: linear-gradient(160deg, #0d1330, #252f66); color: #eef0fa; border-radius: 16px; padding: 18px 18px 8px; font-family: var(--font-serif); font-size: 16px; line-height: 1.95; }
.yd-story p { animation: yd-fade .8s both; }
@keyframes yd-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.yd-mur { border-left: 3px solid var(--lamp); padding: 4px 0 4px 12px; margin-top: 10px; }
.yd-mur small { color: var(--text-sub); font-size: 12px; font-weight: 700; }
.yd-mur p { margin: 2px 0 0; white-space: pre-line; font-family: var(--font-serif); }
.yd-mur.locked p { color: var(--text-sub); }

/* プレイ画面 */
body.yd-in-play .mn-app { padding: 6px 8px 12px; max-width: 640px; }
.yd-play { display: flex; flex-direction: column; align-items: center; gap: 6px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.yd-hud { width: 100%; max-width: 620px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 4px 6px; min-height: 46px; }
.yd-hud small { display: block; font-size: 11px; color: var(--text-sub); line-height: 1.2; font-weight: 700; }
.yd-clock { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.yd-hud-r { text-align: right; }
.yd-count { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--lamp); }
.yd-night { position: relative; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: visible; margin: 0 14px; }
.yd-night > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #26306a, #6c78c9 70%, #ffbf7a); transition: width .4s linear; }
.yd-moon, .yd-sun { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14px; line-height: 1; }
.yd-moon { left: -16px; } .yd-sun { right: -17px; }
.yd-dawn { text-align: center; margin-top: 3px; }
.yd-stage { position: relative; border-radius: 14px; overflow: hidden; box-shadow: 0 6px 24px rgba(5, 8, 30, .35); background: var(--night); touch-action: none; }
.yd-cv { display: block; touch-action: none; cursor: crosshair; }
.yd-stage.yd-danger { box-shadow: 0 0 0 3px #ff5d5d, 0 6px 24px rgba(5, 8, 30, .35); }
.yd-banner { position: absolute; left: 8px; right: 8px; top: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(8, 12, 36, .86); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.45; pointer-events: none; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
.yd-banner.show { opacity: 1; transform: none; }
.yd-banner.tut { border: 1.5px solid #ffd27a; }
.yd-bubble { position: absolute; left: 10px; right: 10px; top: 8px; padding: 7px 12px; opacity: 0; border-radius: 14px; background: rgba(253, 246, 227, .9); color: #1b2140; pointer-events: none; transform: translateY(-8px); transition: opacity .4s, transform .4s; }
.yd-bubble.show { opacity: 1; transform: none; }
.yd-bubble small { font-size: 11.5px; font-weight: 700; color: #7a6230; }
.yd-bubble.low { top: 70px; }
.yd-bubble p { margin: 1px 0 0; font-family: var(--font-serif); font-size: 13.5px; line-height: 1.55; white-space: pre-line; }
.yd-sel { position: absolute; left: 8px; right: 8px; bottom: 8px; }
.yd-sel-in { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 14px; background: rgba(8, 12, 36, .92); color: #fff; font-size: 13.5px; font-weight: 700; }
.yd-sel-in > i { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.yd-del { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 0; background: #e5484d; color: #fff; font-weight: 800; cursor: pointer; }
.yd-x { width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
.yd-overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 12px; background: rgba(6, 9, 28, .55); }
.yd-overlay.show { display: flex; }
.yd-rw { width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto; background: var(--paper); color: #1b2140; border-radius: 18px; padding: 16px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); animation: mn-pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.yd-rw-k { margin: 0; font-size: 13px; font-weight: 800; color: #9a6b12; letter-spacing: .06em; }
.yd-rw-t { display: block; font-size: 19px; margin: 2px 0 10px; }
.yd-rw-tut { font-size: 13px; background: #fff1cc; border-radius: 10px; padding: 6px 10px; margin: 0 0 10px; }
.yd-rw-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yd-rw-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 132px; padding: 12px 8px; border-radius: 14px; border: 2px solid #d8cfb8; background: #fff; color: #1b2140; cursor: pointer; touch-action: manipulation; }
.yd-rw-opt:hover, .yd-rw-opt:focus-visible { border-color: #e0a531; background: #fffaf0; }
.yd-rw-opt:active { transform: scale(.97); }
.yd-rw-ic { font-size: 32px; line-height: 1.2; }
.yd-rw-opt b { font-size: 16px; }
.yd-rw-opt small { font-size: 12px; line-height: 1.45; color: #5c5a66; }
.yd-two { margin-top: 12px; }
.yd-two .mn-btn { color: #1b2140; background: #fff; border-color: #d8cfb8; }
.yd-two .mn-btn-primary { background: #26306a; border-color: #26306a; color: #fff; }
.yd-story-s { text-align: left; font-family: var(--font-serif); font-size: 14.5px; line-height: 1.8; }
.yd-story-s p { margin: 0 0 .5em; }
.yd-rw-big { margin: 6px 0 0; font-weight: 700; }
.yd-rw-big b { font-size: 30px; color: #b27a10; margin-right: 4px; }

.yd-bar { width: 100%; max-width: 620px; display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 0 2px; }
.yd-chips { display: flex; gap: 4px; flex: 1; min-width: 0; flex-wrap: nowrap; }
.yd-chip { width: 32px; height: 44px; border-radius: 10px; border: 2px dashed color-mix(in srgb, var(--c) 70%, transparent); background: transparent; padding: 0; cursor: default; position: relative; flex: none; }
.yd-chip::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 3px solid var(--c); box-sizing: border-box; opacity: .7; }
.yd-chip.used { border-style: solid; border-color: var(--c); background: var(--c); cursor: pointer; }
.yd-chip.used::after { border-color: #fff; background: #fff; opacity: .9; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.yd-chip.on { box-shadow: 0 0 0 3px var(--text); }
.yd-chip.lock { opacity: .25; border-style: dotted; }
.yd-chip.lock::after { content: "＋"; border: 0; width: auto; height: auto; margin: 0; transform: translate(-50%, -50%); color: var(--c); font-weight: 900; font-size: 14px; line-height: 1; }
.yd-res { font-size: 13px; font-weight: 700; color: var(--text-sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
.yd-ctl { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 18px; font-weight: 800; cursor: pointer; flex: none; touch-action: manipulation; }
.yd-ctl.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.yd-speed { font-size: 15px; }
@media (max-width: 380px) { .yd-chip { width: 26px; } .yd-ctl { width: 44px; } .yd-res { font-size: 12px; } }

/* 結果 */
.yd-res-big { font-size: 28px; font-weight: 900; margin: 2px 0 6px; }
.yd-ok { border-color: color-mix(in srgb, var(--lamp) 70%, var(--line)); }
.yd-near { font-weight: 800; color: var(--warn); margin: 4px 0; }
.yd-resmap { display: block; width: 62%; max-width: 240px; height: auto; margin: 10px auto 0; border-radius: 12px; }

@media (prefers-reduced-motion: reduce) { .yd-banner, .yd-bubble { transition: none; } }
.yd-say { position: absolute; left: 50%; bottom: 64px; transform: translate(-50%, 6px); max-width: calc(100% - 24px); width: max-content; padding: 7px 14px; border-radius: 12px; background: rgba(8, 12, 36, .92); color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1.45; text-align: center; pointer-events: none; opacity: 0; transition: opacity .2s, transform .2s; }
.yd-say.show { opacity: 1; transform: translate(-50%, 0); }
.yd-say.bad { background: rgba(150, 25, 35, .94); }

/* 生成画像（assets/manifest.js にあるときだけ使う） */
.yd-ic { width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: -.25em; }
.yd-town-ic .yd-ic { width: 26px; height: 26px; }
.yd-moon .yd-ic, .yd-sun .yd-ic { width: 18px; height: 18px; vertical-align: middle; }
.yd-title-media { aspect-ratio: 16 / 9; object-fit: cover; background: var(--night); }
.yd-story.with-tsuki { position: relative; padding-right: 30%; min-height: 220px; }
.yd-story-tsuki { position: absolute; right: 6px; bottom: 0; width: 28%; max-height: 92%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.yd-banner { display: flex; align-items: center; gap: 8px; }
.yd-banner-face { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: #fdf6e3; }
.yd-bub-in { display: flex; align-items: center; gap: 10px; }
.yd-face { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: #efe6cf; }
.yd-face-akari { object-position: 50% 6%; }
.yd-face.locked { filter: brightness(0) opacity(.35); }
.yd-mur.has-face { display: flex; gap: 10px; align-items: flex-start; }
.yd-rw-img { width: 52px; height: 52px; object-fit: contain; display: block; }
.yd-dawn-img { display: block; width: calc(100% + 32px); margin: -16px -16px 10px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 18px 18px 0 0; }
.yd-res-face { display: block; width: 84px; height: 84px; border-radius: 50%; object-fit: cover; margin: 0 auto 4px; background: #efe6cf; }
