:root {
  --c-primary: #e85d2a;
  --c-primary-dark: #c4471a;
  --c-accent: #2a8ce8;
  --c-bg: #fff7f1;
  --c-card: #ffffff;
  --c-ink: #2b2018;
  --c-muted: #8a7d72;
  --c-line: #f0e2d6;
  --c-ok: #2faa5a;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(180, 90, 40, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dark));
  color: #fff; box-shadow: var(--shadow);
}
.brand { display: flex; flex-direction: column; }
.brand-main { font-weight: 800; font-size: 14px; letter-spacing: .04em; }
.brand-sub { font-size: 12px; opacity: .92; }
.net-badge { font-size: 12px; color: #ffd9c5; }
.net-badge.online { color: #b6ffce; }

/* Layout */
.view { max-width: 560px; margin: 0 auto; padding: 16px; }

/* Progress */
.progress-card {
  background: var(--c-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; text-align: center; margin-bottom: 16px;
}
.progress-label { margin: 0; color: var(--c-muted); font-size: 13px; }
.progress-count { margin: 4px 0 12px; font-size: 40px; font-weight: 800; color: var(--c-primary); }
.progress-count span { font-variant-numeric: tabular-nums; }
.progress-bar { height: 10px; background: var(--c-line); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--c-accent), var(--c-primary)); transition: width .5s ease; }
.goal-msg { margin: 10px 0 0; font-size: 14px; font-weight: 700; min-height: 1.4em; }
.goal-msg.done { color: var(--c-ok); }

/* Buttons */
.btn {
  display: inline-block; border: none; border-radius: 12px; cursor: pointer;
  font-size: 16px; font-weight: 700; padding: 14px 18px; text-decoration: none;
  text-align: center; transition: transform .08s, background .2s; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--c-primary); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--c-muted); border: 1px solid var(--c-line); font-size: 13px; padding: 10px 14px; }
