:root {
  --bg-main: #141a33; --bg-nav: #465594; --bg-chat: #1a2242;
  --bg-card: #1f284a; --accent-blue: #788ef5; --accent-gold: #f5b041;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: radial-gradient(circle at 60% 20%, #232e5c 0%, #131830 65%); color: #fff; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
header { height: 62px; background: linear-gradient(90deg, #4a5a9e, #3d4b87); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; box-shadow: 0 4px 16px rgba(0,0,0,0.35); z-index: 20; }
.nav-left, .nav-links, .nav-right { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 1.45rem; font-weight: 900; display: flex; align-items: center; gap: 8px; letter-spacing: 0.5px; }
.logo-box { background: #fff; color: #3d4b87; padding: 2px 7px; border-radius: 5px; box-shadow: 0 2px 8px rgba(255,255,255,0.25); }
.logo span { color: #a5b4fc; font-style: italic; font-size: 1.05rem; }
.nav-btn { background: rgba(255,255,255,0.14); color: #fff; border: 1px solid rgba(255,255,255,0.12); padding: 8px 14px; border-radius: 7px; font-weight: 700; font-size: 0.8rem; cursor: pointer; }
.nav-btn:hover { background: rgba(255,255,255,0.24); }
.btn-free { background: #6b8afd; color: #fff; border: none; padding: 8px 13px; border-radius: 7px; font-weight: 800; font-size: 0.8rem; cursor: pointer; }
.btn-sfx { background: #c94a4a; color: #fff; border: none; padding: 8px 13px; border-radius: 7px; font-weight: 800; font-size: 0.8rem; cursor: pointer; }
.wallet-box { background: #141a33; padding: 7px 14px; border-radius: 7px; font-weight: 800; border: 1px solid #35447a; display: flex; align-items: center; gap: 6px; }
.workspace { display: flex; flex: 1; overflow: hidden; }
.chat-sidebar { width: 265px; background: #192140; border-right: 1px solid #283463; display: flex; flex-direction: column; }
.chat-header { padding: 12px 14px; background: #1f294f; display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; font-weight: 800; border-bottom: 1px solid #2b386b; }
.rain-pill { background: #131933; padding: 4px 10px; border-radius: 20px; border: 1px solid #364785; color: #f5b041; cursor: pointer; }
.chat-messages { flex: 1; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; font-size: 0.8rem; }
.chat-row { display: flex; gap: 9px; align-items: flex-start; }
.avatar-wrap { position: relative; width: 32px; height: 32px; border-radius: 7px; background: linear-gradient(135deg, #f59e0b, #d97706); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.lvl-tag { position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); background: #4f6ef7; color: #fff; font-size: 0.6rem; font-weight: 900; padding: 0 5px; border-radius: 4px; }
.msg-bubble { background: #222d54; padding: 7px 10px; border-radius: 8px; flex: 1; line-height: 1.3; }
.msg-name { font-weight: 800; font-size: 0.75rem; color: #cbd5e1; margin-bottom: 2px; }
.sys-note { color: #8a99c7; font-size: 0.74rem; padding: 4px 6px; line-height: 1.35; }
.chat-input-area { padding: 10px; background: #141a33; border-top: 1px solid #263261; }
.chat-input-box { display: flex; gap: 6px; background: #1f284a; padding: 4px; border-radius: 7px; border: 1px solid #324178; }
.chat-input-box input { flex: 1; background: transparent; border: none; color: #fff; padding: 6px 8px; outline: none; font-size: 0.8rem; }
.chat-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 0.72rem; color: #8a99c7; font-weight: 700; }
.lobby { flex: 1; overflow-y: auto; padding: 24px 28px; position: relative; }
.hero-space { position: relative; text-align: center; padding: 38px 20px 44px; margin-bottom: 22px; border-radius: 16px; background: radial-gradient(circle at 72% 45%, rgba(99,102,241,0.18) 0%, transparent 55%), linear-gradient(180deg, rgba(30,39,77,0.5) 0%, rgba(20,26,51,0.2) 100%); border: 1px solid rgba(107,138,253,0.18); overflow: hidden; }
.planet-bg { position: absolute; right: 16%; top: 18%; width: 130px; height: 130px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #4b5ea8, #1d264d); opacity: 0.55; pointer-events: none; }
.asteroid-left { position: absolute; left: 8%; bottom: 14%; font-size: 3.6rem; opacity: 0.85; filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5)); pointer-events: none; }
.crystal-right { position: absolute; right: 5%; top: 20%; font-size: 3.4rem; opacity: 0.85; transform: rotate(-15deg); pointer-events: none; }
.hero-space h1 { position: relative; font-size: 1.55rem; font-weight: 900; letter-spacing: 0.6px; text-transform: uppercase; text-shadow: 0 3px 12px rgba(0,0,0,0.5); margin-bottom: 18px; }
.hero-cta { position: relative; background: linear-gradient(180deg, #8ba2ff, #6b84f5); color: #fff; border: none; padding: 11px 36px; border-radius: 8px; font-weight: 800; font-size: 0.9rem; cursor: pointer; box-shadow: 0 5px 18px rgba(107,132,245,0.4); }
.section-title { text-align: center; font-weight: 900; letter-spacing: 2px; font-size: 0.95rem; margin-bottom: 20px; color: #e2e8f0; }
.section-title span { color: var(--accent-gold); }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 16px; max-width: 1120px; margin: 0 auto; }
.game-card { background: radial-gradient(circle at 50% 38%, #2c3a6e 0%, #1a2242 75%); border: 1px solid #303f78; border-radius: 14px; padding: 20px 12px 16px; text-align: center; cursor: pointer; transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s; box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
.game-card:hover { transform: translateY(-5px); border-color: #788ef5; box-shadow: 0 10px 24px rgba(120,142,245,0.28); }
.card-art { height: 95px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.game-title { font-weight: 900; font-size: 0.95rem; letter-spacing: 0.6px; color: #fff; }
.game-sub { font-size: 0.66rem; color: #8a99c7; font-weight: 800; letter-spacing: 1px; margin-top: 3px; }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(10,14,28,0.85); justify-content: center; align-items: center; z-index: 50; }
.modal-box { background: var(--bg-card); border: 1px solid #3c4f91; border-radius: 12px; width: 92%; max-width: 420px; padding: 20px; text-align: center; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.close-btn { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }
.mines-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 12px auto; max-width: 280px; }
.mine-tile { aspect-ratio: 1; background: #2c396b; border: none; border-bottom: 4px solid #1b2447; border-radius: 8px; font-size: 1.4rem; cursor: pointer; transform-style: preserve-3d; transition: transform 0.35s, background 0.2s; }
.mine-tile.flipped { transform: rotateY(180deg); }
.mine-tile span { display: inline-block; transform: rotateY(180deg); }
.mine-tile.safe { background: #16382b; border-bottom-color: #00e676; }
.mine-tile.bomb { background: #4a1c24; border-bottom-color: #ff5252; }
.mines-controls, .bet-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
input, select { background: #13182e; color: #fff; border: 1px solid #3c4f91; padding: 8px; border-radius: 6px; width: 85px; font-weight: bold; }
.btn-cashout { background: #00e676; color: #000; border: none; padding: 10px 16px; border-radius: 8px; font-weight: 900; cursor: pointer; }
.game-display { background: #13182e; border-radius: 8px; padding: 20px; margin: 12px 0; font-size: 2rem; font-weight: 900; }
.bj-card-anim { animation: cardDeal 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1) backwards; }
@keyframes cardDeal { 0% { opacity: 0; transform: translateY(-28px) scale(0.75) rotateY(90deg); } 100% { opacity: 1; transform: translateY(0) scale(1) rotateY(0deg); } }
@media (max-width: 768px) { .chat-sidebar, .nav-links { display: none; } }
.dropdown-wrap { position: relative; display: inline-block; }
.games-dropdown {
  display: none; position: absolute; top: 44px; left: 0; width: 320px;
  background: #1b2447; border: 1px solid #3c4f91; border-radius: 12px;
  padding: 12px; box-shadow: 0 12px 30px rgba(0,0,0,0.6); z-index: 100;
  grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.games-dropdown.show { display: grid; }
.dd-header { grid-column: span 2; font-size: 0.72rem; font-weight: 900; color: #f5b041; letter-spacing: 1px; padding-bottom: 4px; border-bottom: 1px solid #2b386b; }
.dd-item {
  background: #232e59; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 800; font-size: 0.8rem; cursor: pointer; text-align: left;
}
.dd-item:hover { border-color: #6b8afd; background: #2c3a6e; }
.btn-sfx { background: #00b894 !important; color: #000 !important; transition: background 0.2s; }
.btn-sfx.muted { background: #c94a4a !important; color: #fff !important; }
.games-dropdown {
  display: grid !important;
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.games-dropdown.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.modal-overlay {
  position: static !important;
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent !important;
  overflow-y: auto;
  padding: 24px 16px;
  align-items: flex-start !important;
}
.modal-box {
  max-width: 780px !important;
  width: 100% !important;
  margin: 0 auto;
  background: linear-gradient(180deg, #1f284a 0%, #171e38 100%);
  border: 1px solid #324178;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.close-btn {
  background: #2b386b !important;
  padding: 6px 14px !important;
  border-radius: 7px !important;
  font-size: 0.8rem !important;
  font-weight: 800 !important;
}
.close-btn:hover { background: #3c4f91 !important; }
body, .workspace {
  height: auto !important;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto !important;
}
.modal-overlay {
  padding: 12px 10px 40px !important;
}
.modal-box {
  padding: 14px !important;
}
.mines-grid {
  max-width: 245px !important;
  gap: 6px !important;
  margin: 10px auto !important;
}
.mine-tile {
  font-size: 1.2rem !important;
  border-bottom-width: 3px !important;
}
.workspace {
  display: block !important;
  width: 100%;
}
.modal-overlay {
  display: none;
  width: 100%;
  margin-top: 0 !important;
  padding-top: 12px !important;
}
.dropdown-wrap { position: relative; display: inline-block; }
.games-dropdown {
  display: none; position: absolute; top: 44px; left: 0; width: 320px;
  background: #1b2447; border: 1px solid #3c4f91; border-radius: 12px;
  padding: 12px; box-shadow: 0 12px 30px rgba(0,0,0,0.6); z-index: 100;
  grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.games-dropdown.show { display: grid; }
.dd-header { grid-column: span 2; font-size: 0.72rem; font-weight: 900; color: #f5b041; letter-spacing: 1px; padding-bottom: 4px; border-bottom: 1px solid #2b386b; }
.dd-item {
  background: #232e59; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 800; font-size: 0.8rem; cursor: pointer; text-align: left;
}
.dd-item:hover { border-color: #6b8afd; background: #2c3a6e; }
.games-dropdown { display: grid !important; opacity: 0; pointer-events: none; }
.games-dropdown.show { opacity: 1; pointer-events: auto; }
.workspace { display: block !important; width: 100%; }
.modal-overlay { display: none; width: 100%; margin-top: 0 !important; padding-top: 12px !important; }
.modal-overlay {
  position: static !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 12px 10px 30px !important;
  margin: 0 !important;
}
.modal-box {
  display: block !important;
  width: 100% !important;
  max-width: 540px !important;
  margin: 0 auto !important;
}
#crashModal .modal-box > div:nth-child(3) {
  width: 100% !important;
  min-height: 220px !important;
  display: block !important;
}
#crashCanvas {
  width: 100% !important;
  height: 220px !important;
}
.modal-overlay { display: none; }
.modal-overlay.active-page { display: block !important; }

/* === CLEAN LAYOUT & CRASH ROCKET FIX === */
body {
  display: block !important;
  height: auto !important;
  min-height: 100vh;
  overflow-y: auto !important;
}
.workspace {
  display: block !important;
  width: 100%;
  min-height: 0 !important;
}
.modal-overlay {
  display: none !important;
  position: static !important;
  width: 100% !important;
  padding: 16px 12px 40px !important;
  background: transparent !important;
}
.modal-overlay.active-page {
  display: block !important;
}
.modal-overlay { display: none !important; position: static !important; }
.modal-overlay.active-page { display: block !important; }
