/* 30-Second Market */

.market-game-wrap {
  max-width: 720px;
  margin: 0 auto 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.market-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.status-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  text-align: center;
}

.status-card.highlight {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.status-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.status-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#market-timer {
  font-size: 2rem;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

#market-roi.profit {
  color: #ff6b6b;
}

#market-roi.loss {
  color: #4dabf7;
}

#market-roi.neutral {
  color: var(--color-text-muted);
}

.chart-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.chart-panel.sell-flash-profit {
  animation: sellProfitFlash 0.65s ease-out;
}

.chart-panel.sell-flash-loss {
  animation: sellLossFlash 0.65s ease-out;
}

.chart-panel.sell-shake {
  animation: sellLossFlash 0.65s ease-out, sellShake 0.45s ease-in-out;
}

.sell-effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.sell-float {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, 0);
  font-size: 2.25rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.sell-float.profit {
  color: #ff6b6b;
  animation: sellFloatUp 0.85s ease-out forwards;
}

.sell-float.loss {
  color: #4dabf7;
  animation: sellFloatDown 0.85s ease-in forwards;
}

.sell-particle {
  position: absolute;
  font-size: 1.125rem;
  font-weight: 800;
  pointer-events: none;
}

.sell-particle.profit {
  color: #ff8787;
  animation: sellParticleUp 0.8s ease-out forwards;
}

.sell-particle.loss {
  color: #74c0fc;
  animation: sellParticleDown 0.8s ease-in forwards;
}

#market-roi.roi-pop-profit {
  animation: roiPopProfit 0.55s ease-out;
}

#market-roi.roi-pop-loss {
  animation: roiPopLoss 0.55s ease-out;
}

.btn-sell.sell-btn-profit {
  animation: sellBtnProfit 0.45s ease-out;
}

.btn-sell.sell-btn-loss {
  animation: sellBtnLoss 0.45s ease-out;
}

@keyframes sellProfitFlash {
  0% { box-shadow: inset 0 0 0 rgba(255, 107, 107, 0); }
  35% { box-shadow: inset 0 0 80px rgba(255, 107, 107, 0.35); border-color: #ff6b6b; }
  100% { box-shadow: inset 0 0 0 rgba(255, 107, 107, 0); }
}

@keyframes sellLossFlash {
  0% { box-shadow: inset 0 0 0 rgba(77, 171, 247, 0); }
  35% { box-shadow: inset 0 0 80px rgba(77, 171, 247, 0.35); border-color: #4dabf7; }
  100% { box-shadow: inset 0 0 0 rgba(77, 171, 247, 0); }
}

@keyframes sellShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(7px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-2px); }
}

@keyframes sellFloatUp {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1.25); }
}

@keyframes sellFloatDown {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.85); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 70px) scale(0.85); }
}

@keyframes sellParticleUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.5); }
}

@keyframes sellParticleDown {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(50px) scale(0.5); }
}

@keyframes roiPopProfit {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.35); text-shadow: 0 0 20px rgba(255, 107, 107, 0.6); }
}

@keyframes roiPopLoss {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.2); text-shadow: 0 0 20px rgba(77, 171, 247, 0.6); }
}

@keyframes sellBtnProfit {
  0%, 100% { filter: brightness(1); box-shadow: none; }
  50% { filter: brightness(1.25); box-shadow: 0 0 24px rgba(255, 107, 107, 0.55); }
}

@keyframes sellBtnLoss {
  0%, 100% { filter: brightness(1); box-shadow: none; }
  50% { filter: brightness(0.85); box-shadow: 0 0 20px rgba(77, 171, 247, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  .chart-panel.sell-flash-profit,
  .chart-panel.sell-flash-loss,
  .chart-panel.sell-shake,
  .sell-float,
  .sell-particle,
  #market-roi.roi-pop-profit,
  #market-roi.roi-pop-loss,
  .btn-sell.sell-btn-profit,
  .btn-sell.sell-btn-loss,
  .game-overlay.overlay-end-profit,
  .game-overlay.overlay-end-loss,
  .overlay-result.end-profit #overlay-roi,
  .overlay-result.end-loss #overlay-roi,
  .end-particle {
    animation: none !important;
  }
}

#market-chart {
  display: block;
  width: 100%;
  height: 280px;
  touch-action: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(15, 20, 25, 0.82);
  backdrop-filter: blur(6px);
  z-index: 2;
  padding: 1.5rem;
}

.game-overlay.hidden {
  display: none;
}

.overlay-result {
  text-align: center;
  position: relative;
}

.overlay-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.overlay-roi-label,
.overlay-balance-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.375rem;
}

.overlay-balance-label {
  margin-top: 0.75rem;
}

.overlay-roi {
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.25rem;
  line-height: 1.1;
}

.overlay-result.end-profit #overlay-roi {
  animation: endRoiRevealProfit 0.9s ease-out;
}

