/* ── Page layout ──────────────────────────────────────────────────────────── */
#canvas-wrap {
  background: #0c0e14;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── HUD ──────────────────────────────────────────────────────────────────── */
.cbomb-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(512px, calc(100vw - 16px));
  padding: 10px 4px 8px;
  flex-shrink: 0;
}

.cbomb-counter {
  font-family: 'Courier New', 'Courier', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ef4444;
  background: #000;
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 54px;
  text-align: center;
  letter-spacing: 0.05em;
  border: 1px solid #1e293b;
  line-height: 1;
  flex-shrink: 0;
}

.cbomb-reset-btn {
  font-size: 1.6rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 2px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
  transition: background 0.1s;
}

.cbomb-reset-btn:hover { background: #263348; }
.cbomb-reset-btn:active { background: #0f172a; }

/* ── Board ────────────────────────────────────────────────────────────────── */
.cbomb-board-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4px 8px 16px;
  flex: 1;
}

#cbomb-board {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  width: min(512px, calc(100vw - 16px));
  aspect-ratio: 1 / 1;
  background: #0c0e14;
  flex-shrink: 0;
}

/* ── Cells ────────────────────────────────────────────────────────────────── */
.cbomb-cell {
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 3.5vw, 17px);
  font-weight: 800;
  font-family: 'DM Sans', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 2px;
  transition: background 0.05s;
  box-sizing: border-box;
}

.cbomb-cell.cbomb-hidden {
  background: #2d3748;
}

.cbomb-cell.cbomb-hidden:hover {
  background: #374151;
}

.cbomb-cell.cbomb-hidden:active {
  background: #4b5563;
}

.cbomb-cell.cbomb-revealed {
  background: #111827;
  cursor: default;
}

.cbomb-cell.cbomb-flagged {
  background: #2d3748;
  font-size: clamp(9px, 3vw, 14px);
}

.cbomb-cell.cbomb-mine {
  background: #7f1d1d;
  font-size: clamp(9px, 3vw, 14px);
}

.cbomb-cell.cbomb-triggered {
  background: #dc2626 !important;
}

/* Color swatch — background set via inline style by JS */
.cbomb-cell.cbomb-swatch {
  cursor: default;
  border-radius: 2px;
}

.cbomb-cell.cbomb-wrong-flag {
  background: #431407;
  color: #f97316;
  font-size: clamp(9px, 3.2vw, 15px);
  font-weight: 900;
}

/* ── End overlay ──────────────────────────────────────────────────────────── */
.cbomb-end {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 20, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

.cbomb-end-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 300px;
  text-align: center;
  padding: 28px 24px;
}

.cbomb-end-headline {
  font-size: 1.6rem;
  font-weight: 800;
  color: #f1f5f9;
  margin: 0;
  line-height: 1.2;
}

.cbomb-end-sub {
  font-size: 0.9rem;
  color: #94a3b8;
  margin: 0;
}

/* ── Shared button styles (match colorblind.css pattern) ─────────────────── */
.cb-btn-primary {
  background: #f1f5f9;
  color: #0f172a;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.cb-btn-primary:hover { background: #e2e8f0; }
.cb-btn-primary:active { background: #cbd5e1; }

.cb-btn-ghost {
  background: transparent;
  color: #64748b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.1s, color 0.1s;
}

.cb-btn-ghost:hover { border-color: #475569; color: #94a3b8; }

/* ── Key panel ────────────────────────────────────────────────────────────── */
.cbomb-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 26, 0.97);
  border-top: 1px solid #334155;
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.cbomb-panel.cbomb-panel-open {
  transform: translateY(0);
}

.cbomb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cbomb-panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cbomb-panel-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}

.cbomb-panel-close:hover { color: #94a3b8; }

.cbomb-key-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}

.cbomb-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cbomb-key-swatch {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  flex-shrink: 0;
}

.cbomb-key-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid #2d3f55;
  border-radius: 6px;
  color: #f1f5f9;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  padding: 6px 10px;
  min-width: 0;
  -webkit-appearance: none;
}

.cbomb-key-input:focus {
  outline: none;
  border-color: #475569;
  background: #243449;
}

.cbomb-key-input::placeholder {
  color: #334155;
  font-weight: 400;
}

/* ── Mapping reveal (end overlay) ─────────────────────────────────────────── */
.cbomb-mapping {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  width: 100%;
  margin: 4px 0 8px;
}

.cbomb-map-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cbomb-map-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}

.cbomb-map-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #f1f5f9;
  font-family: 'DM Sans', sans-serif;
}

/* ── Utilities ────────────────────────────────────────────────────────────── */
.cbomb-hide { display: none !important; }
