/* Diaper Bomber styles */
:root {
  --bg: #2b2140;
  --bg2: #3a2d57;
  --ink: #3b2a4a;
  --panel: #fff8f0;
  --pink: #ff9ec4;
  --pink-d: #e0679a;
  --blue: #5cb8ff;
  --yellow: #ffd23f;
  --green: #8fe06a;
  --font: "Trebuchet MS", "Arial Rounded MT Bold", "Nunito", Verdana, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,158,196,0.18), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(92,184,255,0.16), transparent 45%),
    var(--bg);
}

#app {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  overflow: hidden;
}

canvas#board {
  position: absolute;
  display: block;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  image-rendering: auto;
  touch-action: none;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  left: 0; right: 0; top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 6px;
  color: #fff;
  font-weight: bold;
  visibility: hidden;
}
#hud.on { visibility: visible; }
.hud-info {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0.6em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 0.12em 0.55em 0.12em 0.3em;
  line-height: 1.2;
}
.hud-item img { width: 1.35em; height: 1.35em; display: block; }
.hud-item.dead { opacity: 0.35; }
.hud-item.warn { background: #ff5d8f; animation: blink 0.5s steps(2) infinite; }
.hud-item .lbl { opacity: 0.75; font-size: 0.8em; }
@keyframes blink { 50% { opacity: 0.55; } }

.hud-btn {
  flex: none;
  width: 2em; height: 2em;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.15);
  color: #fff;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: none;
}
.pause-ic { width: 0.7em; height: 0.8em; border-left: 0.22em solid #fff; border-right: 0.22em solid #fff; }

/* ---------------- banner ---------------- */
.banner {
  position: absolute;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s, transform 0.35s cubic-bezier(.2,1.6,.4,1);
  text-shadow: 0 3px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 6px 12px rgba(0,0,0,0.35);
}
.banner.show { opacity: 1; transform: scale(1); }
.banner .big { font-size: 2.4em; line-height: 1.05; }
.banner .small { font-size: 1em; margin-top: 0.3em; color: #ffe8a3; }

/* ---------------- touch pads ---------------- */
.pad {
  position: absolute;
  display: none;
  touch-action: none;
}
.pad.on { display: block; }
.stick {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 40%, rgba(255,255,255,0.2) 70%);
  border: 3px solid rgba(255,255,255,0.35);
  pointer-events: none;
  transition: opacity 0.15s;
  opacity: 0.55;
}
.stick.active { opacity: 1; }
.knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 44%; height: 44%;
  margin: -22% 0 0 -22%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #bfe6ff 55%, #5cb8ff);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.pad-hint {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  text-align: center;
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  letter-spacing: 0.2em;
  pointer-events: none;
}
.tbtn {
  position: absolute;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 900;
  border: 4px solid var(--ink);
  box-shadow: 0 6px 0 rgba(0,0,0,0.35);
  touch-action: none;
  transition: transform 0.06s;
}
.tbtn img { width: 55%; height: 55%; pointer-events: none; }
.tbtn span { font-size: 11px; letter-spacing: 0.05em; margin-top: -2px; pointer-events: none; }
.tbtn.bomb { background: radial-gradient(circle at 35% 30%, #fff, #ffc2da 50%, var(--pink)); }
.tbtn.det  { background: radial-gradient(circle at 35% 30%, #fff, #e3d4ff 50%, #b89cff); }
.tbtn.det.off { opacity: 0.35; filter: grayscale(0.8); }
.tbtn.down { transform: translateY(4px) scale(0.95); box-shadow: 0 2px 0 rgba(0,0,0,0.35); }

/* ---------------- overlays ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(43,33,64,0.55);
  z-index: 10;
}
.overlay.on { display: flex; animation: fadein 0.2s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#scrTitle { background: rgba(43,33,64,0.35); }

.panel {
  background: var(--panel);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 rgba(0,0,0,0.3), 0 20px 50px rgba(0,0,0,0.35);
  padding: 18px 20px 16px;
  width: min(380px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: pop 0.35s cubic-bezier(.2,1.5,.4,1);
}
.panel.wide { width: min(560px, 100%); }
@keyframes pop { from { transform: scale(0.85); } to { transform: scale(1); } }

.panel h2 { margin: 2px 0 6px; font-size: 1.6em; color: var(--pink-d); }
.panel h3 { margin: 14px 0 6px; font-size: 1.05em; color: #7a55c9; text-align: left; }
.panel .sub { margin: 0 0 10px; opacity: 0.8; }

.title-art { width: 96px; height: 96px; margin-top: -4px; animation: wobble 2.4s ease-in-out infinite; }
.title-art.small { width: 72px; height: 72px; }
@keyframes wobble { 0%,100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-4px); } }

.logo {
  margin: 0;
  line-height: 0.95;
  font-size: 2.6em;
  font-weight: 900;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  color: #fff;
  text-shadow: 0 4px 0 var(--ink), 0 -2px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -2px 0 var(--ink), -3px -2px 0 var(--ink);
}
.logo .l1 { color: var(--pink); }
.logo .l2 { color: var(--blue); }
.tag { margin: 8px 0 12px; font-size: 0.95em; opacity: 0.8; }

.menu { display: flex; flex-direction: column; gap: 9px; width: 100%; align-items: stretch; }
.menu.row { flex-direction: row; justify-content: center; margin-top: 10px; }
.btn {
  font: inherit;
  font-weight: 900;
  font-size: 1.15em;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 11px 14px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s, box-shadow 0.06s, background 0.15s;
}
.btn:hover, .btn:focus-visible { background: #fff1c4; outline: none; }
.btn:focus-visible { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px rgba(92,184,255,0.6); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--pink); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.primary:hover, .btn.primary:focus-visible { background: #ff86b5; }
.btn.small { font-size: 0.95em; padding: 8px 12px; }
.btn.reward { background: var(--green); font-size: 1em; }
.btn.reward:hover, .btn.reward:focus-visible { background: #a6ec85; }
.btn[hidden] { display: none; }

.hi { margin: 12px 0 4px; }
.links { display: flex; gap: 8px; justify-content: center; font-size: 0.9em; margin-top: 4px; }
.links a { color: #7a55c9; font-weight: bold; text-decoration: none; padding: 4px; }
.links a:hover { text-decoration: underline; }

.scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  text-align: left;
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 4px;
  line-height: 1.4;
}
.scroll p { margin: 0 0 8px; }
.ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ctrl-grid div { background: #fff; border: 2px solid #eadff5; border-radius: 10px; padding: 6px 8px; font-size: 0.9em; }
.ctrl-grid b { display: block; color: #7a55c9; }
.icon-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.icon-list li { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid #eadff5; border-radius: 10px; padding: 4px 8px; font-size: 0.88em; }
.icon-list img { width: 36px; height: 36px; flex: none; }
.icon-list b { display: block; }

.opt { width: 100%; margin: 6px 0 10px; text-align: left; }
.opt-label { display: block; font-weight: bold; margin-bottom: 4px; }
.seg { display: flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button {
  flex: 1;
  font: inherit;
  font-weight: bold;
  border: 0;
  border-left: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 9px 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.seg button:first-child { border-left: 0; }
.seg button.sel { background: var(--blue); color: #fff; text-shadow: 0 1px 0 var(--ink); }
.seg button:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }

.stats { width: 100%; margin: 4px 0 14px; display: grid; gap: 4px; }
.stats div { display: flex; justify-content: space-between; background: #fff; border: 2px solid #eadff5; border-radius: 10px; padding: 6px 10px; }
.stats b { color: #7a55c9; }
.stats .new { color: #e0679a; animation: blink 0.6s steps(2) infinite; }

.toast {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.85em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 20;
}
.toast.show { opacity: 1; }

@media (max-height: 520px) {
  .panel { padding: 10px 14px; border-radius: 16px; }
  .title-art { width: 60px; height: 60px; }
  .logo { font-size: 1.9em; }
  .tag { margin: 4px 0 8px; font-size: 0.85em; }
  .btn { padding: 7px 12px; font-size: 1em; }
  .menu { gap: 6px; }
  .hi { margin: 6px 0 2px; }
  .title-panel { width: min(560px, 100%); }
  .title-panel .menu { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .title-art, .panel, .overlay.on { animation: none; }
}
