:root {
  --bg: #020713;
  --panel: rgba(4, 20, 38, 0.78);
  --panel-strong: rgba(5, 31, 55, 0.92);
  --line: rgba(102, 235, 255, 0.28);
  --cyan: #53e8ff;
  --teal: #20d9c4;
  --gold: #f6b93b;
  --red: #ff4b5f;
  --green: #35ef9f;
  --text: #f4fbff;
  --muted: #98b9c7;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 50% -10%, #0b5c88 0, var(--bg) 48%, #01030a 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.game-stage {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #04101e;
  box-shadow: var(--shadow);
  --bg-shift: 0px;
  --bg-scale: 1.04;
  --depth-shift: 0px;
  --camera-shake-x: 0px;
  --camera-shake-y: 0px;
  --world-shift: 0px;
}

.stage-bg {
  position: absolute;
  inset: 0;
  background: #020713;
  transform: translate3d(var(--camera-shake-x), var(--camera-shake-y), 0) scale(var(--bg-scale));
  transition: filter 250ms ease;
}

.stage-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(90deg, rgba(1, 6, 15, 0.82), rgba(1, 9, 18, 0.08), rgba(1, 6, 15, 0.86)),
    radial-gradient(circle at 50% 18%, rgba(77, 226, 255, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(0, 242, 255, 0.06), rgba(0, 0, 0, 0.3));
  pointer-events: none;
}

.stage-bg::after {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 4;
  background:
    radial-gradient(circle at 20% 20%, rgba(83, 232, 255, 0.14), transparent 22%),
    radial-gradient(circle at 72% 70%, rgba(246, 185, 59, 0.12), transparent 18%),
    linear-gradient(115deg, transparent 25%, rgba(122, 246, 255, 0.12) 45%, transparent 62%);
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: lightSweep 9s ease-in-out infinite alternate;
}

.world-map {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  width: 100%;
  min-width: 760px;
  height: auto;
  min-height: 118%;
  transform: translate3d(-50%, var(--world-shift), 0);
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

.bubble-field,
.fx-layer,
.current-field {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.current-field {
  z-index: 2;
  opacity: 0.35;
  mix-blend-mode: screen;
}

.current-field span {
  position: absolute;
  left: -20%;
  width: 55%;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(129, 245, 255, 0.8), transparent);
  transform: rotate(-18deg);
  animation: currentSlide 4.8s linear infinite;
}

.current-field span:nth-child(1) {
  top: 22%;
  animation-delay: -1.1s;
}

.current-field span:nth-child(2) {
  top: 39%;
  width: 70%;
  animation-delay: -2.2s;
}

.current-field span:nth-child(3) {
  top: 58%;
  animation-delay: -0.4s;
}

.current-field span:nth-child(4) {
  top: 75%;
  width: 66%;
  animation-delay: -3.4s;
}

.bubble {
  position: absolute;
  bottom: -30px;
  width: var(--size);
  height: var(--size);
  border: 1px solid rgba(160, 248, 255, 0.65);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.8), rgba(83, 232, 255, 0.14) 42%, transparent 68%);
  opacity: 0;
  animation: bubbleRise var(--duration) linear forwards;
}

.fx-pop {
  position: absolute;
  left: var(--x);
  top: var(--y);
  color: var(--color);
  font-weight: 950;
  font-size: clamp(1rem, 3vw, 2.2rem);
  text-shadow: 0 0 18px currentColor;
  transform: translate(-50%, -50%);
  animation: fxPop 900ms ease-out forwards;
}

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.95;
  text-transform: uppercase;
}

h1 {
  color: #dcfbff;
  font-size: clamp(2.1rem, 6vw, 5.5rem);
  letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(83, 232, 255, 0.55);
}

