:root {
  --ink: #0f1b3d;
  --ink-2: #6b7385;
  --paper: #fafafa;
  --field: #f1f3f8;
}
* { box-sizing: border-box; }
html { overscroll-behavior: none; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  /* 縦の中央寄せは margin:auto で。align-items:center だと、背が高いとき上が切れて、スクロールで戻れない */
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* リングは画面の高さに合わせて縮める（広告枠ぶんを差し引く） */
  --ring: clamp(136px, calc(100dvh - 494px), 264px);
}
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.spin { transform-origin: 400px 400px; animation: spin linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.card {
  position: relative;
  background: rgba(255,255,255,.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 32px;
  box-shadow: 0 1px 2px rgba(15,27,61,.05), 0 16px 48px rgba(15,27,61,.10);
  padding: 20px 24px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.brand svg { width: 46px; height: 49px; }
.brand { margin-top: 0; font-weight: inherit; line-height: 1.2; }
.brand-text { display: flex; flex-direction: column; }
.brand-text small { font-size: 11px; font-weight: 500; letter-spacing: 0; color: #6b7385; margin-top: 2px; }
.brand span {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.ring-box {
  position: relative;
  width: var(--ring);
  height: var(--ring);
  margin: 0 auto;
}
.ring-box svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.ring-bg { fill: none; stroke: rgba(15,27,61,.08); stroke-width: 14; }
.ring-fg {
  fill: none;
  stroke: url(#ring-grad);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 754;
  stroke-dashoffset: 754;
}
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.amount {
  font-size: clamp(30px, calc(var(--ring) * 0.15), 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.unit {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .28em;
  padding-left: .28em;
  color: var(--ink-2);
  margin-top: 2px;
}
.elapsed {
  margin-top: 8px;
  letter-spacing: .06em;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: clamp(14px, 3dvh, 24px);
  padding: 12px 16px;
  background: rgba(241,243,248,.78);
  border-radius: 18px;
}
.field label { font-size: 13px; color: var(--ink-2); }
.field input {
  width: 120px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  color: var(--ink);
  outline: none;
}
.buttons { display: flex; gap: 10px; margin-top: 14px; }
button {
  height: 56px;
  border: 0;
  border-radius: 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background-position .3s ease, filter .2s ease, background-color .2s ease;
}
button:active { transform: translateY(0) scale(.97); }
button:focus-visible { outline: 3px solid #3a62b8; outline-offset: 2px; }
#toggleBtn {
  flex: 1;
  color: #fff;
  background: linear-gradient(135deg, #0f1b3d 0%, #1b3a82 55%, #e9b200 100%);
  background-size: 140% 140%;
  background-position: 0% 0%;
  box-shadow: 0 6px 16px rgba(15,27,61,.22);
}
/* 計測中は「停止」。赤みのあるローズで、押すと止まることが分かるようにする */
#toggleBtn.is-running {
  background: #c2335a;
  box-shadow: 0 6px 16px rgba(194,51,90,.28);
}
#resetBtn { flex: 0 0 96px; background: #fbe9ef; color: #c2335a; }
@media (hover: hover) {
  #toggleBtn:hover { transform: translateY(-2px); background-position: 100% 100%; box-shadow: 0 10px 24px rgba(15,27,61,.3); }
  #toggleBtn.is-running:hover { background: #a82a4c; box-shadow: 0 10px 24px rgba(194,51,90,.38); }
  #resetBtn:hover { transform: translateY(-2px); background: #f7d4df; }
}
/* 広告枠（いまはダミー）。操作ボタンとは .app の gap で離し、誤タップを避ける */
.ad {
  height: 92px;
  border: 1px dashed #aab3c8;
  border-radius: 12px;
  background: rgba(255,255,255,.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  color: #8a93a8;
  font-size: 11px;
  letter-spacing: .08em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.ad[hidden] { display: none; }
/* 商品カード形式（アフィリエイト）。中身が入ると .has-item が付く */
.ad.has-item { display: block; border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.62); padding: 0; }
.ad-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; height: 100%; padding: 12px 14px 12px 18px; color: inherit; text-decoration: none; text-align: left; letter-spacing: 0; }
.ad-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.ad-pr { font-size: 10px; line-height: 1; letter-spacing: .14em; padding: 3px 5px 3px 7px; border: 1px solid #c3cadb; border-radius: 2px; color: var(--ink-2); }
.ad-title { font-size: 14px; font-weight: 700; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ad-sub { flex: 0 0 auto; white-space: nowrap; font-size: 12px; font-weight: 700; line-height: 1; color: #0f1111; background: #ffd814; border-radius: 4px; padding: 9px 12px; transition: background-color .15s ease; }
@media (hover: hover) { .ad-card:hover .ad-sub { background: #f7ca00; } .ad-card:hover .ad-title { text-decoration: underline; } }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 12px; margin-top: -4px; }
.links a { color: #6b7385; text-decoration: none; white-space: nowrap; }
.links a:hover { text-decoration: underline; }
.links [hidden] { display: none; }
.lang { display: flex; justify-content: center; gap: 4px; font-size: 12px; margin-top: -4px; }
.lang a { color: #6b7385; text-decoration: none; padding: 3px 10px; border-radius: 999px; }
.lang a:hover { text-decoration: underline; }
.lang a[aria-current] { color: var(--ink); font-weight: 700; background: var(--field); }
/* 高い時給を入れたときの遊びのポップアップ */
.joke {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15,27,61,.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.joke[hidden] { display: none; }
.joke-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 28px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(15,27,61,.35);
  animation: pop .28s cubic-bezier(.2,1.3,.4,1);
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .joke-card { animation: none; } }
.joke-icon { width: 52px; height: 52px; margin: 0 auto; }
.joke-icon svg { display: block; width: 100%; height: 100%; }
.joke-title { margin: 12px 0 6px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.joke-body { margin: 0; font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.joke-body strong { color: var(--ink); }
.joke-ok { width: 100%; margin-top: 16px; color: #fff; background: linear-gradient(135deg, #0f1b3d 0%, #1b3a82 55%, #e9b200 100%); }
.joke-ok:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(58,98,184,.35); }
.joke-fix { width: 100%; height: 48px; margin-top: 10px; font-size: 14px; background: var(--field); color: var(--ink); }
@media (hover: hover) { .joke-fix:hover { background: #e6e9f2; } }
.joke-link { display: block; margin-top: 12px; font-size: 13px; color: var(--navy-2, #1b3a82); }
html.dark .joke-link { color: #9db8ee; }
/* ダークモード：闇バイトのポップアップで、どちらのボタンを押しても切り替わる（再読み込みで元に戻る） */
body, .card, .field, .ad, .links a, .lang a { transition: background-color .7s ease, color .7s ease, border-color .7s ease; }
html.dark { --ink: #e8ecf7; --ink-2: #9aa3bd; --paper: #080d1c; --field: #1a2340; color-scheme: dark; }
html.dark .bg { filter: invert(1) hue-rotate(180deg); opacity: .5; }
html.dark .card { background: rgba(20,28,56,.72); border-color: rgba(120,140,200,.22); box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 48px rgba(0,0,0,.55); }
html.dark .brand svg, html.dark .ring-box svg { filter: brightness(1.9) saturate(1.1); }
html.dark .ring-bg { stroke: rgba(232,236,247,.12); }
html.dark .field { background: rgba(26,35,64,.85); }
html.dark #resetBtn { background: #3a1a2a; color: #ff8aa8; }
html.dark .ad, html.dark .ad.has-item { background: rgba(20,28,56,.75); border-color: rgba(120,140,200,.22); }
html.dark .ad-pr { border-color: #4a5578; }
html.dark .links a { color: #9aa3bd; }
html.dark .lang a { color: #9aa3bd; }
html.dark .lang a[aria-current] { color: var(--ink); }
html.dark .brand-text small { color: #9aa3bd; }
html.dark .joke-card { background: #141c38; }
html.dark .joke-fix { background: #1f2a4d; }
.copy { margin: 0; text-align: center; font-size: 11px; color: #8a93a8; }
html.dark .copy { color: #6f7a99; }

/* 効果音のオンとオフ（カードの右上）。js/sound.js */
.snd { position: absolute; top: 16px; right: 18px; width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(15,27,61,.06); color: #1b3a82; transition: background-color .2s ease, color .2s ease, transform .15s ease; }
.snd svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.snd .off { display: none; }
.snd.off .on { display: none; }
.snd.off .off { display: block; }
.snd.off { color: #8a93a8; }
@media (hover: hover) { .snd:hover { background: rgba(15,27,61,.12); } }
html.dark .snd { background: rgba(232,236,247,.1); color: #9db8ee; }
html.dark .snd.off { color: #6b7385; }
@media (prefers-reduced-motion: reduce) { .snd { transition: none; } }
