:root {
  --cream: #fff7ea;
  --dot: #ffe6ec;
  /* 文字と線は、ゆずまるの髪に合わせたこげ茶 */
  --ink: #5b4034;
  --ink-soft: #8c7265;
  --pink: #ff8fab;
  --pink-deep: #f0577f;
  --pink-soft: #ffe1ea;
  --mint: #7fd8be;
  --mint-deep: #23997b;
  --mint-soft: #ddf6ee;
  --sky: #86bfff;
  --sky-deep: #3a86de;
  --sky-soft: #e1efff;
  /* ゆずの黄色 */
  --lemon: #ffcb45;
  --lemon-soft: #fff1c4;
  --lav: #cfc3f5;
  --line: 3px solid var(--ink);
  --font-display: 'Mochiy Pop One', 'Zen Maru Gothic', sans-serif;
  --font-body: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  --font-num: 'M PLUS Rounded 1c', 'Zen Maru Gothic', sans-serif;
  --font-lcd: 'DotGothic16', monospace;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--cream);
  background-image: radial-gradient(var(--dot) 2.5px, transparent 3px);
  background-size: 28px 28px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--sky-deep);
  outline-offset: 3px;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 0.4em;
  font-family: var(--font-num);
  font-size: 0.85em;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--ink);
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

.brand__mark {
  width: 30px;
  height: 30px;
  transform: rotate(-8deg);
}

.toggles {
  display: flex;
  gap: 8px;
}

.toggle {
  padding: 4px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--lemon);
  border: 2.5px solid var(--ink);
  border-radius: 99px;
  cursor: pointer;
}

.toggle[aria-pressed='false'] {
  color: var(--ink-soft);
  background: #fff;
}

/* ---------- 共通 ---------- */

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.hint {
  margin-top: 18px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font: inherit;
  font-weight: 900;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  border: var(--line);
  border-radius: 99px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn--primary {
  background: var(--lemon);
}

.btn--share {
  background: var(--sky-soft);
}

.btn--small {
  padding: 6px 18px;
  font-size: 0.9rem;
  box-shadow: 0 4px 0 var(--ink);
}

/* ---------- ゆずまる ---------- */

.mascot {
  position: relative;
}

.mascot__pic {
  display: block;
}

.mascot__pic img {
  display: block;
  width: 100%;
  height: auto;
}

/* 切りぬきシール風：白フチのまわりに線を1本 */
.mascot--sticker .mascot__pic img {
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff)
    drop-shadow(0 2px 0 var(--ink)) drop-shadow(0 -2px 0 var(--ink)) drop-shadow(2px 0 0 var(--ink))
    drop-shadow(-2px 0 0 var(--ink));
}

/* まるいバッジ（画像の下の切れ目は円でかくれる） */
.mascot--badge .mascot__pic {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--lemon-soft);
  border: var(--line);
  border-radius: 50%;
  box-shadow: 0 5px 0 var(--ink);
}

.mascot--badge .mascot__pic img {
  width: 88%;
  margin: 8% auto 0;
}

/* 気持ちのマーク（キラキラ・汗） */
.mascot__fx {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
}