.overlay-result.end-loss #overlay-roi {
  animation: endRoiRevealLoss 0.9s ease-out;
}

.overlay-result.end-neutral #overlay-roi {
  animation: endRoiRevealNeutral 0.7s ease-out;
}

.game-overlay.overlay-end-profit {
  animation: overlayEndProfitGlow 1.4s ease-out;
}

.game-overlay.overlay-end-loss {
  animation: overlayEndLossGlow 1.4s ease-out, overlayEndShake 0.5s ease-in-out;
}

.overlay-effect-layer {
  position: absolute;
  inset: -2rem;
  pointer-events: none;
  overflow: hidden;
}

.end-particle {
  position: absolute;
  bottom: 30%;
  font-size: 1.25rem;
  font-weight: 800;
  pointer-events: none;
}

.end-particle.profit {
  color: #ff8787;
  animation: endParticleRise 1.1s ease-out forwards;
}

.end-particle.loss {
  color: #74c0fc;
  animation: endParticleFall 1.1s ease-in forwards;
}

@keyframes endRoiRevealProfit {
  0% { opacity: 0; transform: scale(0.4); }
  55% { opacity: 1; transform: scale(1.2); text-shadow: 0 0 30px rgba(255, 107, 107, 0.7); }
  100% { transform: scale(1); text-shadow: 0 0 12px rgba(255, 107, 107, 0.3); }
}

@keyframes endRoiRevealLoss {
  0% { opacity: 0; transform: scale(0.85) translateY(-12px); }
  30% { opacity: 1; transform: scale(1) translateY(0); }
  50% { transform: scale(1) translateY(4px); }
  100% { transform: scale(1) translateY(0); text-shadow: 0 0 16px rgba(77, 171, 247, 0.5); }
}

@keyframes endRoiRevealNeutral {
  0% { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes overlayEndProfitGlow {
  0% { box-shadow: inset 0 0 0 rgba(255, 107, 107, 0); }
  40% { box-shadow: inset 0 0 100px rgba(255, 107, 107, 0.25); }
  100% { box-shadow: inset 0 0 0 rgba(255, 107, 107, 0); }
}

@keyframes overlayEndLossGlow {
  0% { box-shadow: inset 0 0 0 rgba(77, 171, 247, 0); }
  40% { box-shadow: inset 0 0 100px rgba(77, 171, 247, 0.25); }
  100% { box-shadow: inset 0 0 0 rgba(77, 171, 247, 0); }
}

@keyframes overlayEndShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes endParticleRise {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-120px) scale(0.4) rotate(20deg); }
}

@keyframes endParticleFall {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(80px) scale(0.5); }
}

.overlay-roi.profit {
  color: #ff6b6b;
}

.overlay-roi.loss {
  color: #4dabf7;
}

.overlay-roi.neutral {
  color: var(--color-text-muted);
}

.overlay-balance {
  font-size: 1rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.overlay-action-btn {
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem 3.5rem;
  min-width: 220px;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(145deg, var(--color-accent-hover), var(--color-accent));
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.15s, filter 0.15s;
  letter-spacing: 0.03em;
}

.overlay-action-btn:hover {
  filter: brightness(1.08);
}

.overlay-action-btn:active {
  transform: scale(0.97);
}

.market-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.market-btn {
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, filter 0.15s;
  letter-spacing: 0.05em;
}

.market-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.market-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-buy {
  background: linear-gradient(145deg, #ff6b6b, #e03131);
  color: #fff;
}

.btn-sell {
  background: linear-gradient(145deg, #4dabf7, #1c7ed6);
  color: #fff;
}

.trade-log-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
}

.trade-log-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.trade-log-list {
  list-style: none;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.trade-log-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.625rem;
  padding: 0.5rem 0.625rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.trade-log-item .trade-type {
  font-weight: 800;
  min-width: 2.5rem;
}

.trade-log-item.buy .trade-type {
  color: #ff6b6b;
}

.trade-log-item.sell .trade-type {
  color: #4dabf7;
}

.trade-log-item .trade-pnl.profit {
  color: #ff6b6b;
  font-weight: 700;
}

.trade-log-item .trade-pnl.loss {
  color: #4dabf7;
  font-weight: 700;
}

.trade-log-item .trade-time {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.trade-log-empty {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0.75rem 0;
}

.trade-log-empty.hidden {
  display: none;
}

.market-hint {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .market-status {
    grid-template-columns: 1fr 1fr;
  }

  .status-card:nth-child(1) {
    grid-column: 1 / -1;
  }

  #market-timer {
    font-size: 1.75rem;
  }

  #market-chart {
    height: 220px;
  }

  .market-btn {
    padding: 1rem 0.75rem;
    font-size: 1rem;
  }

  .overlay-action-btn {
    font-size: 1.25rem;
    padding: 1rem 2.5rem;
    min-width: 180px;
  }

  .overlay-roi {
    font-size: 2rem;
  }
}
