:root {
  --sky: #7EC8F2; --cloud: #FFF4E2; --storm: #4B5566; --red: #E8574A; --gold: #F2C14E; --ink: #2a2430;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --fs: clamp(11px, 2.1vmin + 4px, 18px);
  --font: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7EC8F2; font-family: var(--font); color: var(--ink); overscroll-behavior: none; }
#app { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; font-size: var(--fs); }
#ui button, #ui a, #ui .chip, #ui #bar, #ui input, #ui .card, #ui .note { pointer-events: auto; }
button { font-family: var(--font); color: var(--ink); cursor: pointer; white-space: nowrap; border: 3px solid var(--ink); border-radius: 999px; background: #fff; font-weight: 700; box-shadow: 0 3px 0 var(--ink); transition: transform .12s, box-shadow .12s, opacity .2s; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button.big { font-size: clamp(14px, 2.6vmin + 6px, 24px); padding: .5em 1.4em; background: var(--red); color: #fff; }
button.mid { font-size: clamp(12px, 1.9vmin + 5px, 19px); padding: .45em 1.1em; background: var(--gold); }
button.small { font-size: clamp(11px, 1.4vmin + 5px, 16px); padding: .35em .8em; }
button.ghost { background: #fff; }
button[disabled] { opacity: .45; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; }
.screen.on, .panel.on, .askbox.on, #morning.on, #ask.on { display: flex; }
.hint { z-index: 6; position: absolute; left: 50%; top: calc(var(--sat) + 10px); transform: translateX(-50%); max-width: 86vw; white-space: nowrap; font-weight: 700; font-size: clamp(11px, 1.6vmin + 6px, 17px); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(0,0,0,.4); opacity: 0; overflow: hidden; text-overflow: clip; }
.hint.on { opacity: 1; transition: opacity .25s; }
.iconbtn { z-index: 6; position: absolute; top: calc(var(--sat) + 8px); right: calc(var(--sar) + 8px); width: clamp(34px, 6vmin, 46px); height: clamp(34px, 6vmin, 46px); padding: 0; display: none; align-items: center; justify-content: center; background: rgba(255,255,255,.85); }
.iconbtn.on { display: flex; }
.pz { width: 38%; height: 42%; border-left: 4px solid var(--ink); border-right: 4px solid var(--ink); }
#anchors, #pops { position: absolute; inset: 0; }
.anc { position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 700; pointer-events: none; will-change: transform; }
.lbl { color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 5px rgba(0,0,0,.35), 1px 0 0 var(--ink), -1px 0 0 var(--ink); }
.dim { font-size: .82em; }
.clockBig { font-size: clamp(22px, 5vmin + 6px, 44px); letter-spacing: .02em; }
.warn { color: #ffe08a; }
.moon { color: #b9c8ff; }
.goldTxt { color: var(--gold); }
.pop { position: absolute; left: 0; top: 0; font-weight: 800; color: #fff; text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink); white-space: nowrap; pointer-events: none; font-size: clamp(14px, 2.4vmin + 6px, 26px); }
.pop.gold { color: var(--gold); }
.pop.blue { color: #bfe6ff; }
.drops { display: inline-flex; gap: 3px; font-size: 1.35em; }
.drop { width: .62em; height: .78em; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; border: 2px solid var(--ink); background: #fff; display: inline-block; }
.drop.full { background: #2d8fd8; }
.drop.wet { background: #3b5a7a; }
.pedal { display: block; }
/* タイトル */
#title { flex-direction: column; justify-content: space-between; align-items: center; padding: calc(var(--sat) + 3vh) calc(var(--sar) + 16px) calc(var(--sab) + 2.5vh) calc(var(--sal) + 16px); }
.logo { text-align: center; pointer-events: none; }
.logo .l1 { font-size: clamp(34px, 9vmin + 6px, 84px); font-weight: 900; color: #fff; letter-spacing: .06em; text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 8px 14px rgba(0,0,0,.25); }
.logo .l2 { display: inline-block; margin-top: .3em; font-size: clamp(14px, 3vmin + 4px, 28px); font-weight: 800; color: var(--ink); background: var(--gold); border: 3px solid var(--ink); padding: .1em .7em; border-radius: 8px; transform: rotate(-2deg); }
.titleBottom { display: flex; flex-direction: column; align-items: center; gap: min(1.6vh, 12px); width: 100%; max-width: 560px; }
.diffRow { display: flex; gap: min(2vw, 10px); justify-content: center; }
.dtag { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: clamp(11px, 1.5vmin + 5px, 16px); padding: .35em .6em; border-radius: 10px; background: #fffaf0; min-width: 5.2em; }
.dtag canvas { width: 2.2em !important; height: 1.6em !important; }
.dtag.sel { background: var(--sky); box-shadow: 0 3px 0 var(--ink), 0 0 0 3px #fff inset; }
.iconRow { display: flex; gap: min(2vw, 10px); flex-wrap: nowrap; justify-content: center; }
/* 朝 */
#morning { position: absolute; left: 0; right: 0; bottom: 0; display: none; flex-direction: column; align-items: center; gap: min(1.2vh, 10px); padding: 10px calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px); background: linear-gradient(to bottom, rgba(255,250,240,0), rgba(255,250,240,.9) 14%, rgba(255,250,240,.96)); }
#chips { display: flex; gap: min(1.5vw, 8px); justify-content: center; flex-wrap: nowrap; width: 100%; }
.chip { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding: 3px 2px 2px; flex: 0 1 15%; min-width: 0; max-width: 92px; cursor: pointer; transition: transform .15s, background .15s; box-shadow: 0 3px 0 var(--ink); }
.chip canvas { width: min(9vw, 44px, 7vh) !important; height: min(9vw, 44px, 7vh) !important; }
.chip .pl { font-size: clamp(9px, 1.2vmin + 4px, 13px); font-weight: 800; white-space: nowrap; }
.chip.in { background: #efe4ff; }
.chip.in .pl { color: #6b4fa8; }
.chip.out .pl { color: #2f7fb8; }
.chip.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#barWrap { width: 100%; max-width: 760px; }
#barInfo { display: flex; justify-content: space-between; font-weight: 800; font-size: clamp(11px, 1.5vmin + 5px, 16px); padding: 0 4px 2px; white-space: nowrap; gap: 8px; }
#bar { position: relative; height: clamp(88px, 15vmin, 124px); border: 3px solid var(--ink); border-radius: 12px; background: linear-gradient(#fffdf6, #fff6dc); overflow: hidden; touch-action: none; cursor: ew-resize; }
#bar .tick { position: absolute; bottom: 0; width: 1px; height: 14%; background: rgba(42,36,48,.35); }
#bar .tl { position: absolute; bottom: 2px; font-size: clamp(8px, 1vmin + 4px, 12px); transform: translateX(-50%); color: #6b6070; white-space: nowrap; }
#bar .work { position: absolute; top: 74%; height: 8%; background: #f7c88a; border-radius: 4px; }
#bar .band { position: absolute; top: 0; bottom: 16%; background: linear-gradient(to right, rgba(75,85,102,0.0), rgba(75,85,102,.55) 18%, rgba(70,120,200,.6) 50%, rgba(75,85,102,.55) 82%, rgba(75,85,102,0)); display: flex; align-items: flex-start; justify-content: center; }
#bar .band span { font-weight: 800; color: #fff; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink); font-size: clamp(9px, 1.2vmin + 5px, 14px); margin-top: 1px; white-space: nowrap; }
#bar .dew { position: absolute; top: 0; bottom: 16%; right: 0; background: rgba(40,50,110,.2); border-left: 2px dashed #3a4a9a; }
#bar .moonI { position: absolute; top: 2px; transform: translateX(-50%); font-size: clamp(10px, 1.3vmin + 5px, 15px); color: #2f3b8a; font-weight: 800; }
#bar .it { position: absolute; transform: translate(-50%, 0); transition: left .45s cubic-bezier(.3,1.4,.5,1), opacity .3s; width: clamp(16px, 3.2vmin, 26px); height: clamp(16px, 3.2vmin, 26px); }
#bar .it canvas, #bar .bike canvas, #bar .moonI canvas { width: 100% !important; height: 100% !important; display: block; }
#bar .moonI { width: clamp(12px, 2.4vmin, 18px); height: clamp(12px, 2.4vmin, 18px); }
#bar .it.late { opacity: .5; }
#bar .it i { position: absolute; right: -4px; top: -4px; font-style: normal; color: #D9534F; font-weight: 900; font-size: .8em; }
#bar .ride { position: absolute; top: 54%; height: 18%; background: rgba(232,87,74,.25); border-radius: 6px; transition: left .25s, width .25s; }
#bar .bike { position: absolute; top: 49%; transform: translate(-50%, 0); transition: left .25s; width: clamp(30px, 6vmin, 44px); height: clamp(22px, 4.4vmin, 32px); }
#bar .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); }
/* 店長 */
.askbox { position: absolute; left: 50%; bottom: calc(var(--sab) + 4vh); transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 8px; }
.bubble { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: .35em .9em; font-weight: 800; font-size: clamp(14px, 2.2vmin + 6px, 22px); white-space: nowrap; position: relative; }
.askBtns { display: flex; gap: 12px; }
/* 家計簿 */
#ledger { align-items: center; justify-content: center; padding: calc(var(--sat) + 8px) 12px calc(var(--sab) + 8px); }
.note { width: min(94vw, 460px); max-height: 94%; overflow: auto; background: repeating-linear-gradient(#fffdf5 0 1.9em, #d9e6f2 1.9em calc(1.9em + 1px)); border: 3px solid var(--ink); border-radius: 10px; padding: .6em 1em 1em; box-shadow: 0 6px 0 rgba(0,0,0,.25); position: relative; }
.note h2 { margin: .1em 0 .3em; font-size: 1.25em; }
.note .row { display: flex; justify-content: space-between; line-height: 1.9em; white-space: nowrap; gap: 10px; }
.note .row b { font-variant-numeric: tabular-nums; }
.note .minus { color: #c0392b; }
.note .plus { color: #1f7a3f; }
.note .sm { font-size: .8em; color: #6b6070; }
.note .left { font-size: 1.15em; font-weight: 900; }
.note .btns { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: .6em; }
.note .stamp { position: absolute; right: 12px; top: 8px; width: 74px; height: 74px; }
.note .ebikeRow { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pr { position: relative; display: inline-block; color: inherit; text-decoration: none; }
.pr .prmark { position: absolute; right: -2px; top: -2px; font-size: 9px; color: rgba(42,36,48,.45); font-weight: 700; letter-spacing: .02em; }
.anchLink { position: absolute; display: block; pointer-events: auto; }
/* モーダル */
.modal { align-items: center; justify-content: center; background: rgba(20,24,36,.45); pointer-events: auto; padding: 12px; }
.card { background: #fffdf6; border: 3px solid var(--ink); border-radius: 16px; padding: 1em 1.2em; width: min(94vw, 520px); max-height: 94%; overflow: auto; }
.card h2 { margin: 0 0 .5em; font-size: 1.2em; text-align: center; }
.step { display: flex; align-items: center; gap: .8em; margin: .5em 0; }
.step canvas { flex: 0 0 auto; width: 4.2em !important; height: 4.2em !important; border: 2px solid var(--ink); border-radius: 10px; background: #e8f5fd; }
.step p { margin: 0; font-weight: 700; line-height: 1.45; }
.joy { text-align: center; font-weight: 900; color: var(--red); margin-top: .6em; }
.prnote { text-align: center; font-size: .75em; color: #6b6070; margin-top: .6em; }
.tapclose { text-align: center; font-size: .8em; color: #8a8090; margin-top: .4em; }
.slider { display: flex; align-items: center; gap: 10px; margin: .6em 0; white-space: nowrap; }
.slider input { flex: 1; min-width: 60px; }
.card .btns { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: .5em; }
table.rec { width: 100%; border-collapse: collapse; }
table.rec td, table.rec th { border-bottom: 1px solid #d9d0c0; padding: .3em; text-align: center; white-space: nowrap; }
/* エンディング */
#ending { flex-direction: column; align-items: center; justify-content: flex-end; padding: 0 12px calc(var(--sab) + 2vh); }
.endMsg { text-align: center; margin-bottom: auto; margin-top: calc(50vh - 3.2em); }
.endMsg .big1 { font-size: clamp(26px, 7vmin + 4px, 60px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); white-space: nowrap; }
.endMsg .sub { font-weight: 800; color: #fff; text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.endBtns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 96vw; }
#fade { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
@media (orientation: landscape) {
  #morning { left: auto; top: 0; width: min(54vw, 560px); justify-content: center; background: linear-gradient(to right, rgba(255,250,240,0), rgba(255,250,240,.92) 8%, rgba(255,250,240,.97)); padding-top: calc(var(--sat) + 10px); }
  #chips { flex-wrap: nowrap; }
  #bar { height: clamp(64px, 16vh, 110px); }
  #title { flex-direction: column; align-items: center; padding-top: calc(var(--sat) + 2vh); }
  .titleBottom { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; max-width: 96vw; gap: 8px 14px; }
  .titleBottom .iconRow { flex-basis: 100%; }
  .logo .l1 { font-size: clamp(30px, 7vmin + 8px, 72px); }
}
@media (orientation: landscape) and (max-height: 420px) {
  .titleBottom { gap: 6px; }
  #morning { gap: 5px; }
  .chip canvas { width: min(6vw, 7vh); height: min(6vw, 7vh); }
}

/* 一時停止の操作説明 */
.ctrl { margin: 0 0 .8em; padding: .6em .7em; background: #eef7fd; border-radius: 10px; font-size: .88em; line-height: 1.5; }
.ctrl h3 { margin: 0 0 .35em; font-size: 1em; }
.ctrl .crow { display: grid; grid-template-columns: 6.2em 1fr; gap: .5em; padding: .2em 0; border-top: 1px dashed rgba(42,36,48,.18); }
.ctrl .crow:first-of-type { border-top: 0; }
.ctrl .ck { font-weight: 800; white-space: nowrap; }
.ctrl .y { color: #b8860b; } .ctrl .r { color: #E8574A; }

/* バイト中の「上がります」 */
.leaveBtn { position: absolute; left: 50%; bottom: calc(var(--sab) + 5vh); transform: translateX(-50%); display: none; background: #fff; }
.leaveBtn.on { display: block; }
.leaveBtn:active { transform: translateX(-50%) translateY(2px); }

/* 最後の朝：時間の帯は出さず、下に小さく「上がり20:00・外はどしゃ降り」と「いってきます」だけ */
#morning.final { left: 0; right: 0; top: auto; width: auto; background: linear-gradient(to bottom, rgba(255,250,240,0), rgba(255,250,240,.9) 30%); }
#morning.final #chips, #morning.final #bar { display: none; }
#morning.final #barWrap { max-width: 420px; }