.mascot[data-mood='happy'] .mascot__fx--happy,
.mascot[data-mood='oops'] .mascot__fx--oops {
  opacity: 1;
  animation: fx-pop 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes fx-pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

.mascot[data-mood='happy'] .mascot__pic {
  animation: hop 0.3s ease-in-out 2;
}

@keyframes hop {
  50% {
    transform: translateY(-8%);
  }
}

.mascot[data-mood='oops'] .mascot__pic {
  animation: wobble 0.3s ease-in-out;
}

@keyframes wobble {
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* ---------- タイトル ---------- */

.hero {
  padding: 4px 0 26px;
  text-align: center;
}

/* 胸から下はロゴのキーのうしろにかくす */
.hero__mascot {
  width: 190px;
  margin: 0 auto -44px;
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

/* ロゴは1文字ずつ電卓のキーにする */
.logo {
  position: relative;
  display: flex;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(3rem, 15vw, 4.8rem);
  font-weight: 400;
  line-height: 1;
}

.logo span {
  display: grid;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  border: var(--line);
  border-radius: 0.3em;
  box-shadow: 0 0.12em 0 var(--ink);
}

/* キーどうしを少し重ねて、うしろのゆずまるの切れ目が見えないようにする */
.logo span + span {
  margin-left: -0.05em;
}

.logo span:nth-child(1) {
  background: var(--lemon);
  transform: rotate(-5deg);
}

.logo span:nth-child(2) {
  z-index: 1;
  background: var(--pink);
  transform: rotate(3deg) translateY(6px);
}

.logo span:nth-child(3) {
  background: var(--mint);
  transform: rotate(-3deg);
}

.logo__read {
  margin-top: 20px;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.5em;
  color: var(--ink-soft);
}

.hero__tagline {
  margin-top: 10px;
  font-weight: 700;
  text-wrap: balance;
}

.setup {
  max-width: 900px;
  margin: 0 auto;
}

.setup__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 26px 0 14px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
}

.setup__title span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
}

.picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.picker__item {
  padding: 8px 22px;
  font: inherit;
  font-weight: 900;
  color: var(--ink);
  background: #fff;
  border: var(--line);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.picker__item[aria-checked='true'] {
  background: var(--lemon);
  box-shadow: 0 1px 0 var(--ink);
  transform: translateY(3px);
}

.picker__item[aria-checked='true']::before {
  content: '✓ ';
}

.picker__copy {
  text-wrap: balance;
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
}

.courses {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.course {
  --c: var(--mint);
  --c-soft: var(--mint-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 30px 14px 18px;
  overflow: hidden;
  font: inherit;
  color: inherit;
  text-align: center;
  background: #fff;
  border: var(--line);
  border-radius: 22px;
  box-shadow: 0 7px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.course--pink {
  --c: var(--pink);
  --c-soft: var(--pink-soft);
}

.course--sky {
  --c: var(--sky);
  --c-soft: var(--sky-soft);
}

.course::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 14px;
  background: var(--c);
  border-bottom: var(--line);
}

.course:hover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 11px 0 var(--ink);
}

.course:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--ink);
}

.course__key {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-family: var(--font-num);
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--c);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 4px 0 var(--ink);
}

.course__name {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.course__copy {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.course__spec {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.course__spec span {
  padding: 1px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--c-soft);
  border-radius: 99px;
}

.course__best {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------- ゲーム：HUD ---------- */

.hud {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  max-width: 920px;
  margin: 4px auto 0;
}

.hud__box {
  padding: 8px 16px;
  background: #fff;
  border: var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}

.hud__timer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.hud__timer-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}

.hud__timer-top b,
.hud__value b {
  font-family: var(--font-num);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.hud__bar {
  height: 14px;
  overflow: hidden;
  background: var(--mint-soft);
  border: 2px solid var(--ink);
  border-radius: 99px;
}

.hud__bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--mint);
}

.hud__timer.is-hurry .hud__bar span {
  background: var(--pink-deep);
}

.hud__timer.is-hurry b {
  color: var(--pink-deep);
}

.hud__stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 132px;
}

.hud__label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.hud__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__value small {
  font-size: 0.8rem;
  font-weight: 700;
}

.hud__stat.is-clear {
  background: var(--lemon-soft);
}

.toast {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  z-index: 6;
  padding: 4px 18px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--lemon);
  border: var(--line);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast.is-show {
  animation: toast 1.5s ease-out both;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
  }
  12% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
  20%,
  75% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

/* ---------- ゲーム：机の上 ---------- */

.desk {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 460px) auto;
  gap: 44px;
  align-items: center;
  justify-content: center;
  padding: 86px 0 12px;
  user-select: none;
}

.slip-area {
  position: relative;
}

/* 伝票のうしろから顔を出す */
.slip-area__mascot {
  position: absolute;
  top: -106px;
  right: 22px;
  width: 128px;
}

.slip-stack {
  position: relative;
  perspective: 1400px;
}

/* 下にかさなっている伝票 */
.slip-stack::before,
.slip-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  border: var(--line);
  border-radius: 14px;
}

.slip-stack::before {
  transform: rotate(2.2deg) translate(6px, 9px);
}

.slip-stack::after {
  transform: rotate(-1.4deg) translate(-4px, 5px);
}

.slip {
  --slip: var(--pink);
  --slip-deep: var(--pink-deep);
  --slip-soft: var(--pink-soft);
  position: relative;
  z-index: 1;
  padding: 14px 18px 10px 50px;
  overflow: hidden;
  background: #fff;
  border: var(--line);
  border-radius: 14px;
}

.slip--out {
  --slip: var(--sky);
  --slip-deep: var(--sky-deep);
  --slip-soft: var(--sky-soft);
}

.slip--transfer {
  --slip: var(--mint);
  --slip-deep: var(--mint-deep);
  --slip-soft: var(--mint-soft);
}

