:root {
  --bg: #0d0820;
  --bg2: #1a1038;
  --gold: #d4af37;
  --gold-soft: #f3e5ab;
  --text: #ece6ff;
  --muted: #a99ccf;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
body {
  background: radial-gradient(ellipse at top, #241446 0%, var(--bg) 60%) fixed, var(--bg);
}
.app {
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(212,175,55,0.25);
  flex: 0 0 auto;
}
header a {
  color: var(--gold-soft);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
header h1 {
  flex: 1;
  text-align: center;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sound-btn {
  background: none;
  border: 1px solid rgba(212,175,55,0.35);
  color: var(--gold-soft);
  border-radius: 14px;
  font-size: 13px;
  padding: 2px 8px;
  cursor: pointer;
}
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  font-size: 14px;
  color: var(--gold-soft);
  flex: 0 0 auto;
  min-height: 32px;
}
.hud .score { font-weight: bold; font-size: 17px; color: var(--gold); }
.hud .danger { color: #ff6b6b; }
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#game-canvas { display: block; touch-action: none; }
.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: bold;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
  pointer-events: none;
  animation: popUp 0.8s ease-out forwards;
  white-space: nowrap;
}
.pop.bad { color: #ff6b6b; }
@keyframes popUp {
  from { opacity: 1; margin-top: 0; }
  to   { opacity: 0; margin-top: -48px; }
}
.banner {
  position: absolute;
  left: 50%; top: 38%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 10px 22px;
  border-radius: 24px;
  background: rgba(13,8,32,0.85);
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  font-weight: bold;
  font-size: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8,4,22,0.82);
  padding: 20px;
}
.overlay.show { display: flex; }
.panel {
  width: 100%;
  max-width: 360px;
  text-align: center;
  background: linear-gradient(180deg, #22144a, #140c30);
  border: 1px solid rgba(212,175,55,0.5);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 0 30px rgba(212,175,55,0.15);
}
.panel .icon { font-size: 48px; }
.panel h2 { color: var(--gold); font-size: 20px; margin: 8px 0 12px; }
.panel ul { text-align: left; list-style: none; font-size: 14px; line-height: 1.7; color: var(--text); margin-bottom: 18px; }
.panel ul li::before { content: "✦ "; color: var(--gold); }
.big-score { font-size: 40px; font-weight: bold; color: var(--gold-soft); margin: 4px 0; }
.stats { font-size: 14px; color: var(--muted); margin: 8px 0; line-height: 1.8; }
.stats b { color: var(--gold-soft); }
.message { font-size: 15px; color: var(--gold-soft); margin: 10px 0 18px; }
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 26px;
  background: linear-gradient(180deg, #f3e5ab, #d4af37);
  color: #2a1a00;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.btn + .btn, .btn + a.sub { margin-top: 10px; }
a.sub { display: block; color: var(--muted); font-size: 13px; text-decoration: none; }

/* ─── 追加：星のかけら・ログイン・賭けUI ─── */
.hud .bal { font-size: 13px; color: var(--gold-soft); white-space: nowrap; }
.hud .bal b { color: var(--gold); }
.hud #hud-left { min-width: 80px; }
.hud #hud-right { min-width: 80px; text-align: right; }
.panel .icon img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; }
.panel .warn { font-size: 12px; color: #ffd27a; line-height: 1.6; margin: -6px 0 14px; }
.panel .note { font-size: 13px; color: var(--muted); margin: 10px 0; line-height: 1.6; }
.panel .note a, .login-box a { color: var(--gold); }
.earn-line { font-size: 17px; font-weight: bold; color: var(--gold); margin: 8px 0 4px; min-height: 24px; }
.earn-line.ng { color: #ff9b9b; font-size: 14px; font-weight: normal; }
.login-box { font-size: 14px; color: var(--gold-soft); margin: 10px 0 16px; line-height: 1.7; }
a.btn { text-decoration: none; text-align: center; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { padding: 9px; font-size: 15px; }
.btn.ghost { background: rgba(212,175,55,0.12); color: var(--gold-soft); border: 1px solid rgba(212,175,55,0.5); }
.coin-pop-row { display: none; }

/* 賭けるゲーム共通の操作パネル（キャンバスの下に置く） */
.bet-ui {
  flex: 0 0 auto;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(212,175,55,0.25);
  background: rgba(13,8,32,0.9);
}
.bet-row { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; flex-wrap: wrap; }
.chip {
  flex: 1 1 0; min-width: 0;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(212,175,55,0.45);
  background: rgba(40,24,110,0.7);
  color: var(--gold-soft);
  font-size: 14px; font-weight: bold;
  font-family: inherit;
  cursor: pointer;
}
.chip.sel { background: linear-gradient(180deg, #f3e5ab, #d4af37); color: #2a1a00; }
.chip:disabled { opacity: 0.4; cursor: default; }
.chip.red.sel { background: linear-gradient(180deg, #ff8080, #c01818); color: #fff; }
.chip.black.sel { background: linear-gradient(180deg, #666, #111); color: #fff; }
.chip.green.sel { background: linear-gradient(180deg, #6ee08a, #138a36); color: #fff; }
.bet-label { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.bet-msg { font-size: 13px; color: #ffd27a; text-align: center; min-height: 18px; margin-bottom: 6px; }
.bet-row .btn { flex: 1 1 0; }
.bet-row .btn + .btn { margin-top: 0; }
