/* Trade Casino - Main Game Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0b1a0a;
  --bg-secondary: #122414;
  --navy: #0f2210;
  --gold: #8dc63f;
  --ep-green: #8dc63f;
  --ep-green-dark: #6faa28;
  --green: #8dc63f;
  --green-dark: #6faa28;
  --red: #ff4d4d;
  --red-dark: #e53935;
  --blue-glow: #8dc63f;
  --text: #f0f7ea;
  --text-muted: #a3b894;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
}

.game-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.game-app.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, var(--navy) 0%, var(--bg) 100%);
  border-bottom: 1px solid rgba(141, 198, 63, 0.18);
  flex-shrink: 0;
  z-index: 100;
}

.header-left, .header-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-right {
  justify-content: flex-end;
  gap: 0.75rem;
}

.header-center {
  flex: 1.5;
  text-align: center;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.game-logo svg {
  filter: drop-shadow(0 0 6px rgba(141, 198, 63, 0.4));
}

.header-brand-img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(141, 198, 63, 0.35);
  box-shadow: 0 0 12px rgba(141, 198, 63, 0.2);
}

.header-brand-mark {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(141, 198, 63, 0.35);
  box-shadow: 0 0 12px rgba(141, 198, 63, 0.2);
  background: #e8f5e1;
}

.platform-name {
  font-family: 'Sora', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
}

.platform-name span {
  color: var(--gold);
}

.balance-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.balance-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.balance-value {
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  transition: transform 0.3s ease, color 0.3s ease;
}

.balance-value.balance-up {
  color: var(--green);
  animation: balancePop 0.6s ease;
}

.balance-value.balance-down {
  color: var(--red);
  animation: balanceShake 0.5s ease;
}

@keyframes balancePop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes balanceShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.sound-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sound-btn:active {
  transform: scale(0.92);
}

.sound-btn .icon-sound-off { display: none; }
.sound-btn.muted .icon-sound-on { display: none; }
.sound-btn.muted .icon-sound-off { display: block; color: var(--red); }

/* Chart Section */
.chart-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.5rem 0.75rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.25rem;
  margin-bottom: 0.25rem;
}