.btn-secondary { background: var(--c-accent); color: #fff; box-shadow: var(--shadow); }
.btn-mini { background: transparent; color: var(--c-muted); border: 1px solid var(--c-line); font-size: 12px; padding: 6px 12px; }
.btn-scan { display: block; width: 100%; font-size: 17px; padding: 16px 8px; }
.get-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.get-hint { text-align: center; font-size: 12px; color: var(--c-muted); margin: 0 0 20px; }
.btn-close { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); color: #fff; }

/* Stamp list */
.stamp-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp-item {
  background: var(--c-card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); position: relative; opacity: .55; transition: opacity .3s;
}
.stamp-item.got { opacity: 1; }
.stamp-item .si-mark {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; margin-bottom: 8px; background: var(--c-line); color: var(--c-muted);
}
.stamp-item.got .si-mark { background: var(--c-ok); color: #fff; }
.stamp-item .si-name { font-weight: 700; font-size: 14px; }
.stamp-item .si-work { font-size: 12px; color: var(--c-muted); }
.stamp-item.got { cursor: pointer; }
.stamp-item .si-tap { font-size: 10px; color: var(--c-accent); margin-top: 4px; }
.stamp-item.load-error { grid-column: 1 / -1; opacity: 1; text-align: center; }
.btn-reload { margin-top: 12px; }

/* 商店街マップ */
.prize-card { display: block; width: 100%; margin: 0 0 16px; padding: 16px 14px; border: 0; border-radius: var(--radius); background: #7b4bb7; color: #fff; font: inherit; font-size: 22px; font-weight: 700; text-align: center; cursor: pointer; box-shadow: 0 6px 16px rgba(123,75,183,.35); animation: prize-pop .5s ease-out; }
.prize-card small { display: block; font-size: 12px; font-weight: 400; margin-top: 4px; opacity: .9; }
.prize-card.hidden { display: none; }
@keyframes prize-pop { 0% { transform: scale(.8); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
.modal-cal { margin: 0 0 12px; }
.modal-cal.hidden { display: none; }
.cal { width: 100%; border-collapse: separate; border-spacing: 2px; margin: 0 0 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.cal caption { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.cal th { font-weight: 400; font-size: 11px; color: var(--c-muted); }
.cal td { text-align: center; padding: 5px 0; border-radius: 6px; }
.cal td.sun { color: #d0453a; }
.cal td.sat { color: #2a6fd0; }
.cal td.on { background: #7b4bb7; color: #fff; font-weight: 700; }
.cal td.today { box-shadow: inset 0 0 0 2px #e85d2a; }
.cal-note { font-size: 12px; color: var(--c-muted); margin: 0; }
.cal-on { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #7b4bb7; vertical-align: -1px; }
.modal-look { margin: 0 0 12px; }
.modal-look img { display: block; width: 100%; border-radius: 10px; }
.modal-look figcaption { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.modal-look.hidden { display: none; }
.map-card { background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 16px; }
.map-legend { margin: 8px 2px 0; font-size: 12px; color: #6b5d50; }
.map-legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.map-legend .lg-stamp { background: #e85d2a; }
.map-legend .lg-spot { background: #3a7fb0; }
.map-label { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.map-label span { font-size: 11px; font-weight: 400; color: var(--c-muted); margin-left: 4px; }
.rally-map { border-radius: 10px; overflow: hidden; }
.rally-map svg { border-radius: 10px; }

.foot-actions { display: flex; gap: 10px; justify-content: center; margin: 24px 0 8px; flex-wrap: wrap; }
.offline-note { text-align: center; font-size: 12px; color: var(--c-muted); }

/* Scanner */
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; align-items: center; justify-content: center; }
#cam { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 240px; height: 240px; border: 3px solid #fff; border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
}
.scan-status {
  position: absolute; top: calc(20px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  color: #fff; background: rgba(0,0,0,.55); padding: 8px 16px; border-radius: 99px; font-size: 14px; margin: 0; max-width: 90%; text-align: center;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: var(--c-card); border-radius: 20px; padding: 28px 24px; text-align: center; max-width: 360px; width: 100%; animation: pop .3s ease; max-height: 86vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.stamp-mark { font-size: 56px; }
.modal-card h2 { margin: 8px 0; color: var(--c-primary); }
.modal-photo { width: 100%; max-height: 40vh; object-fit: cover; border-radius: 12px; margin: 4px 0 10px; }
.modal-name { font-weight: 700; margin: 4px 0; }
.modal-work { color: var(--c-muted); font-size: 14px; margin: 0 0 14px; }
.modal-desc { font-size: 13px; text-align: left; margin: 0 0 12px; }
.modal-comment {
  font-size: 13px; text-align: left; background: var(--c-bg);
  border-radius: 12px; padding: 22px 12px 10px; margin: 0 0 12px; position: relative;
}
.modal-comment::before {
  content: "✍️ 作者からひとこと"; position: absolute; top: 6px; left: 12px;
  font-size: 10px; font-weight: 700; color: var(--c-primary);
}
.modal-info { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; text-align: left; font-size: 13px; margin: 0 0 12px; }
.modal-info dt { color: var(--c-muted); }
.modal-info dd { margin: 0; overflow-wrap: anywhere; }
.modal-works { text-align: left; margin: 0 0 12px; }
.modal-works .mw-head { font-size: 12px; font-weight: 700; color: var(--c-muted); margin: 0 0 6px; }
.work-link {
  display: block; width: 100%; text-align: left; border: 1px solid var(--c-line); background: var(--c-bg);
  border-radius: 10px; padding: 10px 12px; margin: 0 0 6px; font-size: 14px; font-family: inherit; color: var(--c-ink); cursor: pointer;
}
.modal-hint { font-size: 12px; color: var(--c-accent); font-weight: 700; margin: 0 0 12px; }
.modal-date { font-size: 11px; color: var(--c-muted); margin: 0 0 12px; }
.modal-card .btn { width: 100%; }

/* じゅんびチェック */
.ready-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 14px; margin-bottom: 16px;
}
.ready-status { margin: 0; font-size: 13px; font-weight: 700; color: var(--c-muted); }
.ready-status.ok { color: var(--c-ok); }
.ready-status.ng { color: var(--c-primary-dark); }

/* 手入力 */
.code-input {
  display: block; width: 100%; font-size: 26px; font-weight: 800; text-align: center;
  letter-spacing: .2em; padding: 12px; margin: 12px 0 4px; border: 2px solid var(--c-line);
  border-radius: 12px; font-family: inherit; color: var(--c-ink); background: var(--c-bg);
}
.code-input:focus { outline: none; border-color: var(--c-accent); }
.input-error { min-height: 1.4em; font-size: 12px; color: var(--c-primary-dark); margin: 0 0 8px; }
.modal-card .btn + .btn { margin-top: 8px; }

.hidden { display: none !important; }
