*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  background: #0e1016;
  color: #eef1f6;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  user-select: none;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

[hidden] { display: none !important; }

.app {
  --neon: #00e575;
  --neon-dim: #10b981;
  --press: cubic-bezier(0.32, 1.7, 0.42, 1);
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 70% at 50% -8%, #1c2030 0%, #12141c 42%, #0c0d12 100%);
  overflow: hidden;
}

.fx-dom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.topnav {
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}

.app.is-idle .topnav {
  margin-bottom: -44px;
}

.topnav-body {
  position: relative;
  width: min(66%, 268px);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 2px 20px;
  background: linear-gradient(180deg, #2c303a 0%, #16181f 55%, #0e1016 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 8px rgba(0, 0, 0, 0.82);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55));
}

.topnav-gloss {
  position: absolute;
  left: 16%;
  right: 16%;
  top: -5px;
  height: 7px;
  border-radius: 8px;
  background: linear-gradient(#fff, #d8dbe3);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.nav-btn {
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #f2f4f8;
  opacity: 0.92;
  border-radius: 12px;
  background: linear-gradient(180deg, #22252e, #12141a);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.07),
    inset 0 -3px 5px rgba(0, 0, 0, 0.7),
    0 4px 8px rgba(0, 0, 0, 0.35);
}

.nav-btn svg { width: 22px; height: 22px; }

.grid-ico {
  width: 16px;
  height: 16px;
  background:
    linear-gradient(#dfe3ea, #dfe3ea) 0 0 / 7px 7px no-repeat,
    linear-gradient(#dfe3ea, #dfe3ea) 9px 0 / 7px 7px no-repeat,
    linear-gradient(#dfe3ea, #dfe3ea) 0 9px / 7px 7px no-repeat,
    linear-gradient(#dfe3ea, #dfe3ea) 9px 9px / 7px 7px no-repeat;
  border-radius: 2px;
}

.bomb-logo {
  width: 42px;
  height: 48px;
  object-fit: contain;
  margin-top: -6px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.dots {
  position: relative;
  z-index: 7;
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 4px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a1d24;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.06),
    inset 0 -2px 3px rgba(0, 0, 0, 0.8);
}

.dots span.on {
  background: var(--neon);
  box-shadow:
    0 0 6px var(--neon),
    0 0 12px rgba(0, 229, 117, 0.7);
  filter: drop-shadow(0 0 6px var(--neon));
}

.app.is-idle .dots { visibility: hidden; height: 0; margin: 0; }

.field {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vault {
  flex: 0 0 auto;
  max-height: 0;
  opacity: 0;
  margin: 0 2px;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transition: max-height 0.55s ease, opacity 0.4s ease, transform 0.55s ease, margin 0.55s ease;
}

.vault.is-open {
  max-height: 170px;
  opacity: 1;
  margin: 0 2px 6px;
  transform: none;
  pointer-events: auto;
}

.vault-body {
  position: relative;
  padding: 11px 12px 18px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, #2a2e38 0%, #15171d 48%, #0c0d11 100%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 6px rgba(0, 0, 0, 0.8),
    0 10px 20px rgba(0, 0, 0, 0.6);
}

.vault-body::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 8px;
  height: 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
}

.vault-screen {
  height: 112px;
  border-radius: 22px;
  background: radial-gradient(90% 80% at 50% 50%, #101010 0%, #050505 70%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.05),
    inset 0 -4px 8px rgba(0, 0, 0, 0.85),
    inset 0 0 0 2px #1a1c22;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vault.won .vault-body {
  box-shadow:
    0 0 20px rgba(0, 229, 117, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 6px rgba(0, 0, 0, 0.8),
    0 10px 20px rgba(0, 0, 0, 0.6);
}

.vault.won .vault-screen {
  background: radial-gradient(80% 80% at 50% 45%, #102010 0%, #050805 72%);
}

.win-copy {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon), 0 0 28px rgba(0, 229, 117, 0.7);
  opacity: 0;
  transform: scale(0.8);
  transition: 0.45s var(--press);
}

.vault.won .win-copy {
  opacity: 1;
  transform: scale(1);
}

.viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 16px 10px 22px;
}

.board {
  --cell: 42vw;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  perspective: 1100px;
}

.row {
  display: grid;
  grid-template-columns: var(--cell) var(--cell);
  justify-content: center;
  align-items: center;
  gap: 14px;
  height: var(--cell);
  overflow: visible;
  transition:
    height 0.5s cubic-bezier(0.22, 0.82, 0.2, 1),
    opacity 0.22s ease,
    transform 0.28s ease,
    gap 0.5s ease;
}

.row.leaving {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.row.spent {
  height: 0;
  gap: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: scale(0.86);
}

.cell {
  position: relative;
  cursor: pointer;
  width: var(--cell);
  height: var(--cell);
  overflow: visible;
  perspective: 900px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition:
    width 0.5s cubic-bezier(0.22, 0.82, 0.2, 1),
    height 0.5s cubic-bezier(0.22, 0.82, 0.2, 1);
}

.cell-3d {
  position: relative;
  width: 100%;
  height: 100%;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.cell.win .cell-3d,
.cell.bomb .cell-3d {
  transform: rotateY(180deg);
}

.cell-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.cell-back {
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
}

.cell-mark {
  width: 52%;
  height: 52%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.cell.win .cell-mark {
  opacity: 1;
  border: 7px solid #00ff85;
  animation: winPulse 0.45s 0.12s var(--press) both;
}

.cell .bomb-outline {
  position: absolute;
  inset: 22%;
  width: 56%;
  height: 56%;
  margin: auto;
  opacity: 0;
  pointer-events: none;
}

.cell.bomb .bomb-outline {
  opacity: 0.7;
  animation: bombShake 0.5s 0.12s ease both;
}

.prompt {
  flex: 0 0 auto;
  align-self: center;
  margin: 10px 0 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(18, 20, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: #c5c9d2;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.prompt-play { color: #fff; margin-left: 3px; }

.hash {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 8px;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #16181f, #101218);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 6px rgba(0, 0, 0, 0.8),
    0 10px 20px rgba(0, 0, 0, 0.45);
}

.hash-left {
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 1;
  flex: 0 0 auto;
}

.hash-mark {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #f3f5f8;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.06),
    inset 0 -1px 2px rgba(0, 0, 0, 0.35);
}

.hash-title { font-weight: 700; font-size: 15px; }

.hash-x {
  color: #8b909a;
  font-size: 13px;
  margin-left: 2px;
}

.hash-steps {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex: 1;
  z-index: 1;
  padding-left: 6px;
}

.hash-step {
  display: flex;
  flex-direction: column;
  color: rgba(16, 185, 129, 0.38);
  font-weight: 700;
  font-size: 14px;
}

.hash-step .payout {
  font-size: 13px;
  color: var(--neon);
  line-height: 1.05;
}

.hash-step.is-current { color: var(--neon); }

.hash-glow {
  position: absolute;
  right: -8px;
  top: 0;
  bottom: 0;
  width: 38%;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 117, 0.22));
  pointer-events: none;
}

.controls { flex: 0 0 auto; margin-bottom: 6px; }

.idle-bar,
.play-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-chip {
  min-width: 48px;
  font-weight: 800;
  font-size: 18px;
  color: #d5d8e0;
}

.stake {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step {
  width: 28px;
  font-size: 22px;
  color: #c7cbd4;
}

.stake-mid { text-align: center; }

.stake-val {
  font-size: 20px;
  font-weight: 800;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 2px;
}

.stake-sub {
  margin-top: 3px;
  font-size: 11px;
  color: #8a8f99;
}

.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(0, 229, 117, 0.45);
  background: linear-gradient(180deg, #1a1d24, #101218);
  color: var(--neon);
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 6px rgba(0, 0, 0, 0.8),
    0 0 20px rgba(0, 229, 117, 0.4);
  transition: transform 0.2s var(--press);
}

.play-btn:active { transform: scale(0.94); }

.play-btn svg { width: 20px; height: 20px; fill: currentColor; margin-left: 3px; }

.play-bar .side-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, #1b1e26, #12141a);
  color: #c9ced8;
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -4px 6px rgba(0, 0, 0, 0.8),
    0 8px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s var(--press);
}

.play-bar .side-btn:active { transform: scale(0.94); }

.play-bar .side-btn svg { width: 22px; height: 22px; }

.play-bar .cash {
  font-size: 22px;
  font-weight: 800;
}

.total-win {
  flex: 1;
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, #1a1c24, #12141a);
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.06),
    inset 0 -4px 6px rgba(0, 0, 0, 0.75);
}

.total-val { font-size: 18px; font-weight: 800; }
.total-sub { font-size: 11px; color: #8a8f99; }

.total-win.lit {
  border-color: rgba(0, 229, 117, 0.35);
  box-shadow:
    0 0 20px rgba(0, 229, 117, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.06);
}

.total-win.lit .total-val {
  color: var(--neon);
  text-shadow: 0 0 12px rgba(0, 229, 117, 0.55);
}

.again {
  margin: 0 auto 8px;
  padding: 8px 22px;
  border-radius: 12px;
  background: var(--neon);
  color: #052010;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 0 20px rgba(0, 229, 117, 0.4);
  transition: transform 0.2s var(--press);
}
.again:active { transform: scale(0.94); }

.again[hidden] { display: none !important; }
.again:not([hidden]) { display: block; }

.footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 14px;
  padding-top: 2px;
}

.back { justify-self: start; color: #c9ced6; }
.balance {
  font-weight: 800;
  color: var(--neon);
  text-shadow: 0 0 10px rgba(0, 229, 117, 0.35);
}
.deposit {
  justify-self: end;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--neon);
  color: #052010;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 0 20px rgba(0, 229, 117, 0.4);
  transition: transform 0.2s var(--press);
}
.deposit:active { transform: scale(0.94); }

.app.is-playing .prompt,
.app.is-playing #idleBar { display: none; }

.app.is-idle #playBar,
.app.is-idle .hash { display: none; }

.spark {
  position: absolute;
  pointer-events: none;
  animation: sparkFly ease-out forwards;
  filter: drop-shadow(0 0 6px #9cff40);
}

.spark.coin {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2.3px solid #c9ff5c;
  border-radius: 50%;
  background: radial-gradient(transparent 42%, rgba(201, 255, 92, 0.28) 46%, transparent 58%);
  box-shadow: 0 0 10px #8cff3a;
}

.spark.bill {
  width: 30px;
  height: 18px;
  margin: -9px 0 0 -15px;
  border: 2px solid #c9ff5c;
  border-radius: 4px;
  box-shadow: 0 0 10px #8cff3a;
  display: grid;
  place-items: center;
  color: #c9ff5c;
  font-size: 11px;
  font-weight: 800;
}

@keyframes sparkFly {
  0% { transform: translate(0, 0) rotate(0deg) scale(0.55); opacity: 0; }
  8% { opacity: 1; }
  72% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.75; }
}

@keyframes winPulse {
  0% { transform: scale(0.5); opacity: 0.45; }
  62% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bombShake {
  0% { transform: scale(0.5) rotate(0deg); }
  40% { transform: scale(1.06) rotate(-8deg); }
  55% { transform: scale(1) rotate(6deg); }
  70% { transform: scale(1) rotate(-4deg); }
  85% { transform: scale(1) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@media (max-height: 740px) {
  .vault-screen { height: 84px; }
  .win-copy { font-size: 22px; }
  .topnav { margin-bottom: -12px; }
  .topnav-body { height: 50px; }
}
