:root {
  --ink: #f5f0ea;
  --muted: #a89f94;
  --panel: rgba(22, 18, 16, 0.92);
  --panel-border: rgba(255, 180, 90, 0.18);
  --accent: #ff7a18;
  --accent-hot: #ff4d00;
  --accent-glow: rgba(255, 122, 24, 0.55);
  --danger: #ff2d55;
  --safe: #ffb347;
  --dead: #2a2420;
  --font-d: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  --font-b: "Noto Sans SC", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-b);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
  background: #0f0c0a;
  overflow-x: hidden;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 80% 60% at 50% 110%, #2a1508 0%, #0f0c0a 55%);
}

.scene-grid {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 140, 40, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 140, 40, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 20%, transparent 75%);
}

.scene-glow {
  position: absolute;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.scene-glow--left {
  top: -10%;
  left: -8%;
  background: rgba(255, 90, 0, 0.22);
  animation: drift 12s ease-in-out infinite;
}

.scene-glow--right {
  bottom: 5%;
  right: -10%;
  background: rgba(255, 45, 85, 0.14);
  animation: drift 14s ease-in-out infinite reverse;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(3%, 4%) scale(1.08); }
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.2rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.back {
  color: #ffb86a;
  text-decoration: none;
  font-weight: 700;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex: 1;
}

.mark {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: linear-gradient(145deg, #ffb347, #ff6b00);
  box-shadow: 0 8px 24px rgba(255, 107, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  animation: markBob 2.8s ease-in-out infinite;
}

@keyframes markBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-4px) rotate(3deg); }
}

.brand h1 {
  margin: 0;
  font-family: var(--font-d);
  font-size: 1.65rem;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.5rem 1.2rem 3rem;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.tool-select select {
  border: 1px solid rgba(255, 180, 90, 0.28);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: #ffd9a8;
  cursor: pointer;
}

.tool-select select option {
  background: #1a1512;
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.field > span {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 700;
}

.guess-row {
  display: flex;
  gap: 0.55rem;
}

.guess-row input,
.field select,
.field input[type="number"] {
  flex: 1;
  border: 1px solid rgba(255, 180, 90, 0.22);
  border-radius: 14px;
  padding: 0.72rem 0.9rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.field select {
  cursor: pointer;
}

.field select option {
  background: #1a1512;
  color: var(--ink);
}

.btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  border-radius: 14px;
  padding: 0.75rem 1.25rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(145deg, #ffb347, #ff6b00);
  color: #1a0f08;
  box-shadow: 0 6px 0 #b34700, 0 10px 28px rgba(255, 107, 0, 0.35);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 180, 90, 0.28);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: #ffd9a8;
  border: 1px solid rgba(255, 180, 90, 0.2);
}

#btnMute {
  min-width: 2.6rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  font-size: 1.05rem;
  line-height: 1;
}

#btnMute[aria-pressed="true"] {
  opacity: 0.72;
}

.btn.wide {
  width: 100%;
  margin-top: 0.65rem;
}

.layout {
  display: grid;
  gap: 1rem;
}

@media (min-width: 920px) {
  .layout {
    grid-template-columns: 1fr 280px;
  }
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.4rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 180, 90, 0.12);
  font-size: 1.05rem;
}

.status strong {
  color: #ffd9a8;
  font-size: 1.2rem;
}

/* —— Number board —— */
.board-wrap {
  position: relative;
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 180, 90, 0.14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

.board-wrap.is-tense {
  border-color: rgba(255, 122, 24, 0.35);
  box-shadow: 0 0 32px rgba(255, 122, 24, 0.12), 0 16px 40px rgba(0, 0, 0, 0.35);
}

.board-wrap.is-critical {
  border-color: rgba(255, 45, 85, 0.45);
  animation: boardPulse 0.9s ease-in-out infinite;
}

@keyframes boardPulse {
  0%, 100% { box-shadow: 0 0 24px rgba(255, 45, 85, 0.15), 0 16px 40px rgba(0, 0, 0, 0.35); }
  50% { box-shadow: 0 0 40px rgba(255, 45, 85, 0.28), 0 16px 40px rgba(0, 0, 0, 0.35); }
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.board-kicker {
  margin: 0;
  font-family: var(--font-d);
  font-size: 1.35rem;
  color: #ffd9a8;
}

.board-legend {
  display: flex;
  gap: 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.leg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
}

.leg::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
}

.leg-live::before {
  background: linear-gradient(145deg, rgba(255, 180, 70, 0.5), rgba(255, 107, 0, 0.35));
  border: 1px solid rgba(255, 180, 90, 0.55);
  box-shadow: 0 0 8px rgba(255, 122, 24, 0.35);
}

.leg-out::before {
  background: var(--dead);
  border: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0.7;
}

.number-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr));
  gap: 0.4rem;
}

@media (min-width: 640px) {
  .number-board {
    gap: 0.5rem;
  }
}

.num-cell {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  padding: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1),
    background 0.35s ease,
    box-shadow 0.35s ease,
    opacity 0.35s ease,
    filter 0.35s ease;
}

.num-cell .num {
  position: relative;
  z-index: 1;
  font-size: clamp(0.72rem, 2.4vw, 1rem);
}

