/* =========================
   THEME VARIABLES
   ========================= */
:root {
  --color-bg: #060241;
  --color-contract-alt: #110e55;
  --color-gold: #ffd700;
  --color-card-border: #ffe97f;
  --color-accent-blue: #1f196e;
  --color-text-soft: #c0d6f9;
  --color-label-blue: #6b9cf8;
  --color-chart-bg2: #2e3e69e5;
  --color-light-blue: rgb(146, 146, 196);
  --color-white-text: rgb(255, 255, 255);

  --page-max-width: 1400px;
  --page-padding: 40px;
}

/* =========================
   GLOBAL
   ========================= */
body {
  /* background-color: #020118; */
  background-color: #040224;
  color: var(--color-gold);
  font-family: "Poppins", Arial, sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* helpers used in ui.js */
.green {
  color: #00ff00;
}
.red {
  color: #ff4444;
}

/* App hidden until JS shows it */
#app {
  display: none;
  min-height: 100vh;
}

/* =========================
   HEADER
   ========================= */
#siteHeader {
  position: fixed;
  top: 0;
  left: 0;
  height: 55px;
  width: 100%;
  background: rgba(2, 1, 24, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 0;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
  z-index: 500;
}

.header-inner {
  max-width: var(--page-max-width);
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0 var(--page-padding);
}

.site-logo {
  height: 40px;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  padding-right: 0;
  position: relative;
}

.account-balance-card {
  display: flex;
  align-items: stretch;
  white-space: nowrap;
  color: var(--color-white-text);
  background-color: var(--color-bg);
  border-radius: 8px;
  overflow: hidden;
}

.account-balance-value {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  padding: 8px 14px;
  display: flex;
  align-items: center;
}

.balance-wallet-icon {
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  opacity: 0.85;
}

.balance-add-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0;
  color: var(--color-white-text);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 14px;
  transition: background-color 0.15s;
}

.balance-add-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Profile icon */
.profile-icon-btn {
  background: none;
  border: none;
  color: var(--color-white-text);
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0 0 0 10px;
  opacity: 0.85;
  transition: opacity 0.15s;
  position: relative;
}

.profile-icon-btn:hover {
  opacity: 1;
}

/* Account dropdown menu */
.account-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: var(--color-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  min-width: 180px;
  overflow: hidden;
}

.account-menu.open {
  display: block;
}

.account-menu-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.account-menu-item {
  width: 100%;
  background: none;
  border: none;
  color: var(--color-white-text);
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  padding: 10px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color 0.12s;
}

.account-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.07);
}

.account-menu-logout {
  color: #f87171;
}

.account-menu-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 4px 0;
}

/* Add Funds Modal */
.add-funds-modal-content {
  background-color: #040224;
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 12px;
  color: var(--color-white-text);
}

.add-funds-modal-header {
  background-color: #040224;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.add-funds-modal-body {
  background-color: #040224;
}

.add-funds-modal-header .modal-title {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  color: #ffffff;
}

.add-funds-modal-footer {
  background-color: #040224;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  justify-content: center;
}

.add-funds-amounts {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.add-funds-amount-btn {
  background-color: var(--color-accent-blue);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  color: #ffffff;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.add-funds-amount-btn:hover {
  background-color: rgba(255, 215, 0, 0.15);
}

.add-funds-custom {
  display: flex;
  justify-content: center;
}

.add-funds-input {
  background-color: var(--color-accent-blue);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  color: var(--color-white-text);
  font-family: "Poppins", sans-serif;
  font-size: 15px;
  padding: 8px 14px;
  width: 100%;
  outline: none;
}

.add-funds-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.add-funds-confirm-btn {
  background-color: var(--color-gold);
  border: none;
  border-radius: 8px;
  color: #060241;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 32px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.add-funds-confirm-btn:hover {
  opacity: 0.85;
}

#btcPriceDisplay {
  display: flex;
  align-items: center;
  gap: 4px;
}

#btcPriceText {
  font-size: 28px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#btcPriceIcon {
  width: 36px;
  height: 36px;
  background-color: var(--color-bg);
  border-radius: 4px;
}

/* =========================
   MAIN LAYOUT
   ========================= */
#mainContainer {
  padding-top: 100px;
  padding-left: var(--page-padding);
  padding-right: var(--page-padding);
  max-width: var(--page-max-width);
  margin: 0 auto;
}

#leftColumn {
  gap: 8px;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

#rightColumn {
  display: flex;
  padding-left: 8px;
}

/* =========================
   BET CONTROLS
   ========================= */
.wager-section {
  color: var(--color-gold);
  margin-bottom: 0;
  min-height: unset;
}

.wager-label-top {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--color-label-blue);
  text-transform: uppercase;
}

.wager-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* keep buttons on one line (Bootstrap uses .d-flex here) */
.wager-row .d-flex {
  flex-wrap: nowrap !important;
  gap: 5px;
  justify-content: center;
}

