/* 個人開発クエスト */
:root {
  --c-ink: #2f3138;
  --c-ink-sub: #6c6f78;
  --c-paper: #ffffff;
  --c-bg: #f2f6ee;
  --c-bg-deep: #dfead6;
  --c-line: #cfdcc6;
  --c-main: #2fa36b;
  --c-main-deep: #1d7a4e;
  --c-main-soft: #d8f2e3;
  --c-sky: #3a86d6;
  --c-sky-soft: #dceafa;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-pink: #ff7a8a;
  --c-bug: #e8513b;
  --c-bug-soft: #fde0da;
  --c-money: #f0a020;
  --c-money-soft: #fff0d0;
  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded", ui-rounded, system-ui, sans-serif;
  --border: 3px solid var(--c-ink);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--c-bg);
  background-image: radial-gradient(var(--c-bg-deep) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--c-ink); font-family: var(--font-base);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.app { position: relative; height: 100%; max-width: 520px; margin: 0 auto; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; padding: calc(12px + var(--safe-top)) 14px calc(12px + var(--safe-bottom)); }
.screen.is-active { display: flex; animation: fadein 0.25s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ボタン */
.btn {
  display: block; width: 100%; max-width: 340px; padding: 14px 18px 15px;
  font-weight: 900; font-size: 19px; letter-spacing: 0.04em;
  background: var(--c-main); color: #fff; border: var(--border); border-radius: 999px;
  box-shadow: 0 6px 0 var(--c-ink); transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--c-ink); }
.btn--sub { background: var(--c-paper); color: var(--c-ink); font-size: 16px; padding: 11px 16px 12px; }
.btn:disabled { opacity: 0.5; }
.link-btn { background: none; border: 0; text-decoration: underline; font-weight: 800; font-size: 15px; color: var(--c-ink-sub); padding: 10px; }
.icon-btn { width: 36px; height: 36px; border: var(--border); border-radius: 50%; background: var(--c-paper); font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 var(--c-ink); padding: 0; }
.icon-btn:active { transform: translateY(3px); box-shadow: none; }

