/* 小銭へらしレジ。画面いっぱいの 3D の上に、レシートと財布のボタンを重ねる */

:root {
  --glass: rgba(20, 16, 13, 0.62);
  --glass-strong: rgba(20, 16, 13, 0.82);
  --border: rgba(255, 240, 220, 0.14);
  --text: #f6efe6;
  --muted: #c4b6a6;
  --accent: #ffb640;
  --accent-ink: #2a1800;
  --good: #6fe0a8;
  --paper: #fbf8f1;
  --ink: #2b2620;
  --font: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #14110f;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- 上のバー */
.bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }

.home, .pill {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}
.home:hover, .pill:hover { background: var(--glass-strong); }

.stat {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}
.stat b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---- レベルと称号（左上） */
.lvl {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 46px);
  left: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  row-gap: 5px;
  min-width: 170px;
  padding: 8px 12px 9px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12.5px;
}
.lvl__lv { font-weight: 800; color: var(--accent); font-size: 12px; }
.lvl__lv b { font-size: 17px; font-variant-numeric: tabular-nums; }
.lvl__title { font-weight: 800; white-space: nowrap; }
.lvl__bar { grid-column: 1 / -1; }
.lvl__bar, .xpbar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.lvl__bar i, .xpbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd27a, var(--accent));
  box-shadow: 0 0 10px rgba(255, 182, 64, 0.6);
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.lvl.is-up { animation: lvup 1.2s ease-out; }
@keyframes lvup {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 182, 64, 0.8); }
  25% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(255, 182, 64, 0.35); }
  100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(255, 182, 64, 0); }
}