.asset-name {
  font-family: 'Sora', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.asset-type {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.live-price {
  font-family: 'Sora', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.price-change {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
}

.price-change.up { color: var(--green); }
.price-change.down { color: var(--red); }

/* Chart Style Picker */
.chart-style-bar {
  margin-bottom: 0.35rem;
  overflow: hidden;
}

.chart-style-picker {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.15rem 0.25rem 0.35rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chart-style-picker::-webkit-scrollbar { display: none; }

.style-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.style-btn:active {
  transform: scale(0.95);
}

.style-btn.active {
  border-color: var(--blue-glow);
  background: rgba(141, 198, 63, 0.18);
  color: var(--blue-glow);
  box-shadow: 0 0 12px rgba(141, 198, 63, 0.25);
}

.style-btn .style-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.chart-wrapper.style-switch {
  animation: chartStyleSwitch 0.4s ease;
}

@keyframes chartStyleSwitch {
  0% { opacity: 0.6; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1); }
}

.chart-wrapper {
  position: relative;
  flex: 1;
  min-height: 200px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(10, 14, 23, 0.95) 100%);
  border: 1px solid rgba(141, 198, 63, 0.2);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.chart-wrapper.crash-shake {
  animation: crashShake 0.5s ease;
}

@keyframes crashShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.chart-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(141, 198, 63, 0.05);
  transition: box-shadow 0.3s ease;
}

.chart-glow.pulse-active {
  box-shadow: inset 0 0 60px rgba(141, 198, 63, 0.2);
  animation: chartPulse 0.6s ease;
}

@keyframes chartPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.chart-wrapper canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Position Panel (Live P/L) */
.position-panel {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  z-index: 12;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.position-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.position-card {
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(141, 198, 63, 0.25);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.position-card.profit {
  border-color: rgba(0, 230, 118, 0.35);
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.1);
}

.position-card.loss {
  border-color: rgba(255, 23, 68, 0.35);
  box-shadow: 0 0 20px rgba(255, 23, 68, 0.1);
}

.position-card.near-liq {
  border-color: rgba(255, 23, 68, 0.6);
  animation: liqWarning 1s ease infinite;
}

@keyframes liqWarning {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 23, 68, 0.2); }
  50% { box-shadow: 0 0 24px rgba(255, 23, 68, 0.45); }
}

.position-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.position-type {
  font-family: 'Sora', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.position-type.buy { color: var(--green); }
.position-type.sell { color: var(--red); }

.position-leverage {
  font-size: 0.65rem;
  color: var(--gold);
  background: rgba(141, 198, 63, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.position-prices {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.price-col {
  text-align: center;
}

.price-label {
  display: block;
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.price-val {
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
}

.price-val.live {
  color: var(--gold);
}

.price-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.position-pnl {
  text-align: center;
  padding: 0.4rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

.position-pnl.up {
  background: rgba(0, 230, 118, 0.1);
}

.position-pnl.down {
  background: rgba(255, 23, 68, 0.1);
}

.pnl-label {
  display: block;
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pnl-value {
  font-family: 'Sora', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
}

.position-pnl.up .pnl-value { color: var(--green); }
.position-pnl.down .pnl-value { color: var(--red); }

.pnl-pct {
  font-size: 0.7rem;
  margin-left: 0.35rem;
  opacity: 0.8;
}

.position-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Trading Panel */
.trade-panel {
  flex-shrink: 0;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: linear-gradient(0deg, var(--navy) 0%, var(--bg-secondary) 100%);
  border-top: 1px solid rgba(141, 198, 63, 0.18);
  transition: opacity 0.3s ease;
}

.trade-panel.has-position .investment-section {
  opacity: 0.5;
}

.section-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 0.5rem;
}

.quick-amounts {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.quick-amounts::-webkit-scrollbar { display: none; }

.quick-btn {
  flex-shrink: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-btn:active {
  transform: scale(0.95);
}

.quick-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(141, 198, 63, 0.1);
  box-shadow: 0 0 12px rgba(141, 198, 63, 0.2);
}

.custom-input-wrap {
  display: flex;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.input-prefix {
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(141, 198, 63, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.investment-input {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
}

.investment-input::-webkit-outer-spin-button,
.investment-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.trade-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.trade-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.trade-btn:active {
  transform: scale(0.96);
}

.btn-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.trade-btn:active .btn-glow {
  opacity: 1;
}

.buy-btn {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  color: #0a0e17;
  box-shadow: 0 4px 20px rgba(0, 230, 118, 0.3);
}

.buy-btn .btn-glow {
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
}

.buy-btn:active {
  box-shadow: 0 2px 30px rgba(0, 230, 118, 0.6);
}

.sell-btn {
  background: linear-gradient(135deg, var(--red-dark) 0%, var(--red) 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 23, 68, 0.3);
}

.sell-btn .btn-glow {
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
}

.sell-btn:active {
  box-shadow: 0 2px 30px rgba(255, 23, 68, 0.6);
}

.btn-icon {
  font-size: 0.9rem;
}

.close-position-btn {
  display: none;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.75rem;
  border: 1px solid rgba(141, 198, 63, 0.4);
  border-radius: 10px;
  background: rgba(141, 198, 63, 0.12);
  color: var(--gold);
  font-family: 'Sora', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.close-position-btn.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.close-position-btn:active {
  transform: scale(0.97);
  background: rgba(141, 198, 63, 0.2);
}

.trade-btn.close-mode {
  animation: pulseClose 1.5s ease infinite;
}

@keyframes pulseClose {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 23, 68, 0.3); }
  50% { box-shadow: 0 4px 30px rgba(255, 23, 68, 0.6); }
}

.trade-btn.buy-btn.close-mode {
  animation-name: pulseCloseBuy;
}

@keyframes pulseCloseBuy {
  0%, 100% { box-shadow: 0 4px 20px rgba(0, 230, 118, 0.3); }
  50% { box-shadow: 0 4px 30px rgba(0, 230, 118, 0.6); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.trade-hint {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.58rem;
  color: #475569;
  letter-spacing: 0.3px;
}

.trade-panel.has-position .trade-hint {
  color: var(--gold);
}

/* Footer */
.game-footer {
  padding: 0.4rem 1rem;
  text-align: center;
  background: var(--bg);
}

.game-footer p {
  font-size: 0.55rem;
  color: #475569;
  letter-spacing: 0.5px;
}

/* Effects */
.effects-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.effects-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floating-number {
  position: fixed;
  font-family: 'Sora', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  pointer-events: none;
  animation: floatUp 2s ease-out forwards;
  z-index: 1001;
  text-shadow: 0 0 10px currentColor;
}

.floating-number.win { color: var(--green); }
.floating-number.loss { color: var(--red); }

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.2); }
}

.trade-result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeInOut 2.5s ease forwards;
}

.trade-result-overlay.win {
  background: radial-gradient(circle, rgba(0, 230, 118, 0.15) 0%, transparent 70%);
}

.trade-result-overlay.loss {
  background: radial-gradient(circle, rgba(255, 23, 68, 0.15) 0%, transparent 70%);
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

.trade-result-content {
  text-align: center;
  animation: resultPop 0.5s ease;
}

@keyframes resultPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.trade-result-overlay.win .result-icon { color: var(--green); }
.trade-result-overlay.loss .result-icon { color: var(--red); }

.result-label {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  letter-spacing: 4px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.result-amount {
  font-family: 'Sora', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
}

.trade-result-overlay.win .result-amount { color: var(--green); }
.trade-result-overlay.loss .result-amount { color: var(--red); }

.crash-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 23, 68, 0.15);
  animation: flashFade 0.6s ease forwards;
  z-index: 998;
}

@keyframes flashFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.toast-notification {
  position: fixed;
  bottom: calc(120px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 23, 68, 0.3);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.85rem;
  z-index: 2000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* Responsive */
@media (min-width: 768px) {
  .game-app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid rgba(255,255,255,0.05);
    border-right: 1px solid rgba(255,255,255,0.05);
  }

  .platform-name { font-size: 1.3rem; }
  .balance-value { font-size: 1rem; }
  .live-price { font-size: 1.6rem; }
}

@media (max-height: 600px) {
  .chart-wrapper { min-height: 160px; }
  .trade-btn { padding: 0.75rem; }
}


.platform-sub {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.logout-btn {
  border: 1px solid rgba(141, 198, 63, 0.3);
  background: rgba(141, 198, 63, 0.08);
  color: var(--ep-green);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.header-right { gap: 0.45rem; }
