.bmg-wrap,
.bmg-wrap * {
  box-sizing: border-box;
}

.bmg-wrap {
  --bmg-bg: #0d1119;
  --bmg-card: rgba(18, 22, 34, .92);
  --bmg-card-2: rgba(28, 31, 45, .92);
  --bmg-ink: #f4efe3;
  --bmg-muted: #b8b0a4;
  --bmg-gold: #d1a85b;
  --bmg-red: #a43435;
  --bmg-blue: #89b9d7;
  --bmg-border: rgba(255,255,255,.12);
  --bmg-shadow: 0 26px 90px rgba(0,0,0,.45);
  width: 100vw;
  max-width: 100vw;
  min-height: 100vh;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: 0;
  margin-bottom: 0;
  padding: clamp(14px, 1.8vw, 26px);
  color: var(--bmg-ink);
  border-radius: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(209,168,91,.25), transparent 32%),
    radial-gradient(circle at 80% 12%, rgba(137,185,215,.18), transparent 28%),
    linear-gradient(135deg, #111827 0%, #090b12 100%);
  box-shadow: var(--bmg-shadow);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bmg-wrap:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .36;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 35%, black, transparent 82%);
}

.bmg-case-header,
.bmg-game-shell {
  width: min(1560px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.bmg-case-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.bmg-kicker,
.bmg-modal-kicker {
  margin: 0 0 6px;
  color: var(--bmg-gold);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.bmg-case-header h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 58px);
  line-height: .95;
  letter-spacing: -.04em;
  color: #fff7e8;
  text-shadow: 0 6px 26px rgba(0,0,0,.5);
}

.bmg-case-header p:not(.bmg-kicker) {
  margin: 10px 0 0;
  color: var(--bmg-muted);
  max-width: 820px;
  font-size: 16px;
}

.bmg-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.bmg-btn,
.bmg-wrap button.bmg-btn {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 12px 18px;
  color: #17110a;
  background: linear-gradient(180deg, #f5d98d, #c69238);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
  transition: transform .16s ease, filter .16s ease, border-color .16s ease;
  font-size: 13px;
}

.bmg-btn:hover,
.bmg-wrap button.bmg-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.bmg-btn-ghost,
.bmg-wrap button.bmg-btn-ghost {
  color: var(--bmg-ink);
  background: rgba(255,255,255,.08);
}

.bmg-btn-danger,
.bmg-wrap button.bmg-btn-danger {
  color: white;
  background: linear-gradient(180deg, #cc5052, #7d1c22);
}

.bmg-game-shell {
  display: block;
}

.bmg-stage-card,
.bmg-side-card {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.035));
  border: 1px solid var(--bmg-border);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 20px 60px rgba(0,0,0,.28);
  overflow: hidden;
}

.bmg-stage-card {
  width: 100%;
}

.bmg-topbar {
  display: grid;
  grid-template-columns: 150px 150px 170px minmax(260px, 1fr);
  gap: 1px;
  background: rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.bmg-stat,
.bmg-hint {
  padding: 14px 18px;
  background: rgba(7, 10, 17, .62);
}

.bmg-stat span {
  display: block;
  margin-bottom: 2px;
  color: var(--bmg-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.bmg-stat strong {
  display: block;
  color: white;
  font-size: 18px;
  white-space: nowrap;
}

.bmg-hint {
  display: flex;
  align-items: center;
  color: #f4d28f;
  font-size: 14px;
  font-weight: 800;
}

.bmg-canvas-frame {
  padding: 16px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,235,181,.08), transparent 56%),
    linear-gradient(180deg, #0d1018, #07080d);
}

.bmg-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  background: #07080d;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 0 42px rgba(0,0,0,.7), 0 18px 55px rgba(0,0,0,.35);
  image-rendering: auto;
}

.bmg-side-card {
  margin-top: 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) minmax(260px, .9fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 14px;
  background:
    radial-gradient(circle at 100% 0%, rgba(209,168,91,.12), transparent 42%),
    linear-gradient(180deg, rgba(28,31,45,.92), rgba(14,16,26,.92));
}

.bmg-detective-card {
  display: flex;
  gap: 12px;
  min-height: 100%;
}

.bmg-detective-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,.09);
  font-size: 28px;
}

.bmg-side-card h3,
.bmg-side-card h4,
.bmg-modal-card h3,
.bmg-notebook-grid h4 {
  margin: 0 0 7px;
  color: #fff7e8;
  letter-spacing: -.02em;
}

.bmg-side-card h3 {
  font-size: 24px;
}

.bmg-side-card h4 {
  font-size: 18px;
}

.bmg-side-card p {
  margin: 0;
  color: var(--bmg-muted);
  font-size: 14px;
  line-height: 1.5;
}

.bmg-progress-box,
.bmg-controls-box,
.bmg-mini-notes,
.bmg-detective-card {
  padding: 16px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
}

.bmg-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--bmg-muted);
  font-size: 13px;
}

.bmg-progress-row strong {
  color: var(--bmg-gold);
}

.bmg-progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
}

.bmg-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8bbbd9, #e6be67);
  transition: width .25s ease;
}

