/* ==========================================================================
   BOMB BUCKET — bomb-squad hazard theme
   ========================================================================== */

:root {
  --bg0: #0d1220;
  --bg1: #1a2130;
  --panel: #10141f;
  --panel-edge: #232b3a;
  --ink: #eef2f7;
  --ink-dim: #9aa7b8;
  --hazard: #ffc61a;
  --hazard-dark: #b8860b;
  --danger: #ff5031;
  --accent: #35d0ff;
  --gold: #ffd76a;
  --font: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg0);
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   HUD
   ========================================================================== */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 0 calc(14px + env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 5;
}

#hud.hidden, .hidden { display: none !important; }

#score {
  font-size: clamp(28px, 5.5vw, 44px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0,0,0,.55);
  min-width: 2ch;
}
#score.bump { animation: bump .18s ease-out; }
@keyframes bump { 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.combo {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--accent);
  font-size: clamp(14px, 2.6vw, 19px);
  text-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.combo-bar {
  width: clamp(52px, 10vw, 86px);
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,.14);
  overflow: hidden;
}
.combo-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .12s linear;
}

#lives {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: 6px;
}
#lives svg { filter: drop-shadow(0 2px 0 rgba(0,0,0,.5)); }
#lives .life { transition: transform .15s ease, opacity .2s ease; }
#lives .life.lost { opacity: .22; transform: scale(.78) rotate(20deg); filter: grayscale(1); }

#btn-pause {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border: 2px solid var(--panel-edge);
  border-radius: 12px;
  background: rgba(16, 20, 31, .82);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-pause:active { transform: scale(.92); }

/* ==========================================================================
   Overlays & panels
   ========================================================================== */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 35%, rgba(13,18,32,.45), rgba(7,9,15,.88));
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 10;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.panel {
  position: relative;
  width: min(430px, 94vw);
  max-height: 92dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #131926, var(--panel));
  border: 2px solid var(--panel-edge);
  border-radius: 18px;
  padding: 26px 26px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
  gap: 13px;
  animation: pop-in .28s cubic-bezier(.2, 1.6, .4, 1);
}
.panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8px;
  border-radius: 16px 16px 0 0;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 14px, #15161a 14px 28px);
  opacity: .9;
}
@keyframes pop-in { from { transform: scale(.86) translateY(14px); opacity: 0; } }

.title {
  font-size: clamp(40px, 9vw, 58px);
  font-weight: 700;
  letter-spacing: 2px;
  line-height: .95;
  color: var(--hazard);
  text-shadow: 0 4px 0 rgba(0,0,0,.55);
  margin-top: 6px;
}
.title span { display: block; color: var(--ink); letter-spacing: 8px; }

.tagline { color: var(--ink-dim); font-size: clamp(13px, 3vw, 15px); line-height: 1.45; }
.tagline b { color: var(--danger); }

.best-line { color: var(--ink-dim); font-size: 13px; letter-spacing: 3px; }
.best-line b { color: var(--gold); font-size: 16px; margin-left: 6px; }

.panel-title {
  font-size: clamp(24px, 6vw, 32px);
  letter-spacing: 4px;
  color: var(--ink);
  margin-top: 6px;
}
.panel-title.danger { color: var(--danger); text-shadow: 0 3px 0 rgba(0,0,0,.5); }

.hint { color: var(--ink-dim); font-size: 12px; letter-spacing: .5px; }

.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  color: #10131a;
  background: linear-gradient(180deg, #ffd44d, var(--hazard));
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--hazard-dark), 0 10px 22px rgba(0,0,0,.45);
  transition: transform .06s ease, box-shadow .06s ease, filter .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--hazard-dark), 0 4px 10px rgba(0,0,0,.45); }

.btn.big { font-size: clamp(18px, 4.5vw, 22px); padding: 16px 20px; }
.btn.small { padding: 10px 16px; font-size: 14px; }

.btn.ghost {
  background: rgba(255,255,255,.05);
  color: var(--ink);
  border: 2px solid var(--panel-edge);
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
}
.btn.ghost:active { box-shadow: 0 1px 0 rgba(0,0,0,.35); }

.btn.danger-ghost {
  background: rgba(255, 80, 49, .08);
  color: var(--danger);
  border: 2px solid rgba(255, 80, 49, .45);
  box-shadow: none;
  font-size: 13px;
  padding: 10px;
}