.num-cell.is-live {
  color: #1a0f08;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.45), transparent 45%),
    linear-gradient(145deg, #ffd9a8, #ff9a3c 55%, #ff6b00);
  box-shadow:
    0 4px 0 #b34700,
    0 0 16px rgba(255, 122, 24, 0.25);
}

.num-cell.is-live:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.04);
  filter: brightness(1.08);
  box-shadow:
    0 7px 0 #b34700,
    0 0 24px rgba(255, 122, 24, 0.4);
}

.num-cell.is-live:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 0 #b34700;
}

.num-cell.is-dead-low,
.num-cell.is-dead-high {
  color: rgba(168, 159, 148, 0.55);
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.12) 0 4px,
      rgba(255, 255, 255, 0.02) 4px 8px
    ),
    #1e1916;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: not-allowed;
  opacity: 0.55;
}

.num-cell.is-dead-low {
  transform: scale(0.92);
}

.num-cell.is-dead-high {
  transform: scale(0.92);
}

.num-cell.is-pick-low,
.num-cell.is-pick-high {
  color: #ffd9a8;
  cursor: not-allowed;
  opacity: 0.85;
}

.num-cell.is-pick-low {
  background: linear-gradient(160deg, rgba(61, 156, 255, 0.35), rgba(30, 80, 140, 0.25));
  box-shadow: inset 0 0 0 1px rgba(61, 156, 255, 0.35);
}

.num-cell.is-pick-high {
  background: linear-gradient(160deg, rgba(255, 107, 74, 0.35), rgba(140, 40, 30, 0.25));
  box-shadow: inset 0 0 0 1px rgba(255, 107, 74, 0.35);
}

.num-cell.is-boom {
  color: #fff;
  background:
    radial-gradient(circle at 50% 50%, #ff6b8a, #ff2d55 45%, #8b0018 100%);
  box-shadow:
    0 0 0 3px rgba(255, 45, 85, 0.55),
    0 0 32px rgba(255, 45, 85, 0.65);
  animation: boomCell 0.6s ease-in-out infinite alternate;
  cursor: not-allowed;
}

@keyframes boomCell {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.num-cell.is-pop {
  animation: cellPop 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes cellPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.bomb-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  padding: 0.5rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffb3c6;
  background: rgba(255, 45, 85, 0.1);
  animation: hintBlink 1.2s ease-in-out infinite;
}

@keyframes hintBlink {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

.bomb-mini {
  font-size: 1.2rem;
  animation: markBob 1.5s ease-in-out infinite;
}

.host-box {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 180, 90, 0.22);
}

.kicker {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.host-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.bomb-peek {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 45, 85, 0.12);
  border: 1px solid rgba(255, 45, 85, 0.35);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.bomb-peek.is-hidden {
  opacity: 0;
  filter: blur(10px);
  user-select: none;
  pointer-events: none;
}

.bomb-peek .peek-label {
  font-size: 0.85rem;
  color: #ffb3c6;
}

.bomb-peek strong {
  font-family: var(--font-d);
  font-size: 1.8rem;
  color: #ff6b8a;
}

.msg {
  margin: 1rem 0 0;
  min-height: 1.5em;
  font-size: 1.05rem;
  color: #ffd9a8;
}

.history {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.history li {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 180, 90, 0.16);
  animation: chipIn 0.35s ease both;
}

.history li.is-boom {
  background: rgba(255, 45, 85, 0.16);
  border-color: rgba(255, 45, 85, 0.4);
  color: #ffb3c6;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.side {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1.1rem 1rem 1.2rem;
  align-self: start;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.side h2 {
  margin: 0;
  font-family: var(--font-d);
  font-size: 1.5rem;
  color: #ffd9a8;
}

.rules ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.rules li + li {
  margin-top: 0.35rem;
}

/* Explosion overlay */
.explosion-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.explosion-layer.is-active {
  pointer-events: auto;
}

.explosion-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 220, 120, 0.95), rgba(255, 60, 0, 0.55) 35%, transparent 70%);
  opacity: 0;
}

.explosion-layer.is-active .explosion-flash {
  animation: flashBang 0.85s ease-out forwards;
}

@keyframes flashBang {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

.explosion-core {
  font-size: clamp(4rem, 16vw, 8rem);
  filter: drop-shadow(0 0 40px rgba(255, 100, 0, 0.8));
  transform: scale(0.2);
  opacity: 0;
}

.explosion-layer.is-active .explosion-core {
  animation: coreBurst 0.75s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
}

@keyframes coreBurst {
  0% { transform: scale(0.2); opacity: 0; }
  35% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.explosion-text {
  position: absolute;
  bottom: 18%;
  margin: 0;
  font-family: var(--font-d);
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
  opacity: 0;
  transform: translateY(20px);
}

.explosion-layer.is-active .explosion-text {
  animation: textRise 0.55s 0.25s ease-out forwards;
}

@keyframes textRise {
  to { opacity: 1; transform: translateY(0); }
}

.particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 101;
  animation: particleFly var(--dur, 0.9s) ease-out forwards;
}

@keyframes particleFly {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

body.is-shaking {
  animation: screenShake 0.55s ease-out;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(7px, -5px); }
  45% { transform: translate(-6px, -3px); }
  60% { transform: translate(5px, 6px); }
  75% { transform: translate(-4px, 2px); }
}