.bmg-controls-box p + p {
  margin-top: 7px;
}

.bmg-mini-notes ul,
.bmg-notebook-grid ul {
  margin: 0;
  padding-left: 18px;
  color: var(--bmg-muted);
}

.bmg-mini-notes li,
.bmg-notebook-grid li {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.42;
}

.bmg-mobile-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: rgba(0,0,0,.22);
  border-top: 1px solid rgba(255,255,255,.08);
}

.bmg-dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 40px);
  gap: 5px;
}

.bmg-dpad button,
.bmg-interact-mobile {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  color: white;
  background: rgba(255,255,255,.1);
  font-weight: 900;
  touch-action: manipulation;
}

.bmg-dpad button[data-bmg-dir="up"] { grid-column: 2; grid-row: 1; }
.bmg-dpad button[data-bmg-dir="left"] { grid-column: 1; grid-row: 2; }
.bmg-dpad button[data-bmg-dir="down"] { grid-column: 2; grid-row: 3; }
.bmg-dpad button[data-bmg-dir="right"] { grid-column: 3; grid-row: 2; }

.bmg-interact-mobile {
  min-height: 54px;
  min-width: 130px;
  background: linear-gradient(180deg, #f2ca72, #b98331);
  color: #160f09;
}

.bmg-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 7, 12, .78);
  backdrop-filter: blur(12px);
  z-index: 999999;
}

.bmg-modal.is-open {
  display: flex;
}

.bmg-modal-card {
  width: min(720px, 96vw);
  max-height: min(760px, 92vh);
  overflow: auto;
  position: relative;
  padding: clamp(20px, 3vw, 32px);
  color: var(--bmg-ink);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 0%, rgba(209,168,91,.2), transparent 34%),
    linear-gradient(180deg, rgba(31,35,51,.98), rgba(12,14,22,.98));
  box-shadow: 0 28px 100px rgba(0,0,0,.58);
}

.bmg-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  color: white;
  background: rgba(255,255,255,.08);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.bmg-dialog-card h3,
.bmg-notebook-card h3,
.bmg-accuse-card h3 {
  margin: 0 34px 12px 0;
  font-size: clamp(24px, 3vw, 34px);
}

.bmg-dialog-text {
  color: #e7ddcf;
  font-size: 16px;
  line-height: 1.65;
}

.bmg-dialog-text p {
  margin: 0 0 12px;
}

.bmg-dialog-text .bmg-quote {
  margin: 12px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--bmg-gold);
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  color: #fff4dd;
}

.bmg-dialog-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.bmg-notebook-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.bmg-notebook-grid section,
.bmg-theory-box {
  padding: 16px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 18px;
  background: rgba(0,0,0,.2);
}

.bmg-theory-box {
  margin-top: 16px;
  color: #f4d9a0;
  line-height: 1.45;
}

.bmg-suspect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.bmg-suspect-choice {
  text-align: left;
  padding: 14px;
  min-height: 88px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  color: var(--bmg-ink);
  background: rgba(255,255,255,.07);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.bmg-suspect-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(209,168,91,.7);
  background: rgba(209,168,91,.12);
}

.bmg-suspect-choice strong {
  display: block;
  margin-bottom: 5px;
  color: #fff7e8;
  font-size: 16px;
}

.bmg-suspect-choice span {
  color: var(--bmg-muted);
  font-size: 12px;
}

.bmg-accuse-warning {
  margin: 0;
  color: var(--bmg-muted);
}

.bmg-verdict {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  line-height: 1.55;
}

.bmg-verdict.is-win {
  background: rgba(42, 117, 83, .2);
  color: #d9ffe7;
}

.bmg-verdict.is-lose {
  background: rgba(164, 52, 53, .2);
  color: #ffe0df;
}

.bmg-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  padding: 18px;
}

.bmg-wrap:fullscreen .bmg-case-header,
.bmg-wrap:fullscreen .bmg-game-shell {
  width: min(1760px, 100%);
}

@media (max-width: 1200px) {
  .bmg-side-card {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 900px) {
  .bmg-wrap {
    min-height: auto;
  }
  .bmg-case-header {
    display: grid;
    align-items: start;
  }
  .bmg-header-actions {
    justify-content: flex-start;
  }
  .bmg-side-card {
    grid-template-columns: 1fr;
  }
  .bmg-topbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .bmg-hint {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .bmg-wrap {
    padding: 10px;
  }
  .bmg-case-header h2 {
    font-size: 31px;
  }
  .bmg-header-actions .bmg-btn {
    flex: 1 1 auto;
  }
  .bmg-mobile-controls {
    display: flex;
  }
  .bmg-notebook-grid,
  .bmg-suspect-grid {
    grid-template-columns: 1fr;
  }
  .bmg-canvas-frame {
    padding: 8px;
  }
  .bmg-stat,
  .bmg-hint {
    padding: 11px 12px;
  }
  .bmg-stat strong {
    font-size: 15px;
  }
}

.bmg-canvas:focus {
  outline: 3px solid rgba(209,168,91,.72);
  outline-offset: 3px;
}

.bmg-canvas-frame,
.bmg-canvas {
  touch-action: none;
}