.wager-coin {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1a1f8f, #06022d);
  color: var(--color-gold);
  border: 1px solid rgba(255, 215, 0, 0.4);
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  transition:
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.wager-coin:hover {
  cursor: pointer;
  border-color: rgba(255, 215, 0, 0.75);
  box-shadow:
    0 0 8px rgba(255, 215, 0, 0.4),
    0 0 20px rgba(255, 215, 0, 0.15);
  transform: scale(1.08);
}

.wager-coin.active {
  border: 2px solid #ffd700;
  font-weight: 800;
  background: radial-gradient(circle at 35% 35%, #2a2faa, #0a0650);
  box-shadow:
    0 0 0 3px rgba(255, 215, 0, 0.25),
    0 0 14px rgba(255, 215, 0, 0.55),
    inset 0 0 8px rgba(255, 255, 255, 0.15);
}

/* =========================
   CHART HINT + EXPIRY
   ========================= */
#betControlsRow {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

#betControlsRow .panel {
  flex: 0 0 150px;
  width: 150px;
  padding: 8px 10px 6px;
  justify-content: flex-start;
  background-color: var(--color-bg);
}

#expiryPanel {
  text-align: center;
}

#expiryPanel .expiry-label {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-label-blue);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#expiryCountdown {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-gold);
  line-height: 1.1;
}

#chartHint {
  flex: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background-color: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.hint-main {
  display: block;
  font-family: "Baloo 2", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-gold);
  text-shadow: none;
}

.hint-sub {
  display: block;
  font-family: "Poppins", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--color-label-blue);
}

#chartBtcPrice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
}

.chart-btc-icon {
  width: 18px;
  height: 18px;
}

#chartBtcPriceText {
  font-family: "Poppins", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-white-text);
}

#chartBtcPriceText.green { color: #4caf50; }
#chartBtcPriceText.red   { color: #f44336; }

/* =========================
   CHART AREA
   ========================= */
#chartContainer {
  height: 70vh;
  width: 100%;
  touch-action: none;
  position: relative;
}

#chartWindowLabel {
  position: absolute;
  bottom: 22px;
  left: 10px;
  color: #8b1a1a;
  font-size: 10px;
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
}

#bitcoinChart {
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

/* =========================
   CONTRACTS PANEL
   ========================= */
#contractsSection {
  flex: 1;
  background-color: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  padding: 12px;
  overflow: hidden;
}

#contractsSection .tab-content {
  max-height: none;
  overflow: hidden;
}

#contractsSection .contracts-toprow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--color-bg);
}

#contractsSection .contracts-tab {
  color: #ffffff;
  text-align: center;
  padding: 4px 0;
  font-weight: 600;
  user-select: none;
  position: relative;
  cursor: pointer;
}

#contractsSection .contracts-tab:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

#contractsSection .contracts-tab.is-active::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 0;
  height: 2px;
  background-color: var(--color-gold);
}

/* =========================
   CONTRACT TABLES
   ========================= */
#contractsSection table.table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

#contractsSection table.table thead th {
  padding: 10px 6px;
  text-align: center;
  background-color: var(--color-bg);
  color: var(--color-label-blue);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 2px solid #b7c5d3;
}

#contractsSection table.table tbody tr:nth-child(odd) td {
  background-color: var(--color-bg);
}

#contractsSection table.table tbody tr:nth-child(even) td {
  background-color: var(--color-contract-alt);
}

#contractsSection #historyContractTable td,
#contractsSection #publicContractTable td {
  background-color: transparent !important;
}

#contractsSection table.table tbody td {
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
  color: var(--color-gold);
  font-size: 12px;
  border: none;
}

#historyContractTable td,
#historyContractTable th,
#publicContractTable td,
#publicContractTable th {
  white-space: nowrap;
}

#contractsSection #publicContractTable td:first-child,
#contractsSection #publicContractTable th:first-child {
  text-align: left;
  width: 80px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

#contractsSection #historyContractTable tbody td,
#contractsSection #publicContractTable tbody td {
  color: var(--color-white-text);
  background-color: transparent;
}

/* =========================
   CONTRACT ROW ANIMATIONS
   ========================= */
#contractTableBody tr.contract-row {
  position: relative;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
}

#contractTableBody tr.contract-row.contract-row-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes contractRowTextFlash {
  0%,
  100% {
    filter: none;
    text-shadow: none;
  }
  50% {
    filter: brightness(2);
    text-shadow: 0 0 8px #ffffff;
  }
}

.contract-row-flash-text td {
  animation: contractRowTextFlash 0.3s ease-in-out 4;
}

/* =========================
   SPLASH SCREEN
   ========================= */
#splashScreen {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: Arial, sans-serif;
}

.loader {
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  border: 6px solid #333;
  border-top-color: #fefe00;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loadingText {
  font-size: 18px;
  opacity: 0.7;
}

/* =========================
   BET MESSAGE
   ========================= */