h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.balance-card,
.control-panel,
.history-panel,
.prototype-notes {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.balance-card {
  align-self: start;
  min-width: 180px;
  padding: 12px 14px;
  border-radius: 8px;
  text-align: right;
}

.balance-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.balance-card strong {
  display: block;
  color: var(--gold);
  font-size: 1.35rem;
}

.multiplier-wrap {
  position: absolute;
  z-index: 4;
  top: 24%;
  left: 50%;
  width: min(480px, calc(100% - 36px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.multiplier-wrap p,
.multiplier-wrap small {
  display: inline-flex;
  margin: 0;
  border: 1px solid rgba(83, 232, 255, 0.2);
  border-radius: 999px;
  background: rgba(2, 9, 20, 0.56);
  color: var(--muted);
  padding: 7px 13px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.78rem;
  font-weight: 800;
}

.multiplier-wrap strong {
  display: block;
  margin: 8px 0;
  color: #eaffff;
  font-size: clamp(4.2rem, 13vw, 10rem);
  letter-spacing: -0.04em;
  text-shadow:
    0 0 22px rgba(83, 232, 255, 0.9),
    0 0 70px rgba(32, 217, 196, 0.35);
}

.submarine-layer {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 47%;
  width: min(330px, 42vw);
  aspect-ratio: 1;
  transform:
    translate(-50%, -50%)
    translate3d(var(--sub-x, 0px), var(--sub-y, 0px), 0)
    rotate(var(--sub-rotate, 0deg))
    scale(var(--sub-scale, 1));
  transition: filter 180ms ease, opacity 180ms ease;
  will-change: transform;
}

.submarine-layer img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(83, 232, 255, 0.45));
}

.engine-trail {
  position: absolute;
  z-index: 1;
  left: -18%;
  top: 45%;
  width: 38%;
  height: 16%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(83, 232, 255, 0.22), rgba(101, 255, 238, 0.78));
  filter: blur(6px);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 180ms ease;
}

.sonar-ring {
  position: absolute;
  inset: 25%;
  border: 1px solid rgba(83, 232, 255, 0.26);
  border-radius: 50%;
  opacity: 0;
}

.ring-one {
  animation: sonar 2.3s linear infinite;
}

.ring-two {
  animation: sonar 2.3s 0.8s linear infinite;
}

.depth-track {
  position: absolute;
  z-index: 1;
  top: 16%;
  right: 28px;
  bottom: 18%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px dashed rgba(83, 232, 255, 0.45);
  padding-right: 18px;
  transform: translate3d(0, var(--depth-shift), 0);
  transition: opacity 180ms ease;
}

.depth-track span {
  color: var(--cyan);
  font-weight: 900;
  text-shadow: 0 0 15px rgba(83, 232, 255, 0.85);
}

.pressure-meter {
  position: absolute;
  z-index: 4;
  right: 22px;
  bottom: 22px;
  width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 15, 30, 0.72);
  padding: 12px;
  backdrop-filter: blur(14px);
}

.meter-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.meter-shell {
  overflow: hidden;
  height: 12px;
  border: 1px solid rgba(83, 232, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 8, 18, 0.72);
}

.meter-shell span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--red));
  box-shadow: 0 0 18px rgba(83, 232, 255, 0.4);
  transition: width 150ms linear;
}

.telemetry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.telemetry strong {
  display: block;
  color: var(--cyan);
  font-size: 0.8rem;
}

.control-panel {
  position: absolute;
  z-index: 5;
  left: 22px;
  bottom: 22px;
  display: grid;
  grid-template-columns: 150px 165px 140px minmax(230px, 1fr);
  gap: 10px;
  width: min(740px, calc(100% - 44px));
  padding: 10px;
  border-radius: 8px;
}

.field-row {
  display: grid;
  gap: 5px;
}

.payout-preview {
  align-content: center;
  border: 1px solid rgba(83, 232, 255, 0.22);
  border-radius: 8px;
  background: rgba(0, 8, 18, 0.52);
  padding: 8px 10px;
}

.payout-preview strong {
  color: var(--gold);
  font-size: 1.12rem;
  line-height: 1;
}

.payout-preview small {
  color: var(--muted);
  font-size: 0.72rem;
}

label,
.panel-heading {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stepper,
.auto-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  overflow: hidden;
  border: 1px solid rgba(83, 232, 255, 0.3);
  border-radius: 8px;
  background: rgba(0, 8, 18, 0.66);
}

.auto-row {
  grid-template-columns: 86px minmax(0, 1fr);
}

.stepper button,
.quick-actions button,
.target-actions button,
.toggle,
.panel-heading button {
  border: 0;
  color: var(--cyan);
  background: rgba(83, 232, 255, 0.08);
  font-weight: 900;
}

.stepper input,
.auto-row input {
  width: 100%;
  border: 0;
  border-left: 1px solid rgba(83, 232, 255, 0.2);
  border-right: 1px solid rgba(83, 232, 255, 0.2);
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 8px;
  text-align: center;
  font-weight: 900;
}

.toggle {
  text-transform: uppercase;
}