/* とじ穴とミシン目 */
.slip::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 34px;
  background: radial-gradient(circle, var(--cream) 5px, var(--ink) 5.5px, var(--ink) 7px, transparent 7.5px) center / 34px 54px
    repeat-y var(--slip-soft);
  border-right: 2.5px dashed var(--slip);
}

.slip__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 4px double var(--slip);
}

.slip__type {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  color: var(--slip-deep);
}

.slip__no {
  font-family: var(--font-num);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.slip__note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 8px;
  white-space: nowrap;
}

.slip__note span {
  flex: none;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--slip-deep);
  background: var(--slip-soft);
  border-radius: 6px;
}

.slip__note b {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
}

.slip__units,
.cells {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.slip__units {
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--slip-deep);
  text-align: center;
}

.cells {
  overflow: hidden;
  font-family: var(--font-num);
  font-size: clamp(1.7rem, 7.4vw, 2.8rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: #fff;
  border: 2.5px solid var(--slip);
  border-radius: 10px;
  transition: box-shadow 0.1s;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  height: 1.5em;
  border-left: 1.5px solid var(--slip-soft);
}

.cell:first-child {
  border-left: 0;
}

/* 3ケタごとの太い線（カンマのかわり） */
.cell:nth-last-child(3n + 3):not(:first-child) {
  border-left: 2.5px solid var(--slip);
}

.cell--yen {
  font-size: 0.62em;
  color: var(--ink-soft);
}

.cell.is-done {
  color: var(--slip-deep);
  background: var(--slip-soft);
}

.cell.is-next {
  background: var(--lemon-soft);
}

.cell.is-next::after {
  content: '';
  position: absolute;
  inset: auto 14% 3px;
  height: 4px;
  background: var(--lemon);
  border-radius: 99px;
}

.slip.is-ready .cells {
  box-shadow: 0 0 0 4px var(--lemon);
}

.slip__turn {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--slip-deep);
  text-align: right;
  visibility: hidden;
}

.slip.is-ready .slip__turn {
  visibility: visible;
  animation: nudge 0.5s ease-in-out infinite alternate;
}

@keyframes nudge {
  to {
    transform: translateX(-6px);
  }
}

.slip.is-miss {
  animation: shake 0.22s;
}

@keyframes shake {
  25% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(7px);
  }
}

/* めくられていく伝票（左とじのページをめくる動き） */
.slip--leaving {
  position: absolute;
  inset: 0;
  z-index: 2;
  transform-origin: left center;
  animation: turn 0.34s cubic-bezier(0.4, 0, 0.9, 0.5) forwards;
  pointer-events: none;
}

@keyframes turn {
  60% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotateY(-100deg);
  }
}

.hanko {
  position: absolute;
  top: 44px;
  right: 22px;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: #e5484d;
  border: 4px solid #e5484d;
  border-radius: 50%;
  transform: rotate(-14deg);
  animation: stamp 0.14s ease-out;
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: rotate(-14deg) scale(1.8);
  }
}

/* ---------- ゲーム：電卓 ---------- */

.calc {
  --calc: var(--lav);
  --cols: 4;
  --key-h: 60px;
  width: calc(var(--cols) * 72px + 40px);
  max-width: 100%;
  padding: 14px 16px 18px;
  background: var(--calc);
  border: var(--line);
  border-radius: 26px;
  box-shadow: 0 8px 0 var(--ink);
}

.calc[data-layout='casio'] {
  --calc: #ffb7c9;
}

.calc[data-layout='sharp'] {
  --calc: #a5e5d2;
}

.calc__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 8px;
}

.calc__brand {
  font-family: var(--font-num);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.calc__solar {
  width: 76px;
  height: 18px;
  background: repeating-linear-gradient(90deg, #7b5b4d 0 17px, var(--ink) 17px 19px);
  border: 2px solid var(--ink);
  border-radius: 5px;
}

.calc__lcd {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 58px;
  padding: 0 12px;
  margin-bottom: 14px;
  overflow: hidden;
  font-family: var(--font-lcd);
  font-size: 1.9rem;
  line-height: 1;
  background: #e2f1dc;
  border: var(--line);
  border-radius: 12px;
  box-shadow: inset 0 4px 0 rgba(91, 64, 52, 0.12);
}

.calc__keys {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: var(--key-h);
  gap: 10px 9px;
}

.key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--font-num);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.05s, box-shadow 0.05s;
}

.key small {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 700;
}