.demo-header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.demo-header-btn {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.15s;
}
.demo-header-login {
  color: #e6eaf0;
  border: 1px solid rgba(255,255,255,0.2);
}
.demo-header-login:hover { color: #ecd551; border-color: rgba(236,213,81,0.4); }
.demo-header-register {
  background: #ecd551;
  color: #1a1600;
  border: 1px solid transparent;
}
.demo-header-register:hover { filter: brightness(1.1); }

#demoBanner {
  background: rgba(236, 213, 81, 0.1);
  border-bottom: 1px solid rgba(236, 213, 81, 0.3);
  color: #ecd551;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
}
.demo-banner-login {
  color: #ecd551;
  font-weight: 700;
  text-decoration: underline;
}
.demo-banner-login:hover {
  color: #fff;
}

.bet-message {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.msg-error {
  background: #ff4d4d;
  color: white;
}
.msg-success {
  background: #12b468;
  color: white;
}
.msg-info {
  background: #4d7edf;
  color: white;
}

/* =========================
   FOOTER
   ========================= */
#logoutFooter {
  width: 100%;
  padding: 10px 0;
  text-align: center;
}

#logoutBtn {
  background: none;
  border: none;
  color: #9aa4b2;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

#logoutBtn:hover {
  color: #ffffff;
}

/* =========================
   RESPONSIVE: DESKTOP ONLY
   ========================= */
@media (min-width: 993px) {
  #chartBtcPriceText {
    font-size: 28px;
  }

  .chart-btc-icon {
    width: 26px;
    height: 26px;
  }

  #contractsSection {
    padding-top: 0;
  }

  #contractsSection .contracts-tab {
    padding: 7px 0 0;
  }

  #contractsSection table.table thead th {
    padding: 6px 6px;
  }
}

/* =========================
   RESPONSIVE: LANDSCAPE MID
   ========================= */
@media (max-width: 992px) and (orientation: landscape) {
  #leftColumn {
    width: 66.6667%;
  }
  #rightColumn {
    width: 33.3333%;
  }

  .wager-coin {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  #expiryPanel .expiry-label {
    margin-top: 2px;
  }

  .hint-main {
    font-size: 17px;
    letter-spacing: 1px;
  }

  .hint-sub {
    font-size: 11px;
  }

  #contractsSection {
    width: 100%;
  }

  #contractsSection .contracts-tab {
    padding: 7px 0 1px;
  }

  #contractsSection table.table thead th {
    padding: 3px 6px;
  }

  #contractsSection .contracts-tab {
    padding: 7px 0 0;
  }

  #contractsSection .tab-content {
    max-height: none;
  }

  #siteHeader {
    height: 80px;
  }

  #mainContainer {
    padding-top: 90px;
  }

  #chartContainer {
    height: 60vh;
  }
}

/* =========================
   RESPONSIVE: SMALL SCREENS
   ========================= */
@media (max-width: 480px) {
  #siteHeader {
    height: 55px;
  }

  .header-inner {
    max-width: 100%;
    padding: 0;
    justify-content: space-between;
  }

  .header-right {
    width: 100%;
    gap: 4px;
  }

  .profile-icon-btn {
    padding-left: 0;
    margin-right: 6px;
  }

  .account-balance-card {
    margin-left: auto;
  }

  .site-logo {
    height: 30px;
  }

  .account-balance-card {
    padding: 5px 10px;
  }

  .account-balance-value {
    font-size: 15px;
  }

  #btcPriceText {
    font-size: 16px;
  }

  #btcPriceIcon {
    width: 22px;
    height: 22px;
  }

  #mainContentRow {
    display: block;
    padding: 0;
    margin: 0;
    flex-direction: column;
  }

  #mainContainer {
    padding-left: 2px;
    padding-right: 2px;
    padding-top: 62px;
  }

  #leftChartColumn {
    width: 100%;
    padding: 0;
    margin: 0;
    background-color: var(--color-bg);
  }

  #rightColumn {
    padding-left: 0;
  }

  #contractsSection {
    height: auto;
    overflow: hidden;
    margin-bottom: 80px;
  }

  #contractsSection .tab-content {
    max-height: none;
  }

  #chartContainer {
    width: 100%;
    height: 50vh;
    margin: 0 0 6px 0;
    box-sizing: border-box;
  }

  #bitcoinChart {
    width: 100%;
    height: auto;
  }

  .wager-coin {
    width: 30px;
    height: 30px;
  }

  #betControlsRow .panel {
    flex: 0 0 110px;
    width: 110px;
    padding-top: 4px;
  }

  #chartHint {
    padding-bottom: 8px;
  }

  #chartBtcPriceText {
    font-size: 24px;
  }

  .chart-btc-icon {
    width: 22px;
    height: 22px;
  }

  #expiryPanel .expiry-label {
    margin-top: 0;
  }

  .hint-main {
    font-size: 16px;
    letter-spacing: 1px;
  }

  .hint-sub {
    font-size: 13px;
    letter-spacing: 0.5px;
  }

  #contractsSection .contracts-tab {
    padding: 7px 0 1px;
  }

  #contractsSection table.table thead th {
    padding: 7px 6px;
  }
}
