:root {
  --red: #c8202f;
  --red-d: #8e1520;
  --ink: #1d1a17;
  --paper: #fff8ee;
  --card: #ffffff;
  --line: #eadfce;
  --gray: #857a6e;
  --wood: #7a4a24;
  --wood-l: #a8723f;
  --gold: #e0a526;
  --orange: #e07b00;
  --brush: "Yuji Syuku", "Hiragino Mincho ProN", serif;
  --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191512; --card: #24201c; --line: #3a322b; --ink: #f3ebe1; --gray: #b3a596;
  }
}
:root[data-theme="dark"] {
  --paper: #191512; --card: #24201c; --line: #3a322b; --ink: #f3ebe1; --gray: #b3a596;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.brush { font-family: var(--brush); font-weight: 400; }
.fine { font-size: 12px; color: var(--gray); }
.center { text-align: center; }
.error { color: var(--red); font-weight: 700; }
.row { display: flex; gap: 8px; align-items: center; }
.row.gap { gap: 10px; flex-wrap: wrap; margin-top: 12px; }
input, select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.field { display: block; font-size: 13px; color: var(--gray); margin: 8px 0; }
.field .row, .field input { margin-top: 4px; }
.field input { width: 100%; }
.field .row input { flex: 1; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; cursor: pointer;
  padding: 11px 18px; background: var(--red); color: #fff; text-decoration: none;
  box-shadow: 0 3px 0 var(--red-d); transition: transform .06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-d); }
.btn.small { padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; }

/* ---------- ログイン ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(200, 32, 47, .18), transparent 60%),
    var(--paper);
}
.login h1 { font-size: 54px; line-height: 1.1; margin: 18px 0 10px; color: var(--red); }
.login h1 small { font-size: 30px; color: var(--ink); }
.login .lead { margin: 0 0 24px; }
.btn.google { background: #fff; color: #1f1f1f; box-shadow: 0 2px 0 #c9c0b4, 0 0 0 1.5px #dadce0; padding: 13px 22px; }
.dev { margin-top: 18px; display: flex; gap: 8px; }
.login .fine { max-width: 360px; margin-top: 28px; }
.lanterns { display: flex; gap: 26px; }
.lantern {
  position: relative; width: 62px; height: 82px; border-radius: 46%;
  background: radial-gradient(ellipse at 40% 35%, #ff5a5a, var(--red) 55%, var(--red-d));
  box-shadow: 0 0 34px rgba(255, 70, 50, .55);
  display: grid; place-items: center; animation: sway 3.2s ease-in-out infinite; transform-origin: 50% -20px;
}
.lantern:nth-child(2) { animation-delay: -1.6s; }
.lantern::before, .lantern::after {
  content: ""; position: absolute; left: 14px; right: 14px; height: 8px; background: var(--ink); border-radius: 3px;
}
.lantern::before { top: -4px; } .lantern::after { bottom: -4px; }
.lantern span { font-family: var(--brush); color: #fff; font-size: 30px; }
.lantern { background-image:
  repeating-linear-gradient(0deg, transparent 0 9px, rgba(0,0,0,.14) 9px 10px),
  radial-gradient(ellipse at 40% 35%, #ff5a5a, var(--red) 55%, var(--red-d)); }
@keyframes sway { 50% { transform: rotate(4deg); } }

/* ---------- のれん ---------- */
.noren {
  position: sticky; top: 0; z-index: 500;
  background: var(--red); color: #fff; padding: 10px 16px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: baseline; justify-content: space-between;
  /* のれんの切れ目 */
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat,
    repeating-linear-gradient(90deg, #000 0 calc(25% - 3px), transparent calc(25% - 3px) 25%) bottom/100% 6px no-repeat;
          mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat,
    repeating-linear-gradient(90deg, #000 0 calc(25% - 3px), transparent calc(25% - 3px) 25%) bottom/100% 6px no-repeat;
}
.noren-title { font-size: 22px; letter-spacing: .04em; }
.noren-sub { font-weight: 700; font-size: 14px; }

main { padding: 12px 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); border: 1px solid var(--line); }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.card h2::before { content: ""; display: inline-block; width: 5px; height: 15px; background: var(--red); margin-right: 8px; vertical-align: -2px; border-radius: 2px; }

/* ---------- タブバー ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; display: flex;
  background: var(--ink); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; height: var(--tab-h); background: none; border: 0; color: #cbbfb1; font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabs i { font-style: normal; font-family: var(--brush); font-size: 21px; line-height: 1; }
.tabs button.on { color: #fff; }
.tabs button.on i { color: #ff6b6b; }

/* ---------- ホーム ---------- */
.hero { position: relative; display: grid; place-items: center; padding: 20px; }
.ring { width: 200px; height: 200px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--red); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .8s; }
.hero-num { position: absolute; top: 76px; text-align: center; }
.hero-num b { font-size: 44px; line-height: 1; display: block; }
.hero-num span { color: var(--gray); }
.hero-pct { font-weight: 700; color: var(--red); margin-top: 4px; }
.secbars { display: grid; gap: 7px; }
.secbar { display: grid; grid-template-columns: 8.8em 1fr 3.4em; white-space: nowrap; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--red); border-radius: 6px; }
.secbar .n { text-align: right; color: var(--gray); font-variant-numeric: tabular-nums; }
.recent { margin: 0; padding: 0; list-style: none; }
.recent li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.recent li:last-child { border: 0; }
.recent .d { margin-left: auto; color: var(--gray); font-size: 12px; }