/* ---- レシート */
.receipt {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 52px);
  right: 16px;
  width: 230px;
  margin: 0;
  padding: 14px 16px 18px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.4s, opacity 0.4s;
  /* 下の辺をギザギザに */
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
}
.receipt.is-done { opacity: 0.55; }
.receipt__shop {
  margin: 0 0 8px;
  text-align: center;
  font-family: var(--font);
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #1b6e4a;
  border-bottom: 1px dashed #b9b1a4;
  padding-bottom: 8px;
}
.receipt__lines {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  border-bottom: 1px dashed #b9b1a4;
  max-height: 30vh;
  overflow: auto;
}
.receipt__lines li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.receipt__lines small { color: #7a7166; }
.receipt__row { display: flex; justify-content: space-between; margin: 6px 0 0; }
.receipt__total { font-size: 16px; font-weight: 800; }
.receipt__total b { font-size: 20px; }
.receipt__need {
  margin: 10px 0 0;
  padding: 6px 8px;
  text-align: center;
  font-weight: 800;
  font-family: var(--font);
  background: #f3e2c8;
  color: #8a4b00;
  border-radius: 4px;
}
.receipt__need:empty { display: none; }
.receipt__need.is-ok { background: #d8f2e3; color: #11643c; }

/* ---- 財布の山の枚数 */
.labels { position: fixed; inset: 0; pointer-events: none; }
.badge {
  position: absolute;
  left: 0; top: 0;
  font: 800 13px/1 var(--font);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge.is-zero { opacity: 0.35; }

/* ---- 下のドック */
.dock {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(1100px, calc(100vw - 24px));
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.chips {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}
.chip { position: relative; display: flex; }
.chip__add {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: background 0.15s, transform 0.1s;
}
.chip__add:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); }
.chip__add:active:not(:disabled) { transform: scale(0.96); }
.chip__add:disabled { opacity: 0.38; }
.chip__name { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chip__have { font-size: 11px; color: var(--muted); }
.chip__have b { color: var(--text); font-size: 13px; }
.chip__minus {
  position: absolute;
  top: -8px;
  right: -4px;
  min-width: 34px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.chip__minus:disabled { display: none; }

.actions { display: flex; flex-direction: column; gap: 6px; width: 132px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); flex: 1.4; }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); flex: 1; }
.btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.btn:disabled { opacity: 0.35; }
.btn--big { font-size: 16px; padding: 13px 22px; }

/* 硬貨・お札のアイコン */
.money {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: none;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25), inset 0 -3px 4px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
}
.m1 { width: 22px; height: 22px; background: radial-gradient(circle at 35% 30%, #fdfdfd, #b9bcc0 60%, #8d9095); }
.m5 { width: 24px; height: 24px; background: radial-gradient(circle at 35% 30%, #fff1b8, #d7a640 60%, #9a6c18); }
.m10 { width: 25px; height: 25px; background: radial-gradient(circle at 35% 30%, #f6b48a, #b8643a 60%, #7a3a1c); }
.m50 { width: 23px; height: 23px; background: radial-gradient(circle at 35% 30%, #ffffff, #c4c3c0 60%, #8f8e8b); }
.m100 { width: 25px; height: 25px; background: radial-gradient(circle at 35% 30%, #ffffff, #c4c3c0 60%, #8f8e8b); }
.m500 { width: 28px; height: 28px; background: radial-gradient(circle at 35% 30%, #fbf6e2 0 30%, #d9cfa9 50%, #e8bf60 52%, #a8781f 100%); }
.m5::after, .m50::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1c1714;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
}
.m50::after { width: 5px; height: 5px; }
.m1000, .m5000, .m10000 { width: 34px; height: 18px; border-radius: 3px; margin: 4px 0; }
.m1000 { background: linear-gradient(135deg, #cfe0ea, #7fa6c4); }
.m5000 { background: linear-gradient(135deg, #e6dcef, #a58cc2); }
.m10000 { background: linear-gradient(135deg, #efe2cf, #b4916a); }

/* ---- 通知 */
.toast {
  z-index: 20;
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- モーダル */
.modal {
  z-index: 10;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 8, 6, 0.45);
  overflow: auto;
  animation: fade 0.25s ease-out;
}
.modal--result { background: linear-gradient(90deg, rgba(10, 8, 6, 0.45), transparent 60%); }
/* 広い画面では左に寄せ、トレーに出てきたお釣りが見えるようにする */
@media (min-width: 1000px) {
  .modal--result { place-items: center start; padding: 112px 16px 16px max(24px, 4vw); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(14px) scale(0.98); opacity: 0; } }

.card {
  width: min(520px, 100%);
  padding: 26px 26px 22px;
  border-radius: 22px;
  background: rgba(28, 22, 18, 0.9);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: pop 0.3s ease-out;
}
.card__kicker { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: 0.15em; color: var(--accent); }
.card h1 { margin: 0 0 10px; font-size: clamp(28px, 6vw, 38px); letter-spacing: 0.04em; }
.card__lead { margin: 0 0 14px; font-size: 15px; line-height: 1.7; color: var(--muted); }
.card__lead strong { color: var(--text); }
.card__best { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

.example {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.6;
}
.example p { margin: 2px 0; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.tag--good { background: rgba(111, 224, 168, 0.18); color: var(--good); }

.rules { margin: 0 0 18px; padding-left: 1.3em; font-size: 13.5px; line-height: 1.75; color: var(--muted); }
.rules b { color: var(--text); }
.card .btn--big { width: 100%; }

.card--result { width: min(460px, 100%); text-align: center; }
.grade { margin: 0 0 12px; font-size: 30px; font-weight: 900; letter-spacing: 0.04em; }
[data-lv="3"] .grade { color: var(--accent); text-shadow: 0 0 24px rgba(255, 182, 64, 0.5); }
[data-lv="2"] .grade { color: var(--good); }
[data-lv="0"] .grade { color: #ff8b7a; }
.compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.compare div { display: flex; flex-direction: column; align-items: center; }
.compare span { font-size: 12px; color: var(--muted); }
.compare b { font-size: 44px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.compare small { font-size: 12px; color: var(--muted); }
.compare .vs { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.pts { margin: 4px 0 14px; font-size: 22px; font-weight: 900; color: var(--accent); }
.pts small { margin-left: 8px; font-size: 13px; color: var(--good); }

.me {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 182, 64, 0.08);
  border: 1px solid rgba(255, 182, 64, 0.25);
}
.me__row { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; }
.me__lv { font-weight: 800; color: var(--accent); }
.me__lv b { font-size: 22px; font-variant-numeric: tabular-nums; }
.me__title { font-size: 17px; font-weight: 900; }
.me__next { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.xp {
  margin: 0 0 14px;
  padding: 10px 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  text-align: left;
}
.xp__row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 7px; font-size: 13.5px; font-weight: 800; }
.xp__row b { color: var(--accent); }
.xp__gain { font-variant-numeric: tabular-nums; }
.xp__rest { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.xp__up {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: center;
  font-weight: 900;
  font-size: 16px;
  color: var(--accent-ink);
  background: linear-gradient(90deg, #ffd27a, var(--accent), #ffd27a);
  background-size: 200% 100%;
  animation: shine 1.6s linear infinite, pop 0.35s ease-out;
}
.xp__up span { font-size: 13px; }
@keyframes shine { to { background-position: -200% 0; } }

.money-list {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 8px 10px;
  margin: 0 0 14px;
  text-align: left;
  font-size: 13px;
}
.money-list dt { color: var(--muted); padding-top: 5px; }
.money-list dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
  white-space: nowrap;
}
.mc .money { transform: scale(0.75); margin: -3px -2px; }
.mc b { font-variant-numeric: tabular-nums; }
.mc--none { padding: 3px 10px; color: var(--muted); }
.opt {
  margin: 0 0 14px;
  padding: 12px 12px 0;
  border-radius: 14px;
  background: rgba(111, 224, 168, 0.08);
  border: 1px solid rgba(111, 224, 168, 0.25);
}
.opt__h { margin: 0 0 10px; font-size: 13px; font-weight: 800; color: var(--good); }

.end__rank { margin: 4px 0 6px; font-size: clamp(30px, 7vw, 40px); }
.end__score { margin: 0 0 14px; font-size: 18px; color: var(--muted); }
.end__score b { font-size: 46px; color: var(--accent); font-variant-numeric: tabular-nums; }
.new { margin-left: 8px; padding: 2px 10px; border-radius: 999px; background: var(--good); color: #062014; font-size: 13px; font-weight: 900; }
.end__stats { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.end__stats b { color: var(--text); font-size: 17px; }
.end__btns { display: flex; gap: 8px; }
.end__btns .btn { flex: 1; }

.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  line-height: 1.8;
  background: #14110f;
}
.fallback a { color: var(--accent); }

/* ---- 狭い画面 */
@media (max-width: 860px) {
  .chips { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .chip__add { padding: 6px 2px 4px; }
  .actions { width: 96px; }
}
@media (max-width: 640px) {
  .stat { gap: 10px; padding: 7px 12px; font-size: 12px; }
  .stat span:nth-child(3) { display: none; }
  .home { padding: 7px 10px; }
  .lvl { min-width: 0; padding: 6px 10px 7px; font-size: 11.5px; top: calc(max(12px, env(safe-area-inset-top)) + 42px); left: 12px; }
  .lvl__lv b { font-size: 14px; }
  .pill { padding: 7px 10px; }
  .receipt {
    top: auto;
    right: auto;
    left: 12px;
    bottom: calc(var(--dock-h, 170px) + 18px);
    width: auto;
    padding: 8px 12px 12px;
    font-size: 11.5px;
  }
  .receipt__shop, .receipt__lines { display: none; }
  .receipt__row { margin-top: 2px; }
  .receipt__total b { font-size: 17px; }
  .receipt__need { margin-top: 6px; padding: 4px 6px; }
  .dock { flex-direction: column; padding: 8px; gap: 8px; }
  .actions { width: auto; flex-direction: row; }
  .actions .btn { padding: 11px; }
  .badge { font-size: 11px; padding: 3px 6px; }
  .card { padding: 22px 18px 18px; }
}
@media (max-height: 560px) and (min-width: 641px) {
  .receipt__lines { display: none; }
}

/* ---- X で共有 */
.res__btns { display: flex; gap: 8px; }
.card .res__btns #resNext { flex: 1; width: auto; }
.card .res__btns .xbtn { flex: none; width: 56px; padding-left: 0; padding-right: 0; font-size: 20px; }
.xshare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 800;
  text-decoration: none;
}
.xshare span { font-size: 14px; }
.xshare:hover { background: rgba(255, 255, 255, 0.08); }
