/* 禁コーラ — 白と水色（氷）。色を持つのはマスコットと王冠の履歴だけ、他は静かに */
:root {
  --bg: #f5f8fb;
  --card: #ffffff;
  --raised: #edf2f7;
  --hair: rgba(19, 34, 50, 0.09);
  --text: #132232;
  --text-2: #4b5a6b;
  --muted: #66727f;
  --accent: #0b6fa4;
  --accent-press: #095d8a;
  --ice: #e8f5fc;
  --ice-line: rgba(11, 111, 164, 0.14);
  --cola: #4b2513;
  --cola-face: #6a3a20;
  --danger: #b42318;

  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --font-round: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "M PLUS Rounded 1c", var(--font);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-control: 10px;
  --r-card: 16px;
  --shadow: 0 1px 2px rgba(19, 34, 50, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

p,
h2,
dl,
dd,
ol,
ul {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

a.btn {
  font: inherit;
}

.sprite {
  position: absolute;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ ヘッダー */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font: 600 18px/1 var(--font-round);
}

.brand-cap {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.today-date {
  color: var(--text-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ レイアウト */

.layout {
  display: grid;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.col {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

@media (min-width: 880px) {
  .top,
  .layout {
    padding-left: 32px;
    padding-right: 32px;
  }

  .layout {
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 24px;
  }
}

/* ------------------------------------------------------------ ステージ（マスコット） */

.stage {
  background: var(--ice);
  border: 1px solid var(--ice-line);
  border-radius: var(--r-card);
  padding: 16px 20px 24px;
  text-align: center;
}

.stage-art {
  display: flex;
  justify-content: center;
}

.stage-art svg {
  width: min(264px, 72vw);
  height: auto;
  display: block;
}

.stage-lead {
  margin-top: 4px;
  color: var(--text-2);
  font: 400 16px/24px var(--font-round);
}

.stage-result {
  margin-top: 4px;
  font: 600 28px/36px var(--font-round);
  min-height: 36px;
}

.stage[data-mode="idle"] .stage-result {
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
}

.stage-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 14px;
  min-height: 20px;
  font-variant-numeric: tabular-nums;
}

.stage-result.is-new {
  animation: rise 400ms var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------ 記録ボタン */

.record {
  display: grid;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--r-control);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: default;
}

.drank-row {
  display: flex;
  gap: 8px;
}

.stepper {
  display: flex;
  align-items: center;
  flex: none;
  height: 52px;
  border-radius: var(--r-control);
  background: var(--card);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
}

.step {
  display: grid;
  place-items: center;
  width: 40px;
  height: 100%;
  border: 0;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--r-control);
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.step:hover:not(:disabled) {
  background: var(--raised);
  color: var(--text);
}

.step:disabled {
  color: rgba(19, 34, 50, 0.25);
  cursor: default;
}

.stepper output {
  min-width: 40px;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.btn-drank {
  flex: 1;
  background: var(--card);
  border-color: var(--hair);
  box-shadow: var(--shadow);
  color: var(--cola);
}

.btn-drank:hover {
  background: #fbf7f4;
  border-color: rgba(75, 37, 19, 0.22);
}

.btn-skip {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.btn-skip:hover:not(:disabled) {
  background: var(--accent-press);
}

.btn-skip:disabled {
  background: var(--raised);
  color: var(--muted);
}

.record-note {
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}

.share {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 4px;
}

.btn-share {
  background: var(--text);
  color: #fff;
}

.btn-share:hover {
  background: #22364a;
}

.btn-quiet {
  background: var(--card);
  border-color: var(--hair);
  color: var(--text);
}

.btn-quiet:hover {
  background: var(--raised);
}

.link-undo {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.link-undo .icon {
  width: 16px;
  height: 16px;
}

.link-undo:hover {
  color: var(--text);
  background: var(--raised);
}

.toast {
  min-height: 20px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}

.toast.is-error {
  color: var(--danger);
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------ 統計 */

.stats,
.history {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r-card);
  padding: 20px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 16px;
}

.stat-total {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hair);
}

.stat-label,
.stat dt {
  color: var(--text-2);
  font-size: 13px;
  line-height: 20px;
}

.stat-figure {
  margin-top: 4px;
  font: 500 48px/1 var(--font-round);
  color: var(--cola);
  font-variant-numeric: tabular-nums;
}

.unit {
  margin-left: 4px;
  font-size: 0.42em;
  font-weight: 400;
  color: var(--text-2);
}

.stat-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 16px;
  padding-top: 20px;
}

.stat dd {
  margin-top: 4px;
  font: 500 28px/1 var(--font-round);
  font-variant-numeric: tabular-nums;
}

.stat dd .unit {
  font-size: 14px;
}

/* ------------------------------------------------------------ 30日カレンダー（王冠） */

.cal-head,
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-head span {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  padding-bottom: 8px;
}

.cal {
  list-style: none;
  padding: 0;
  row-gap: 8px;
}

.cal li {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.cal .day {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cal li.is-today .day {
  color: var(--accent);
  font-weight: 600;
}

.cap {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

.cap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cap-count {
  position: relative;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* <use> の中身にはセレクタが届かないので、継承される fill / stroke / color で塗り分ける */
.cap-drank svg {
  fill: var(--cola);
  color: var(--cola-face);
}

.cap-skipped svg {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.2;
  color: var(--ice);
}

.cap-none::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px dashed rgba(19, 34, 50, 0.2);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  list-style: none;
  padding: 16px 0 0;
  margin-top: 16px;
  border-top: 1px solid var(--hair);
  color: var(--text-2);
  font-size: 13px;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cap-mini {
  width: 16px;
  height: 16px;
}

.cap-mini.cap-none::before {
  width: 14px;
  height: 14px;
}

.cap-mini.cap-drank {
  background: var(--cola);
  border-radius: 50%;
}

.cap-mini.cap-skipped {
  background: #fff;
  border: 1.2px solid var(--accent);
  border-radius: 50%;
}

/* ------------------------------------------------------------ フッター */

.foot {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ------------------------------------------------------------ GIF シート */

.sheet {
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--hair);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(19, 34, 50, 0.08);
}

.sheet[open] {
  animation: rise 300ms var(--ease) both;
}

.sheet::backdrop {
  background: rgba(19, 34, 50, 0.32);
}

.sheet-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
}

.gif-frame {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--ice);
}

.gif-frame img {
  width: 100%;
  height: 100%;
  display: block;
}

.gif-frame img:not([src]) {
  visibility: hidden;
}

.gif-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sheet-note {
  margin-top: 12px;
  color: var(--text-2);
  font-size: 13px;
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