/* タイトル */
.screen--title { justify-content: center; gap: 14px; }
.screen--title > a.back-to-games { position: absolute !important; top: calc(12px + var(--safe-top)); left: 12px; z-index: 6; display: inline-flex; align-items: center; padding: 6px 12px 7px; font: 800 13px/1 var(--font-base); color: var(--c-ink); text-decoration: none; background: var(--c-paper); border: 3px solid var(--c-ink); border-radius: 999px; box-shadow: 0 3px 0 var(--c-ink); }
.screen--title > a.back-to-games[hidden] { display: none; }
.screen--title > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }
.logo { margin: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.logo__sub { padding: 5px 14px; border: var(--border); border-radius: 999px; background: var(--c-paper); font-size: 14px; font-weight: 900; box-shadow: 0 3px 0 var(--c-ink); }
.logo__main { margin-top: 12px; font-size: clamp(40px, 12vw, 56px); font-weight: 900; line-height: 1.1; color: var(--c-main); -webkit-text-stroke: 2px var(--c-ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--c-ink); letter-spacing: 0.04em; }
.hero { position: relative; width: 230px; height: 150px; }
.laptop { position: absolute; left: 30px; top: 12px; width: 170px; }
.laptop__screen { position: relative; height: 104px; border: var(--border); border-radius: 12px 12px 4px 4px; background: var(--c-sky-soft); display: flex; align-items: center; justify-content: center; }
.laptop__app { width: 52px; height: 52px; border: var(--border); border-radius: 14px; background: var(--c-main); color: #fff; font: 900 14px/1.05 var(--font-num); display: flex; align-items: center; justify-content: center; text-align: center; animation: bob 2.4s ease-in-out infinite; }
.laptop__badge { position: absolute; bottom: -12px; right: -26px; background: var(--c-gold); border: var(--border); border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 900; transform: rotate(-6deg); white-space: nowrap; }
.laptop__base { height: 14px; margin: 0 -14px; border: var(--border); border-radius: 0 0 12px 12px; background: var(--c-paper); }
.hero__mail { position: absolute; font-size: 26px; animation: bob 2s ease-in-out infinite; }
.hero__mail--1 { left: 0; top: 4px; animation-delay: -0.4s; }
.hero__mail--2 { right: 0; top: 0; animation-delay: -1s; }
.hero__mail--3 { left: 4px; top: 86px; animation-delay: -1.5s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.title__lead { margin: 0; text-align: center; font-weight: 800; line-height: 1.7; font-size: 15px; }
.title__lead b { color: var(--c-main-deep); }
.title__best { margin: 0; font-weight: 800; font-size: 14px; color: var(--c-ink-sub); }

/* ルール */
.screen--rules { justify-content: center; gap: 14px; }
.rules__title { margin: 0; font-size: 24px; font-weight: 900; }
.rules__list { margin: 0; padding: 16px 16px 16px 34px; background: var(--c-paper); border: var(--border); border-radius: var(--radius); font-size: 14.5px; line-height: 1.65; overflow: auto; max-height: 70dvh; }
.rules__list li + li { margin-top: 6px; }
.rules__list b { color: var(--c-main-deep); }

/* 計画画面 */
.screen--plan { padding: 0; align-items: stretch; }
.hud { padding: calc(8px + var(--safe-top)) 12px 8px; background: var(--c-paper); border-bottom: var(--border); }
.hud__top { display: flex; align-items: center; gap: 6px; }
.month { font-size: 22px; font-weight: 900; }
.month__of { font-weight: 800; color: var(--c-ink-sub); font-size: 14px; }
.months { flex: 1; display: flex; gap: 3px; margin: 0 6px; }
.months i { flex: 1; height: 8px; border-radius: 4px; background: var(--c-line); }
.months i.done { background: var(--c-main); }
.months i.now { background: var(--c-gold); outline: 2px solid var(--c-ink); }
.stats { display: grid; grid-template-columns: 1.1fr 0.8fr 1.2fr; gap: 6px; margin-top: 8px; }
.stat { border: var(--border); border-radius: 12px; padding: 4px 8px 5px; display: flex; flex-direction: column; min-width: 0; }
.stat--users { background: var(--c-main-soft); }
.stat--rating { background: #fff6d6; }
.stat--money { background: var(--c-money-soft); }
.stat__label { font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.stat__val { font-size: 21px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__val.pop { animation: pop 0.4s ease; }
@keyframes pop { 40% { transform: scale(1.15); } }
.star { color: var(--c-gold-deep); margin-right: 1px; }
.chips { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 800; padding: 2px 8px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-bg); }
.chip b { font-family: var(--font-num); margin-left: 2px; }
.chip--bug { background: var(--c-bug-soft); }
.chip--bug.is-many { background: var(--c-bug); color: #fff; }
.timebar { margin-top: 8px; }
.timebar__label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; }
.timebar__label b { font-size: 17px; }
.timebar__track { height: 14px; margin-top: 3px; border: var(--border); border-radius: 999px; background: var(--c-bg); overflow: hidden; }
.timebar__fill { display: block; height: 100%; width: 0; background: var(--c-sky); transition: width 0.2s; }
.timebar__track.is-full .timebar__fill { background: var(--c-pink); }
.timebar__track.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.timebar__money { margin-top: 3px; font-size: 12px; font-weight: 800; color: var(--c-ink-sub); text-align: right; }
.timebar__money.is-over { color: var(--c-bug); }

.plan { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 12px 16px; }
.sec { margin: 12px 2px 6px; font-size: 15px; font-weight: 900; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.sec__n { font-family: var(--font-num); background: var(--c-ink); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.sec__hint { font-size: 11px; color: var(--c-ink-sub); font-weight: 800; }
.inbox { display: flex; flex-direction: column; gap: 6px; }
.mail { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; background: var(--c-paper); border: var(--border); border-radius: 14px; animation: fadein 0.3s ease both; }
.mail__ico { font-size: 20px; }
.mail__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mail__from { font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.mail__tag { display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 10.5px; }
.mail--bug .mail__tag { background: var(--c-bug); }
.mail--req .mail__tag { background: var(--c-sky); }
.mail--ask .mail__tag { background: var(--c-money); }
.mail__text { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.reply { flex: none; min-width: 66px; padding: 6px 6px 7px; border: var(--border); border-radius: 12px; background: var(--c-bg); font-weight: 900; font-size: 13px; line-height: 1.15; box-shadow: 0 3px 0 var(--c-ink); }
.reply small { display: block; font-size: 11px; color: var(--c-ink-sub); }
.reply:active { transform: translateY(3px); box-shadow: none; }
.mail.is-on { background: var(--c-main-soft); }
.mail.is-on .reply { background: var(--c-main); color: #fff; }
.mail.is-on .reply small { color: #fff; }
.mail__hint { font-size: 10.5px; font-weight: 800; color: var(--c-ink-sub); margin-top: 1px; }
.final-banner { margin: 10px 0 0; padding: 7px 10px; border: var(--border); border-radius: 12px; background: var(--c-gold); font-size: 13px; font-weight: 900; text-align: center; }
.final-banner[hidden], .milestone[hidden] { display: none; }
.milestone { margin: 4px 0 2px; padding: 4px 14px; border: var(--border); border-radius: 999px; background: var(--c-gold); font-size: 14px; font-weight: 900; animation: pop 0.4s ease 0.3s both; }
.report__notes li.advice { margin-top: 4px; padding: 6px 8px; border-radius: 10px; background: var(--c-sky-soft); color: var(--c-ink); }
.result__style { margin: 0; font-size: 14px; font-weight: 900; color: var(--c-main-deep); text-align: center; }
.inbox__empty { font-size: 13px; font-weight: 800; color: var(--c-ink-sub); padding: 6px 4px; }

.acts { display: flex; flex-direction: column; gap: 6px; }
.act { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; background: var(--c-paper); border: var(--border); border-radius: 14px; }
.act.is-on { background: var(--c-sky-soft); }
.act--money.is-on { background: var(--c-money-soft); }
.act__ico { font-size: 22px; }
.act__body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.act__name { font-size: 15px; }
.act__cost { font-family: var(--font-num); font-size: 12px; font-weight: 900; padding: 0 7px; border-radius: 999px; background: var(--c-ink); color: #fff; }
.act--money .act__cost { background: var(--c-money); color: var(--c-ink); }
.act__eff { flex-basis: 100%; font-size: 11.5px; font-weight: 700; color: var(--c-ink-sub); }
.stepper { flex: none; display: flex; align-items: center; gap: 4px; }
.step { width: 38px; height: 38px; border: var(--border); border-radius: 12px; background: var(--c-paper); font-weight: 900; font-size: 20px; line-height: 1; padding: 0; box-shadow: 0 3px 0 var(--c-ink); }
.step--plus { background: var(--c-gold); }
.step:active { transform: translateY(3px); box-shadow: none; }
.step--plus.is-ng { opacity: 0.45; }
.step:disabled { opacity: 0.35; box-shadow: none; transform: translateY(3px); }
.step__n { min-width: 20px; text-align: center; font-size: 20px; font-weight: 900; }
.plan__foot { margin: 10px 0 0; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); text-align: center; }
.plan__go { padding: 10px 14px calc(12px + var(--safe-bottom)); background: var(--c-paper); border-top: var(--border); display: flex; justify-content: center; }

.toast { position: absolute; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); margin: 0; padding: 8px 14px; background: var(--c-ink); color: #fff; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.is-show { opacity: 1; }

/* 月末レポート */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom)); background: rgba(40, 44, 50, 0.45); }
.modal[hidden] { display: none; }
.report { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; background: var(--c-paper); border: var(--border); border-radius: 22px; padding: 14px 16px 16px; box-shadow: 0 8px 0 var(--c-ink); animation: popin 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both; display: flex; flex-direction: column; align-items: center; }
@keyframes popin { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.report__title { margin: 0; font-size: 18px; font-weight: 900; }
.report__users { display: flex; align-items: baseline; gap: 4px; margin-top: 4px; }
.report__big { font-size: 46px; font-weight: 900; color: var(--c-main-deep); }
.report__unit { font-weight: 900; }
.report__delta { margin-left: 6px; font-family: var(--font-num); font-weight: 900; font-size: 18px; }
.up { color: var(--c-main-deep); }
.down { color: var(--c-bug); }
.report__delta.up::before { content: "▲"; font-size: 13px; margin-right: 2px; }
.report__delta.down::before { content: "▼"; font-size: 13px; margin-right: 2px; }
.report__flow { margin: 2px 0 0; display: flex; gap: 14px; font-size: 13px; font-weight: 800; }
.event { width: 100%; margin-top: 10px; padding: 8px 12px; border: var(--border); border-radius: 14px; background: #fff6d6; display: flex; flex-direction: column; gap: 2px; animation: popin 0.35s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.event[hidden] { display: none; }
.event.is-bad { background: var(--c-bug-soft); }
.event__title { font-size: 15px; }
.event__text { font-size: 12.5px; font-weight: 700; line-height: 1.45; }
.report__rows { width: 100%; list-style: none; margin: 10px 0 0; padding: 0; font-size: 14px; font-weight: 800; }
.report__rows li { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 2px dashed var(--c-line); }
.report__rows li span:last-child { font-family: var(--font-num); }
.report__notes { width: 100%; list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; font-weight: 800; color: var(--c-main-deep); }
.report__notes li.bad { color: var(--c-bug); }
.report__notes:empty { display: none; }
.review { position: relative; width: 100%; margin: 12px 0 14px; padding: 8px 12px; border: 2px solid var(--c-ink); border-radius: 14px; background: var(--c-bg); font-size: 13px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.review__stars { color: var(--c-gold-deep); letter-spacing: 1px; }
.review__name { margin-left: auto; font-size: 11px; color: var(--c-ink-sub); }

/* 結果 */
.screen--result { justify-content: center; gap: 8px; overflow-y: auto; }
.result__kicker { margin: 0; font-weight: 900; color: var(--c-ink-sub); }
.result__rank { margin: 0; padding: 6px 18px; font-size: 24px; font-weight: 900; background: var(--c-gold); border: var(--border); border-radius: 999px; box-shadow: 0 4px 0 var(--c-ink); text-align: center; animation: popin 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.result__score { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.result__label { font-weight: 900; }
.result__score .num { font-size: 52px; font-weight: 900; color: var(--c-main-deep); }
.result__new { margin: 0; padding: 2px 12px; border-radius: 999px; background: var(--c-pink); color: #fff; font-weight: 900; font-size: 14px; animation: pop 0.6s ease 2; }
.result__break { margin: 0; font-size: 13px; font-weight: 800; color: var(--c-ink-sub); }
.result__chart { width: 100%; max-width: 380px; height: 150px; background: var(--c-paper); border: var(--border); border-radius: var(--radius); padding: 6px; }
.result__chart canvas { width: 100%; height: 100%; display: block; }
.result__next, .result__tip { margin: 0; font-size: 13.5px; font-weight: 800; text-align: center; line-height: 1.5; }
.result__tip { color: var(--c-ink-sub); font-size: 12.5px; }
.result__btns { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }

.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate { display: flex; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; background: var(--c-bg); font-size: 20px; font-weight: 900; }
}
@media (max-height: 680px) {
  .hero { display: none; }
  .stat__val { font-size: 18px; }
  .report__big { font-size: 38px; }
  .result__chart { height: 110px; }
  .result__score .num { font-size: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
