* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1d2b4a;
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  position: relative;
  width: min(100%, 56.25vh);
  width: min(100%, 56.25dvh);
  height: 100%;
  margin: 0 auto; overflow: hidden;
  touch-action: none;
}
canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
.pill {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 18px 6px 14px; border-radius: 999px;
  background: rgba(28, 40, 64, .82); color: #fff;
  font-size: 30px; font-weight: 900; line-height: 1;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.pill .people { width: 38px; height: 27px; fill: #fff; }
.pill.small {
  top: calc(max(14px, env(safe-area-inset-top)) + 54px);
  font-size: 15px; padding: 5px 12px;
}
#progress {
  position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 96px); left: 18px; right: 44px;
  height: 10px; border-radius: 5px; background: rgba(28, 40, 64, .55);
}
#progressFill { height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #58b6ff, #2a82e0); }
#progress img { position: absolute; right: -30px; top: -20px; height: 34px; }
#pauseBtn {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px;
  width: 52px; height: 52px; border: 0; border-radius: 14px;
  background: rgba(28, 40, 64, .82); box-shadow: 0 3px 0 rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  pointer-events: auto; cursor: pointer;
}
#pauseBtn span { width: 8px; height: 24px; border-radius: 3px; background: #fff; }

/* オーバーレイ画面 */
#overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; color: #fff;
}
#overlay:empty { display: none; }
#overlay.dim { background: rgba(15, 25, 50, .55); }
.title {
  font-size: 46px; font-weight: 900; letter-spacing: 2px;
  text-shadow:
    3px 0 0 #1d4f9a, -3px 0 0 #1d4f9a, 0 3px 0 #1d4f9a, 0 -3px 0 #1d4f9a,
    2px 2px 0 #1d4f9a, -2px 2px 0 #1d4f9a, 2px -2px 0 #1d4f9a, -2px -2px 0 #1d4f9a,
    0 7px 0 #1d4f9a;
}
.subtitle { font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.big-img { width: 46%; max-width: 200px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.25)); }
canvas.big-img { height: auto; aspect-ratio: 157 / 200; flex: none; }
.mid-img { width: 34%; max-width: 150px; }
.btn {
  pointer-events: auto; cursor: pointer;
  border: 0; border-radius: 18px; padding: 16px 40px;
  font: inherit; font-size: 24px; font-weight: 900; color: #fff;
  background: linear-gradient(#5fd06b, #2fa64a); box-shadow: 0 6px 0 #1f7a35;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f7a35; }
.btn.blue { background: linear-gradient(#58b6ff, #2a82e0); box-shadow: 0 6px 0 #1a5aa8; }
.btn.gray { background: linear-gradient(#9aa6b8, #6f7d92); box-shadow: 0 6px 0 #4e5a6c; font-size: 18px; padding: 12px 30px; }
.coins {
  display: flex; align-items: center; gap: 6px;
  font-size: 26px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.coins img { width: 34px; }
.wallet { display: flex; gap: 18px; justify-content: center; }
.row { display: flex; gap: 12px; }
.btn.small { font-size: 18px; padding: 10px 26px; }
.btn.pink { background: linear-gradient(#ff8fcb, #e0479b); box-shadow: 0 6px 0 #a8306f; }
.btn:disabled { filter: grayscale(.8); opacity: .6; }

/* ショップ */
#overlay.shop { justify-content: flex-start; padding-top: max(20px, env(safe-area-inset-top)); overflow-y: auto; background: rgba(15, 25, 50, .78); }
.tabs { display: flex; gap: 6px; background: rgba(0,0,0,.3); padding: 5px; border-radius: 16px; }
.tab {
  pointer-events: auto; cursor: pointer; border: 0; border-radius: 12px; padding: 9px 28px;
  font: inherit; font-size: 18px; font-weight: 900; color: #cfd8ea; background: transparent;
}
.tab.on { color: #fff; background: #2a82e0; }
.shop-body { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: rgba(255,255,255,.95); color: #1d2b4a; border-radius: 16px; padding: 10px 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
}
.card-icon { width: 46px; height: 46px; object-fit: contain; }
.card-text { flex: 1; min-width: 0; }
.card-name { font-size: 17px; font-weight: 900; }
.card-name .lv { font-size: 13px; color: #2a82e0; }
.card-desc { font-size: 12px; color: #55617a; margin-top: 3px; }
.card-desc b { color: #1f9a3c; }
.buy {
  pointer-events: auto; cursor: pointer; border: 0; border-radius: 12px; padding: 8px 12px;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  font: inherit; font-size: 16px; font-weight: 900; color: #fff;
  background: linear-gradient(#5fd06b, #2fa64a); box-shadow: 0 4px 0 #1f7a35;
}
.buy img { width: 20px; }
.buy:active { transform: translateY(3px); box-shadow: 0 1px 0 #1f7a35; }
.buy:disabled { background: #9aa6b8; box-shadow: 0 4px 0 #6f7d92; cursor: default; }
.maxed { font-size: 15px; font-weight: 900; color: #e08a00; padding: 8px 6px; }
.skin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.skin {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(255,255,255,.95); color: #1d2b4a; border-radius: 16px; padding: 8px 6px 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.2); border: 3px solid transparent;
}
.skin.using { border-color: #2a82e0; }
.skin canvas { width: 70%; aspect-ratio: 157 / 200; }
.skin .card-name { font-size: 14px; }
.skin .maxed { color: #2a82e0; padding: 6px 0; }
.hint { font-size: 13px; opacity: .85; }
.btn.tiny { font-size: 13px; padding: 8px 14px; border-radius: 12px; box-shadow: 0 4px 0 #4e5a6c; }
.btn.tiny.off { opacity: .55; }

/* チュートリアル */
#hint {
  position: absolute; left: 0; right: 0; top: 40%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; text-align: center;
}
.hint-text {
  padding: 12px 22px; border-radius: 18px;
  background: rgba(28, 40, 64, .85); color: #fff;
  font-size: 21px; font-weight: 900; line-height: 1.35;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.hand {
  margin-top: 90px; font-size: 64px; line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.35));
  animation: swipe 1.4s ease-in-out infinite;
}
@keyframes swipe {
  0%, 100% { transform: translateX(-80px) rotate(-10deg); }
  50% { transform: translateX(80px) rotate(10deg); }
}
.tap { animation: blink 1.1s infinite; font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
@keyframes blink { 50% { opacity: .35; } }
.pop { animation: pop .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