.key--plus,
.key--equal {
  background: var(--lemon);
}

.key--enter {
  font-size: 0.95rem;
  background: var(--pink);
}

/* 入力には使わない、位置あわせ用のキー */
.key--dummy {
  font-size: 1rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(91, 64, 52, 0.5);
  box-shadow: 0 4px 0 rgba(91, 64, 52, 0.5);
}

.key.is-next {
  box-shadow: 0 4px 0 var(--ink), 0 0 0 3px #fff, 0 0 0 7px var(--pink-deep);
}

.key.is-pressed {
  background: var(--lemon-soft);
  box-shadow: 0 1px 0 var(--ink);
  transform: translateY(3px);
}

.key.is-wrong {
  background: #ff9c9c;
  animation: shake 0.2s;
}

/* ---------- ゲーム：カウントダウン ---------- */

.overlay {
  position: absolute;
  inset: 0 -12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 247, 234, 0.9);
  border-radius: 24px;
  /* カウントダウン中に金額を先読みできないようにぼかす */
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.overlay__text {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 16vw, 6rem);
  line-height: 1.1;
  color: var(--pink-deep);
  text-shadow: 0 5px 0 var(--ink);
  -webkit-text-stroke: 2px var(--ink);
}

.overlay__text.is-pop {
  animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

.overlay__sub {
  font-weight: 900;
}

/* ---------- 結果 ---------- */

.result {
  max-width: 560px;
  padding: 22px 24px 28px;
  margin: 8px auto 0;
  text-align: center;
  background: #fff;
  border: var(--line);
  border-radius: 26px;
  box-shadow: 0 8px 0 var(--ink);
}

.result__course {
  display: inline-block;
  padding: 2px 18px;
  font-weight: 900;
  background: var(--lemon);
  border: 2.5px solid var(--ink);
  border-radius: 99px;
}

.result__mascot {
  width: 112px;
  margin: 14px auto 10px;
}

.result__mascot[data-mood='happy'] .mascot__fx--happy {
  animation: twinkle 0.9s ease-in-out infinite alternate;
}

@keyframes twinkle {
  to {
    transform: scale(1.08) rotate(4deg);
  }
}

.result__mascot[data-mood='oops'] .mascot__pic {
  transform: rotate(-7deg);
}

.result__verdict {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--pink-deep);
}

.result__sub {
  font-weight: 700;
}

.result__rank {
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px;
  margin: 18px 0;
  background: var(--pink-soft);
  border: 2.5px dashed var(--pink);
  border-radius: 16px;
}

.result__rank span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.result__rank strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
}

.result__rank em {
  font-size: 0.9rem;
  font-style: normal;
  font-weight: 700;
}

.result__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.result__stats div {
  padding: 8px 4px;
  background: var(--cream);
  border-radius: 12px;
}

