:root {
  --accent: #b7282e;
  --accent-dark: #8f1f24;
  --bg: #eef6fa;
  --surface: #ffffff;
  --text: #24313a;
  --text-muted: #63767f;
  --border: #cfe0e6;
  --key-bg: #e4eef2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101820;
    --surface: #1a242c;
    --text: #eef4f7;
    --text-muted: #9fb0b8;
    --border: #2c3942;
    --key-bg: #22303a;
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  overscroll-behavior: none;
}
.hidden { display: none !important; }

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#game-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 360 / 640;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  touch-action: manipulation;
  user-select: none;
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 10px;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}
#hud-score {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.btn-mute-small {
  pointer-events: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: rgba(10, 30, 40, .45);
  color: #fff;
  text-align: center;
  pointer-events: none; /* 背景タップはcanvasまで貫通させ、handleInput()を発火させる */
}
.overlay .icon-btn-small,
.overlay .btn,
.overlay .featured-good,
.overlay .other-games-hint {
  pointer-events: auto;
}
.overlay-top {
  display: flex;
  justify-content: space-between;
  padding: 10px;
}
.overlay-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
}
.icon-btn-small {
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
}

.logo {
  font-size: 2.4rem;
  margin: 0;
  text-shadow: 0 3px 6px rgba(0,0,0,.4);
}
.logo-accent { color: #ffd9a0; }
.mascot-bubble {
  background: rgba(255,255,255,.92);
  color: #5a4030;
  font-size: .78rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  margin: 2px 0 6px;
}
.subtitle { margin: 0; font-size: .95rem; opacity: .95; }
.best-label { margin: 4px 0 0; font-size: .85rem; opacity: .9; }
.tap-prompt {
  margin-top: 18px;
  font-size: .85rem;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:1} }

.go-title { margin: 0; font-size: 1.4rem; }
.go-tier-note { margin: 4px 0 0; font-size: .78rem; opacity: .85; }
.go-score { font-size: 2.2rem; font-weight: 800; margin: 10px 0 0; }
.go-breakdown { font-size: .85rem; opacity: .9; margin: 4px 0 0; }
.go-record {
  font-size: 1rem;
  font-weight: 700;
  color: #ffd9a0;
  margin: 0 0 4px;
}
.go-badge-unlock {
  margin: 10px 0 0;
  font-size: .75rem;
  background: rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 5px 12px;
}
.go-daily-bonus {
  margin: 8px 0 0;
  font-size: .78rem;
  font-weight: 700;
  color: #fff6da;
  background: rgba(255,209,102,.28);
  border: 1px solid rgba(255,209,102,.6);
  border-radius: 999px;
  padding: 5px 12px;
}
.go-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  width: 200px;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: rgba(255,255,255,.25); color: #fff; }

.featured-good {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 10px;
  width: 220px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  text-align: left;
}
.featured-img { flex-shrink: 0; line-height: 0; }
.featured-img img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.featured-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.featured-title {
  font-size: .68rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.featured-cta {
  font-size: .68rem;
  font-weight: 700;
  color: #ffd9a0;
  text-decoration: none;
  align-self: flex-start;
}

.other-games-hint {
  margin-top: 10px;
  background: none;
  border: none;
  color: #fff;
  opacity: .85;
  font-size: .72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}
.nav-highlight {
  animation: nav-pulse 1.4s ease-in-out 2;
  border-radius: 12px;
}
@keyframes nav-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(183,40,46,0); }
  50% { box-shadow: 0 0 0 8px rgba(183,40,46,.25); }
}

.toast {
  margin-top: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: .8rem;
}

.below-canvas {
  width: 100%;
  max-width: 400px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --- PR/おみやげ共通 --- */
.ad-slot {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 0;
  overflow: hidden;
}
.shop-banner-slot { padding: 10px; }
.shop-banner-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  width: 100%;
  padding-bottom: 2px;
}
.shop-banner-scroller img {
  height: 56px;
  width: auto;
  border-radius: 6px;
  flex: 0 0 auto;
}
.pr-badge {
  background: var(--text-muted);
  color: var(--bg);
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 4px;
}
.goods-panel { width: 100%; }
.goods-heading {
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.goods-scroller {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.goods-card {
  flex: 0 0 auto;
  width: 108px;
  background: var(--key-bg);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.goods-img { line-height: 0; }
.goods-img img { width: 100%; height: auto; border-radius: 6px; display: block; }
.goods-title {
  color: var(--text);
  text-decoration: none;
  font-size: .7rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- ほかのゲーム --- */
.cross-game-nav {
  width: 100%;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  text-align: center;
}
.cross-game-label { font-size: .75rem; color: var(--text-muted); margin: 0 0 8px; }
.cross-game-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cross-game-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--key-bg);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 700;
}
.cross-game-icon { font-size: 1rem; }

/* --- モーダル --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 24px 20px;
  max-width: 380px;
  width: 100%;
  position: relative;
}
.modal h2 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}
.help-list { padding-left: 20px; line-height: 1.9; }

.badges-progress-label {
  font-size: .8rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--accent);
}
.badges-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--key-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.badges-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd166, var(--accent));
  border-radius: 999px;
  transition: width .3s ease;
}
.badges-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.badge-card {
  background: var(--key-bg);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 2px solid transparent;
}
.badge-card:not(.badge-locked) {
  background: linear-gradient(160deg, rgba(255,209,102,.25), rgba(255,158,203,.18));
  border-color: rgba(255,209,102,.6);
}
.badge-icon { font-size: 1.8rem; }
.badge-name { font-size: .75rem; font-weight: 700; margin-top: 4px; }
.badge-desc { font-size: .65rem; color: var(--text-muted); margin-top: 2px; }
.badge-locked { opacity: .45; }
