:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --accent: #38bdf8;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e293b, var(--bg));
  color: var(--text);
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
}

.app {
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  margin: 0;
  position: relative;
}

.hud-stats-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0;
  border: 0;
  background: #0b1220;
  box-shadow: none;
}

.game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.build-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 0.36rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgb(251 191 36 / 55%);
  background: rgb(2 6 23 / 76%);
  color: #fde68a;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(2px);
  box-shadow: 0 0 16px rgb(251 191 36 / 30%);
  pointer-events: none;
}

.minimap-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(220px, 40vw);
  padding: 0.5rem 0.58rem 0.58rem;
  border-radius: 10px;
  border: 1px solid rgb(148 163 184 / 30%);
  background: rgb(15 23 42 / 55%);
  backdrop-filter: blur(2px);
  z-index: 2;
  pointer-events: none;
}

.minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
}

.minimap-overlay h2 {
  margin: 0;
  font-size: 0.8rem;
  color: #cbd5e1;
  letter-spacing: 0.04em;
}

.minimap-room-timer {
  flex: 0 0 auto;
  padding: 0.14rem 0.38rem;
  border-radius: 999px;
  background: rgb(15 23 42 / 78%);
  color: #fef08a;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.15;
}

#minimapCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid rgb(148 163 184 / 32%);
  background: rgb(2 6 23 / 80%);
}

.mini-leaders {
  margin: 0.45rem 0 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  font-size: 0.74rem;
}

.mini-leaders li {
  color: #dbeafe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-leaders li.gold {
  color: #facc15;
  font-weight: 700;
}

.mini-leaders li.silver {
  color: #cbd5e1;
}

.mini-leaders li.bronze {
  color: #fdba74;
}

.back-hold-ui {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(430px, 78vw);
  padding: 0.5rem 0.6rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgb(148 163 184 / 28%);
  background: rgb(15 23 42 / 62%);
  backdrop-filter: blur(2px);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.merge-ui {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 220px;
  max-width: 38vw;
  padding: 0.5rem 0.6rem 0.58rem;
  border-radius: 10px;
  border: 1px solid rgb(148 163 184 / 28%);
  background: rgb(15 23 42 / 62%);
  backdrop-filter: blur(2px);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.merge-ui.visible {
  opacity: 1;
}

.cashout-feed {
  position: absolute;
  top: 280px;
  left: 12px;
  width: min(320px, 34vw);
  max-height: min(38vh, 300px);
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.cashout-feed-list {
  display: none;
}

.cashout-feed-list:not(:empty) {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  max-height: min(34vh, 260px);
  overflow: hidden;
}

.cashout-feed-item {
  width: fit-content;
  max-width: 100%;
  align-self: flex-start;
  padding: 0.32rem 0.42rem;
  border-radius: 7px;
  border: 1px solid rgb(87 193 255 / 24%);
  background: rgb(17 28 35 / 78%);
  color: #ffd37b;
  font-size: 0.75rem;
  line-height: 1.2;
  animation: cashout-fade-in 140ms ease-out;
}

.cashout-popup {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: min(420px, 78vw);
  padding: 0.85rem 0.95rem 0.95rem;
  border-radius: 10px;
  border: 1px solid rgb(148 163 184 / 35%);
  background: rgb(15 23 42 / 84%);
  backdrop-filter: blur(3px);
  text-align: center;
}

.cashout-popup.hidden {
  display: none;
}

.cashout-popup-text {
  margin: 0 0 0.7rem;
  color: #fef08a;
  font-size: 1.08rem;
  font-weight: 700;
}

.cashout-popup-btn {
  border: 1px solid rgb(34 197 94 / 70%);
  background: rgb(22 163 74 / 88%);
  color: #ecfdf5;
  font-weight: 700;
  font-size: 0.96rem;
  border-radius: 7px;
  padding: 0.44rem 1rem;
  cursor: pointer;
}

.cashout-popup-btn:hover {
  background: rgb(21 128 61 / 90%);
}

.cashout-confetti-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 140ms ease;
}

.cashout-confetti-layer.active {
  opacity: 1;
}

.cashout-confetti-piece {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 2px;
  opacity: 0;
  will-change: transform, opacity;
  animation-name: cashout-confetti-cannon;
  animation-timing-function: cubic-bezier(0.22, 0.68, 0.28, 0.98);
  animation-fill-mode: forwards;
}

@keyframes cashout-fade-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cashout-confetti-cannon {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.88);
  }
  8% {
    opacity: 1;
  }
  40% {
    opacity: 1;
    transform: translate3d(var(--peak-x), var(--peak-y), 0) rotate(var(--spin-a)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--end-x), var(--end-y), 0) rotate(var(--spin-b)) scale(1);
  }
}

.merge-title {
  margin-bottom: 0.4rem;
  color: #dbeafe;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.merge-rows {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  max-height: min(40vh, 280px);
  overflow-y: auto;
}

.merge-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.merge-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(15 23 42 / 78%);
  border: 1px solid rgb(148 163 184 / 30%);
}

.merge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b 0%, #facc15 100%);
  box-shadow: 0 0 10px rgb(245 158 11 / 42%);
  transition: width 80ms linear;
}

.merge-text {
  min-width: 38px;
  color: #fde68a;
  font-size: 0.74rem;
  text-align: right;
}

.back-hold-ui.visible {
  opacity: 1;
}

.back-hold-ui.active {
  border-color: rgb(14 165 233 / 65%);
}

.back-hold-header {
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #dbeafe;
}

.back-hold-track {
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(15 23 42 / 75%);
  border: 1px solid rgb(148 163 184 / 28%);
}

.back-hold-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8 0%, #22d3ee 100%);
  box-shadow: 0 0 12px rgb(56 189 248 / 45%);
  transition: width 45ms linear;
}

.menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: rgb(2 6 23 / 68%);
  backdrop-filter: blur(2px);
  border-radius: 0;
}

.menu h2 {
  margin: 0;
  font-size: 1.6rem;
}

.menu label {
  font-size: 0.9rem;
  color: #cbd5e1;
}

#bankrollLabel {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fef08a;
}

.menu-note {
  margin: 0;
  width: min(420px, 82%);
  text-align: center;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.menu input {
  width: min(320px, 75%);
  padding: 0.65rem 0.8rem;
  border: 1px solid #475569;
  border-radius: 9px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 1rem;
}

.menu button {
  padding: 0.65rem 1.4rem;
  border: 0;
  border-radius: 9px;
  background: #0ea5e9;
  color: #0b1220;
  font-weight: 700;
  cursor: pointer;
}

.menu button:hover {
  background: #38bdf8;
}

.menu button:disabled {
  background: #334155;
  color: #94a3b8;
  cursor: not-allowed;
}

.menu-link {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.86rem;
  border-bottom: 1px dashed rgb(147 197 253 / 55%);
  padding-bottom: 1px;
}

.menu-link:hover {
  color: #bfdbfe;
}

.menu.hidden {
  display: none;
}