.result__stats dt {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.result__stats dd {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.result__stats b {
  margin: 0 2px;
  font-family: var(--font-num);
  font-size: 1.35rem;
  font-weight: 800;
}

/* 合計金額はケタが多く、スマホではワクからはみ出す。文字数（--chars は game.js が入れる）に合わせて小さくする */
.result__total {
  container-type: inline-size;
}

.result__total b {
  font-size: min(1.35rem, calc((100cqi - 0.9rem) / (var(--chars, 6) * 0.6)));
}

.result__best {
  min-height: 1.7em;
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.result__best.is-new {
  color: var(--pink-deep);
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 12px;
  justify-content: center;
  margin-top: 14px;
}

/* ---------- 広告枠・あそびかた・フッター ---------- */

.ad-slot {
  max-width: 728px;
  margin: 0 auto;
  text-align: center;
}

/* 幅がないと広告を読みこめないので、枠いっぱいに広げておく */
.ad-slot ins {
  display: block;
  width: 100%;
}

/* 広告が実際に入るまで（読みこみ中や、出せる広告がなかったとき）は、場所を取らない。
   枠ごと display:none にすると広告を読みこめなくなるので、高さだけ 0 にしておく */
.ad-slot ins:not([data-ad-status='filled']) {
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden;
}

/* 広告が入ったら、余白と「スポンサーリンク」の表示を出す。
   上の余白は、コースのボタンから広告まで 150px ほど離すための大きさ */
.ad-slot:has(ins[data-ad-status='filled']) {
  margin-top: 110px;
}

.ad-slot:has(ins[data-ad-status='filled'])::before {
  content: 'スポンサーリンク';
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* 広告の部品がないとき（手元での確認、プレイ中）は、枠ごと表示しない */
.ad-slot:empty {
  display: none;
}

/* 誤クリックをふせぐため、プレイ中は広告を出さない（Google はゲームから 150px 以上離すか、外すことを推奨）。
   プレイ中は js/ads.js が広告を取り外すので、ここはその念のための指定 */
body[data-screen='game'] .ad-slot {
  display: none;
}

/* 結果画面でも「もう一回」ボタンから 150px ほど離す */
body[data-screen='result'] .ad-slot:has(ins[data-ad-status='filled']) {
  margin-top: 122px;
}

.howto {
  max-width: 900px;
  margin: 44px auto 0;
}

body:not([data-screen='title']) .howto {
  display: none;
}

.howto__title {
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  text-align: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 18px 16px 14px;
  background: #fff;
  border: var(--line);
  border-radius: 18px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: -14px;
  left: 14px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-family: var(--font-num);
  font-weight: 800;
  background: var(--lemon);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
}

.steps p,
.tip p {
  margin-top: 6px;
  font-size: 0.9rem;
}

.tips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.tip {
  padding: 16px 18px;
  background: var(--mint-soft);
  border: var(--line);
  border-radius: 18px;
}

.tip:nth-child(2) {
  background: var(--sky-soft);
}

.tip h3,
.about h3 {
  font-size: 1rem;
  font-weight: 900;
}

/* ゆずまるの紹介 */
.about {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
  margin-top: 16px;
  background: #fff;
  border: var(--line);
  border-radius: 18px;
}

.about__photo {
  width: 104px;
  height: auto;
  padding: 5px 5px 16px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-4deg);
}

.about p {
  margin: 6px 0 12px;
  font-size: 0.9rem;
}

.site-footer {
  padding: 28px 20px 36px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.site-footer__links a {
  color: var(--ink);
}

.site-footer__note {
  max-width: 640px;
  margin: 4px auto 0;
  font-size: 0.72rem;
}

/* ---------- スマホ・タブレット ---------- */

@media (max-width: 860px) {
  .courses,
  .steps,
  .tips {
    grid-template-columns: minmax(0, 1fr);
  }

  .course {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 14px;
    align-items: center;
    padding: 26px 16px 14px;
    text-align: left;
  }

  .course__key {
    grid-row: span 4;
  }

  .course__name {
    margin-top: 0;
  }

  .course__spec {
    justify-content: flex-start;
    margin-top: 4px;
  }

  .course__best {
    margin-top: 2px;
  }

  .steps {
    gap: 24px;
  }

  .picker {
    gap: 6px;
  }

  .picker__item {
    padding: 7px 11px;
    font-size: 0.82rem;
  }

  /* ゲーム中はスクロールなしで1画面におさめる（タップ中に画面が動かないように） */
  body[data-screen='game'] .site-header,
  body[data-screen='game'] .site-footer,
  .slip-area__mascot,
  .calc__top,
  .hint--game {
    display: none;
  }

  body[data-screen='game'] main {
    padding: 10px 14px 0;
  }

  .toast {
    top: 2px;
    font-size: 0.9rem;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .hud__box {
    padding: 4px 12px;
    border-radius: 12px;
    box-shadow: 0 3px 0 var(--ink);
  }

  .hud__timer {
    grid-column: 1 / -1;
    padding-bottom: 8px;
  }

  .hud__stat {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
  }

  .hud__timer-top b,
  .hud__value b {
    font-size: 1.3rem;
  }

  .hud__value small {
    font-size: 0.7rem;
  }

  .desk {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    justify-items: center;
    padding-top: 14px;
  }

  .slip-area {
    width: min(460px, 100%);
  }

  .slip {
    padding: 8px 12px 6px 44px;
  }

  .slip__note {
    margin: 6px 0 4px;
  }

  .slip__turn {
    margin-top: 4px;
  }

  .calc {
    --key-h: 52px;
    width: min(calc(var(--cols) * 76px + 30px), 100%);
    padding: 10px 12px 14px;
  }

  .calc__lcd {
    height: 46px;
    margin-bottom: 10px;
    font-size: 1.6rem;
  }

  .calc__keys {
    gap: 9px 7px;
  }

  .result {
    padding: 18px 14px 22px;
  }

  .result__stats {
    gap: 6px;
  }
}

/* 背のひくいスマホ（iPhone SE など） */
@media (max-width: 860px) and (max-height: 700px) {
  .calc {
    --key-h: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