.toggle.is-on {
  color: #001814;
  background: linear-gradient(180deg, #6fffe9, var(--teal));
}

.cta-row {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 12px;
}

.primary {
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  color: #031019;
  font-size: 1.25rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

.bet {
  background: linear-gradient(180deg, #ffe38a, var(--gold));
}

.cashout {
  background: linear-gradient(180deg, #7effff, var(--teal));
}

.quick-actions,
.target-actions {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
}

.quick-actions {
  grid-template-columns: repeat(6, 1fr);
}

.target-actions {
  grid-template-columns: 0.7fr repeat(4, 1fr);
  align-items: center;
}

.target-actions span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quick-actions button,
.target-actions button {
  min-height: 30px;
  border: 1px solid rgba(83, 232, 255, 0.25);
  border-radius: 7px;
  font-size: 0.86rem;
}

.quick-actions button:disabled,
.target-actions button:disabled {
  opacity: 0.45;
}

.quick-actions button.is-selected,
.target-actions button.is-selected,
.quick-actions button:active {
  border-color: rgba(246, 185, 59, 0.75);
  color: var(--gold);
  background: rgba(246, 185, 59, 0.13);
}

.countdown {
  position: absolute;
  z-index: 8;
  top: 48%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 124px;
  height: 124px;
  border: 1px solid rgba(83, 232, 255, 0.42);
  border-radius: 50%;
  background: rgba(1, 9, 20, 0.65);
  color: var(--cyan);
  font-size: 4.5rem;
  font-weight: 950;
  text-shadow: 0 0 24px rgba(83, 232, 255, 0.95);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.82);
  pointer-events: none;
}

.countdown.is-visible {
  animation: countdownBeat 760ms ease-out;
}

.history-panel {
  position: absolute;
  z-index: 4;
  top: 118px;
  left: 22px;
  width: min(280px, calc(100% - 44px));
  padding: 12px;
  border-radius: 8px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading button {
  border: 1px solid rgba(83, 232, 255, 0.24);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.68rem;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.history-chip {
  border: 1px solid rgba(83, 232, 255, 0.3);
  border-radius: 999px;
  background: rgba(4, 20, 38, 0.86);
  color: var(--cyan);
  padding: 6px 9px;
  font-size: 0.8rem;
  font-weight: 900;
}

.history-chip.hot {
  border-color: rgba(246, 185, 59, 0.6);
  color: var(--gold);
}

.history-chip.bust {
  border-color: rgba(255, 75, 95, 0.5);
  color: var(--red);
}

.prototype-notes {
  overflow: hidden;
  align-self: stretch;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.prototype-notes img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.prototype-notes div {
  padding: 16px;
}

.prototype-notes p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.game-stage.is-running .stage-bg {
  filter: saturate(1.08) contrast(1.04);
}

.game-stage.is-running .depth-track {
  opacity: 0.95;
}

.game-stage.is-running .engine-trail {
  opacity: 1;
  animation: trailPulse 420ms ease-in-out infinite alternate;
}

.game-stage.is-warning .multiplier-wrap strong,
.game-stage.is-warning #pressureHint {
  color: #ffe1a3;
  text-shadow: 0 0 26px rgba(246, 185, 59, 0.9);
}

.game-stage.is-warning .stage-bg {
  filter: saturate(1.18) contrast(1.08);
}

.game-stage.is-failed .submarine-layer {
  filter: saturate(1.2) hue-rotate(130deg);
  animation: failShake 480ms linear;
}

.game-stage.is-won .submarine-layer {
  filter: drop-shadow(0 0 28px rgba(246, 185, 59, 0.85));
  animation: winLift 900ms ease-out;
}

@keyframes sonar {
  0% {
    opacity: 0.55;
    transform: scale(0.3);
  }
  100% {
    opacity: 0;
    transform: scale(2.5);
  }
}

@keyframes lightSweep {
  from {
    transform: translate3d(-4%, -2%, 0) rotate(0deg);
  }
  to {
    transform: translate3d(5%, 3%, 0) rotate(4deg);
  }
}

@keyframes currentSlide {
  from {
    opacity: 0;
    transform: translateX(0) rotate(-18deg);
  }
  12%,
  78% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(175vw) rotate(-18deg);
  }
}

@keyframes bubbleRise {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.6);
  }
  10%,
  82% {
    opacity: 0.75;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), -110vh, 0) scale(1.35);
  }
}

@keyframes fxPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.85);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(1.12);
  }
}

@keyframes countdownBeat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  25%,
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.22);
  }
}

@keyframes trailPulse {
  from {
    transform: translateY(-50%) scaleX(0.82);
  }
  to {
    transform: translateY(-50%) scaleX(1.18);
  }
}

@keyframes failShake {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  20% {
    transform: translate(-53%, -50%) rotate(-5deg);
  }
  40% {
    transform: translate(-48%, -51%) rotate(4deg);
  }
  60% {
    transform: translate(-52%, -48%) rotate(-3deg);
  }
  80% {
    transform: translate(-49%, -52%) rotate(2deg);
  }
}

@keyframes winLift {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -57%) scale(1.08);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .prototype-notes {
    display: none;
  }

  .game-stage {
    min-height: calc(100vh - 36px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .game-stage {
    min-height: calc(100vh - 20px);
  }

  .topbar {
    padding: 14px;
  }

  .balance-card {
    min-width: 132px;
  }

  .history-panel {
    top: auto;
    bottom: 245px;
    left: 12px;
    width: calc(100% - 24px);
  }

  .control-panel {
    left: 12px;
    bottom: 12px;
    grid-template-columns: 1fr 1fr;
    width: calc(100% - 24px);
    padding: 12px;
  }

  .cta-row,
  .payout-preview,
  .quick-actions,
  .target-actions {
    grid-column: 1 / -1;
  }

  .depth-track {
    right: 12px;
    opacity: 0.75;
  }

  .submarine-layer {
    top: 46%;
    width: min(270px, 62vw);
  }

  .pressure-meter {
    right: 12px;
    bottom: 245px;
    width: 170px;
  }
}

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 2rem;
  }

  .balance-card strong {
    font-size: 1rem;
  }

  .multiplier-wrap {
    top: 22%;
  }

  .multiplier-wrap strong {
    font-size: 4.2rem;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .history-panel {
    bottom: 405px;
  }

  .pressure-meter {
    bottom: 352px;
    width: calc(100% - 24px);
  }
}