/* ==========================================================================
   Segmented controls (difficulty / toggles)
   ========================================================================== */

.seg {
  display: flex;
  border: 2px solid var(--panel-edge);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,.3);
}
.seg button {
  flex: 1;
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1.5px;
  padding: 11px 4px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg button + button { border-left: 2px solid var(--panel-edge); }
.seg button.on {
  background: linear-gradient(180deg, #ffd44d, var(--hazard));
  color: #10131a;
  text-shadow: none;
}
.seg.small button { padding: 9px 4px; font-size: 12px; }

/* ==========================================================================
   Settings widgets
   ========================================================================== */

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
}
.setting > span { flex: 0 0 auto; }
.setting .seg { flex: 1; max-width: 200px; }

input[type="range"] {
  flex: 1;
  max-width: 200px;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--hazard) var(--fill, 60%), rgba(255,255,255,.14) var(--fill, 60%));
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--hazard-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--hazard-dark);
}

/* ==========================================================================
   High scores
   ========================================================================== */

#score-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
#score-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 14px;
}
#score-list .rank { color: var(--ink-dim); width: 26px; font-weight: 700; }
#score-list .name { flex: 1; font-weight: 700; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#score-list .diff {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 5px;
  padding: 2px 7px;
  background: rgba(255,255,255,.1);
  color: var(--ink-dim);
}
#score-list .diff.easy   { color: #7ee081; background: rgba(126,224,129,.12); }
#score-list .diff.normal { color: var(--hazard); background: rgba(255,198,26,.12); }
#score-list .diff.hard   { color: var(--danger); background: rgba(255,80,49,.14); }
#score-list .pts { font-weight: 700; color: var(--gold); }
#score-list li.top1 { border-color: rgba(255,215,106,.5); background: rgba(255,215,106,.07); }

.empty-note { color: var(--ink-dim); font-size: 14px; }

/* ==========================================================================
   Game over
   ========================================================================== */

.go-score-wrap { display: flex; flex-direction: column; gap: 2px; }
.go-label { color: var(--ink-dim); letter-spacing: 4px; font-size: 13px; }
.go-score {
  font-size: clamp(44px, 12vw, 64px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.05;
  text-shadow: 0 4px 0 rgba(0,0,0,.5);
}
.go-best { color: var(--gold); font-weight: 700; letter-spacing: 2px; }

.record-badge {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 2px;
  animation: pulse .9s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.12); text-shadow: 0 0 18px rgba(255,215,106,.6); } }

.save-row { display: flex; gap: 8px; }
#initials {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(0,0,0,.35);
  border: 2px solid var(--panel-edge);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
#initials:focus { border-color: var(--hazard); }
.saved-note { color: #7ee081; font-weight: 700; letter-spacing: 1px; }

.pause-score { color: var(--ink-dim); letter-spacing: 3px; }
.pause-score b { color: var(--ink); font-size: 22px; margin-left: 8px; }

/* ==========================================================================
   Difficulty: 4-option segment + insane tag
   ========================================================================== */

.seg.four button { font-size: 12.5px; letter-spacing: 1px; }
#score-list .diff.insane { color: #ff5edb; background: rgba(255,94,219,.15); }

/* ==========================================================================
   Revive (rewarded ad) overlay
   ========================================================================== */

.revive-sub { color: var(--ink-dim); font-size: 14px; line-height: 1.55; }
.revive-sub b { color: #7ee081; }

.revive-timer {
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}
.revive-timer i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffd44d, var(--hazard));
  border-radius: 4px;
}

.btn.reward {
  background: linear-gradient(180deg, #7ee081, #35a84a);
  color: #06230d;
  box-shadow: 0 5px 0 #1d6b2c, 0 10px 22px rgba(0,0,0,.45);
  animation: reward-pulse 1.1s ease-in-out infinite;
}
.btn.reward:active { box-shadow: 0 1px 0 #1d6b2c, 0 4px 10px rgba(0,0,0,.45); }
.btn.reward:disabled { filter: grayscale(.7) brightness(.85); cursor: wait; animation: none; }
.btn:disabled { cursor: default; }
@keyframes reward-pulse { 50% { transform: scale(1.04); } }

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 480px), (max-height: 560px) {
  .panel { padding: 20px 18px 16px; gap: 10px; border-radius: 14px; }
  .title { letter-spacing: 1px; }
  .title span { letter-spacing: 5px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01s !important; transition-duration: .01s !important; }
}