/* ---------- 店舗一覧 ---------- */
.filters { position: sticky; top: 52px; z-index: 10; background: var(--paper); padding: 6px 0 8px; display: grid; gap: 8px; }
.filters input { width: 100%; }
.filters select { flex: 1; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--ink); font: inherit; padding: 8px 12px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; }
.sec-h { position: sticky; top: 148px; background: var(--paper); font-weight: 900; padding: 10px 2px 4px; z-index: 5; display: flex; justify-content: space-between; }
.sec-h span { color: var(--gray); font-weight: 400; font-size: 13px; }
.store {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; cursor: pointer;
}
.badge {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 12px; border: 2px solid var(--red); color: var(--red); background: var(--card);
}
.badge.done { background: var(--red); color: #fff; }
.badge.plan { border-color: var(--orange); color: var(--orange); }
.store .nm { font-weight: 700; line-height: 1.3; }
.store .sub { font-size: 12px; color: var(--gray); }
.store .right { margin-left: auto; text-align: right; font-size: 12px; color: var(--gray); white-space: nowrap; }
.store .right.done { color: var(--red); font-weight: 700; }
.empty { text-align: center; color: var(--gray); padding: 30px 0; }

/* ---------- 地図 ---------- */
.tab-map { position: fixed; inset: 52px 0 calc(var(--tab-h) + env(safe-area-inset-bottom)) 0; }
#map { position: absolute; inset: 0; }
.map-btn {
  position: absolute; right: 12px; bottom: 16px; z-index: 450; border: 0; border-radius: 22px; padding: 10px 14px;
  background: var(--card); color: var(--ink); font: inherit; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.leaflet-popup-content { font-family: inherit; font-size: 14px; }
.leaflet-popup-content .btn { margin-top: 6px; padding: 6px 12px; font-size: 13px; }

/* ---------- 友達 ---------- */
.code-card { text-align: center; }
.code { font-size: 34px; font-weight: 900; letter-spacing: .12em; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
#reqForm .row input { flex: 1; text-transform: uppercase; letter-spacing: .1em; }
.msg { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
.friend { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.friend:last-child { border: 0; }
.friend .rank { font-family: var(--brush); font-size: 22px; color: var(--red); text-align: center; }
.friend .nm { font-weight: 700; }
.friend .bar { margin-top: 4px; }
.friend .n { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.friend .n small { display: block; font-weight: 400; font-size: 11px; color: var(--gray); }
.friend.me { background: linear-gradient(90deg, rgba(200,32,47,.07), transparent); border-radius: 10px; }
.req { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.req b { flex: 1; }

/* ---------- ダイアログ ---------- */
dialog.sheet {
  border: 0; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; margin: auto auto 0; background: var(--card); color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(20, 10, 5, .5); }
.sheet-head { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.plan { color: var(--orange); font-weight: 700; margin: 4px 0; }
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; text-align: center; }
.compare div { background: var(--paper); border-radius: 12px; padding: 8px 4px; font-size: 12px; color: var(--gray); }
.compare b { display: block; font-size: 22px; color: var(--ink); }
.mini { max-height: 32vh; overflow: auto; padding-left: 0; list-style: none; margin: 0; font-size: 14px; }
.mini li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
dialog h3 { font-size: 14px; margin: 8px 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 24px; z-index: 900; font-size: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: calc(100% - 32px);
}

/* ---------- チンチロ ---------- */
.tab-chin { margin: -12px -16px 0; }
.chin-board {
  min-height: calc(100dvh - 52px - var(--tab-h));
  padding: 16px 16px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  /* 木のカウンター */
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 2px, transparent 2px 9px, rgba(255,255,255,.04) 9px 11px, transparent 11px 23px),
    linear-gradient(180deg, var(--wood-l), var(--wood));
  color: #fff;
}
.menu-board {
  background: #fdf6e6; color: var(--ink); border: 4px solid #3a2414; border-radius: 6px; padding: 8px 18px 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); min-width: 240px; text-align: center;
}
.menu-title { font-size: 28px; color: var(--red); line-height: 1.2; cursor: default; user-select: none; -webkit-user-select: none; }
.menu-title.wink { animation: wink .35s; } /* 裏技が入った合図（さりげなく） */
@keyframes wink { 40% { transform: rotate(-4deg) scale(1.06); } }
.menu-board ul { list-style: none; padding: 0; margin: 4px 0 0; font-size: 14px; text-align: left; }
.menu-board li { display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px dotted #c9b9a0; padding: 2px 0; }
.menu-board li b { font-family: var(--brush); font-size: 18px; color: var(--red); font-weight: 400; }
.bowl-wrap { position: relative; width: min(84vw, 340px); aspect-ratio: 1; }
.bowl {
  position: absolute; inset: 0; border-radius: 50%;
  /* どんぶり：黒い縁、朱の内側 */
  background: radial-gradient(circle at 50% 50%, #1a1311 66%, #3a2a24 69%, #120c0a 72%);
  box-shadow: 0 14px 30px rgba(0,0,0,.45), inset 0 0 0 3px #000;
}
.bowl-in {
  position: absolute; inset: 9%; border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255,255,255,.35), transparent 30%),
    radial-gradient(circle at 50% 55%, #f04a3f, #c8202f 55%, #7d0f17 100%);
  box-shadow: inset 0 10px 26px rgba(0,0,0,.55), inset 0 -4px 10px rgba(255,255,255,.12);
}
.bowl-in::after { /* 底の高台の輪 */
  content: ""; position: absolute; inset: 30%; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18), 0 0 0 1px rgba(255,255,255,.08);
}
.die {
  position: absolute; left: 0; top: 0; width: 15%; aspect-ratio: 1; border-radius: 18%;
  background: linear-gradient(145deg, #ffffff, #e9e4dc); box-shadow: 0 3px 5px rgba(0,0,0,.45), inset 0 -2px 3px rgba(0,0,0,.12);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 4px; will-change: transform;
}
.die i { width: 66%; aspect-ratio: 1; border-radius: 50%; background: #1d1a17; place-self: center; }
.die i.one { width: 110%; background: radial-gradient(circle at 40% 35%, #ff4c4c, #c00); grid-area: 2 / 2; }
.stamp {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: end; padding-bottom: 13%; pointer-events: none;
  animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.stamp b {
  font-family: var(--brush); font-weight: 400; font-size: 54px; line-height: 1; color: #fff;
  padding: 4px 18px 8px; border: 6px double #fff; border-radius: 14px; background: rgba(200, 32, 47, .88);
  transform: rotate(-8deg); text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.stamp span { margin-top: 6px; font-weight: 900; font-size: 15px; background: #fff; color: var(--red); padding: 4px 14px; border-radius: 20px; transform: rotate(-3deg); }
.stamp.half b { background: rgba(29, 26, 23, .88); }
.stamp.dbl b { background: rgba(224, 165, 38, .92); color: #3a2414; border-color: #3a2414; }
@keyframes stamp { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.btn.roll { font-size: 22px; padding: 14px 54px; font-family: var(--brush); font-weight: 400; border-radius: 40px; }
.chin-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chin-stats div { background: rgba(0,0,0,.28); border-radius: 12px; padding: 6px 12px; text-align: center; font-size: 12px; }
.chin-stats b { display: block; font-size: 20px; }
.mute { background: rgba(0,0,0,.25); color: #fff; border: 0; border-radius: 20px; padding: 6px 14px; font: inherit; font-size: 13px; }
.tab-chin .fine { color: #f1dcc4; max-width: 340px; }
