/* game.css — Card Flip Game styles */

/* Prevent auto-scroll behavior on game page */
html {
  scroll-behavior: auto !important;
  overflow-anchor: none;
}

body {
  overflow-anchor: none;
}

/* Test mode banner */
.test-mode-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(255, 221, 126, 0.15), rgba(255, 156, 74, 0.1));
  border: 2px solid var(--rarity-legendary-solid);
  padding: 12px 24px;
  border-radius: 12px;
  margin-top: 16px;
  font-size: 1rem;
  color: var(--accent-3);
  box-shadow: 0 4px 20px rgba(255, 156, 74, 0.2);
}

.test-mode-banner i {
  font-size: 1.2rem;
}

/* Phase notice */
.phase-notice {
  background: linear-gradient(135deg, rgba(138, 107, 255, 0.1), rgba(47, 230, 184, 0.05));
  border: 2px solid rgba(138, 107, 255, 0.3);
  border-radius: 14px;
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent-2);
}

.phase-notice i {
  font-size: 1.3rem;
  color: var(--accent);
}

.phase-notice p {
  margin: 0;
  font-size: 0.95rem;
  color: #e9eef6;
}

/* Game arena layout */
.game-arena {
  padding: 24px 0;
}

/* Wallet Section */
.wallet-section {
  margin-bottom: 32px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(138, 107, 255, 0.08), rgba(47, 230, 184, 0.03));
  border-radius: 14px;
  border: 2px solid rgba(138, 107, 255, 0.2);
}

.wallet-connect {
  text-align: center;
}

.wallet-connect .btn {
  font-size: 1.1rem;
  padding: 14px 28px;
  margin-bottom: 12px;
}

.wallet-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 8px 0 0 0;
}

.wallet-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.wallet-address {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Courier New', monospace;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
}

.wallet-balance {
  color: var(--accent-3);
  font-size: 1.1rem;
  font-weight: 700;
}

/* Betting Controls */
.betting-controls {
  margin-bottom: 28px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bet-input-group {
  margin-bottom: 16px;
}

.bet-input-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-3);
  font-weight: 600;
}

.bet-input-group input {
  width: 100%;
  max-width: 300px;
  padding: 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 2px solid rgba(138, 107, 255, 0.3);
  background: rgba(255, 255, 255, 0.03);
  color: #f3f7fb;
}

.bet-input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.fee-notice {
  margin: 8px 0 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.room-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Rooms List */
#rooms-section {
  margin-bottom: 32px;
}

.section-title {
  margin: 0 0 16px 0;
  font-size: 1.3rem;
  color: var(--accent-2);
  font-family: Poppins, sans-serif;
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.no-rooms {
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-style: italic;
}

.room-card {
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border-radius: 12px;
  border: 2px solid rgba(138, 107, 255, 0.15);
  transition: all 240ms ease;
}

.room-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(138, 107, 255, 0.1);
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.room-header h4 {
  margin: 0;
  font-size: 1.05rem;
  color: #f3f7fb;
}

.room-status {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(61, 220, 132, 0.15);
  color: #3ddc84;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.room-info {
  margin-bottom: 14px;
}

.room-info p {
  margin: 6px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.room-info strong {
  color: #f3f7fb;
}

/* Active Game */
#active-game {
  margin-top: 20px;
}

.room-info {
  text-align: center;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(138, 107, 255, 0.08);
  border-radius: 10px;
  border: 1px solid rgba(138, 107, 255, 0.2);
}

.room-info h3 {
  margin: 0 0 8px 0;
  color: var(--accent-2);
}

.room-info p {
  margin: 4px 0;
  color: var(--muted);
}

#waiting-status {
  color: var(--accent-3);
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.game-state {
  margin-bottom: 32px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(138, 107, 255, 0.05), rgba(47, 230, 184, 0.02));
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Score board */
.score-board {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.score-item {
  text-align: center;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.score-item.player {
  border-left: 4px solid var(--rarity-epic-solid);
}

.score-item.opponent {
  border-left: 4px solid var(--rarity-legendary-solid);
}

.score-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.score-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  font-family: Poppins, sans-serif;
}

.wins {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.vs {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(138, 107, 255, 0.2);
}

/* Game status message */
.game-status {
  text-align: center;
  padding: 12px;
  background: rgba(47, 230, 184, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(47, 230, 184, 0.15);
}

.game-status p {
  margin: 0;
  font-size: 1rem;
  color: #f3f7fb;
  font-weight: 600;
}

/* Card selection */
.selection-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-3);
  margin: 24px 0 14px 0;
  font-family: Poppins, sans-serif;
}

.card-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.card-deck .game-card {
  cursor: pointer;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  transition: all 240ms ease;
  text-align: center;
  overflow: hidden;
  scroll-margin: 0;
  scroll-snap-align: none;
}

.card-deck .game-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
}

.card-deck .game-card p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
}

.card-deck .game-card:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(47, 230, 184, 0.08), rgba(138, 107, 255, 0.04));
  transform: scale(1.05);
}

.card-deck .game-card.selected {
  border-color: var(--accent-3);
  background: linear-gradient(180deg, var(--rarity-epic), rgba(138, 107, 255, 0.2));
  box-shadow: 0 0 24px rgba(138, 107, 255, 0.15);
}

/* Battle arena */
.battle-arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin: 32px 0;
  padding: 20px;
  background: linear-gradient(180deg, rgba(138, 107, 255, 0.02), transparent);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  min-height: 380px;
}

.battle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent);
  min-width: 220px;
}

.battle-card.your-card {
  border-color: var(--rarity-epic-solid);
  box-shadow: 0 0 24px rgba(138, 107, 255, 0.08);
}

.battle-card.opponent-card {
  border-color: var(--rarity-legendary-solid);
  box-shadow: 0 0 24px rgba(255, 156, 74, 0.08);
}

.card-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.battle-card.your-card .card-label {
  color: var(--rarity-epic-solid);
}

.battle-card.opponent-card .card-label {
  color: var(--rarity-legendary-solid);
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border: none;
}

.card-content img {
  max-width: 200px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: none;
  max-width: 200px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: none;
}

.card-info p {
  margin: 4px 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.card-info p:first-child {
  color: #f3f7fb;
  font-weight: 700;
  font-size: 1rem;
}

/* Battle result */
.battle-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  background: linear-gradient(135deg, rgba(47, 230, 184, 0.1), rgba(138, 107, 255, 0.1));
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  padding: 16px;
}

/* Battle history button */
.history-button-wrapper {
  margin: 24px 0;
  text-align: center;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.modal-content {
  background: var(--bg);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  margin: 0;
  color: var(--accent);
}

.btn-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.history-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.btn.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}
.battle-history-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}
.battle-history-table thead th {
  color: #cdd6f4;
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
}
.battle-history-table tbody tr {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
}
.battle-history-table tbody td {
  padding: 10px 12px;
}
.battle-history-table tbody tr.win td {
  color: #5ef3c1;
}
.battle-history-table tbody tr.lose td {
  color: #ff9b7a;
}

.battle-result.win {
  background: linear-gradient(135deg, rgba(61, 220, 132, 0.15), rgba(255, 209, 102, 0.08));
  border-color: rgba(61, 220, 132, 0.3);
}

.battle-result.lose {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 156, 74, 0.08));
  border-color: rgba(255, 107, 107, 0.3);
}

.result-text {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: Poppins, sans-serif;
  text-shadow: 0 0 12px rgba(138, 107, 255, 0.1);
  margin-bottom: 8px;
}

.battle-result.win .result-text {
  color: #3ddc84;
}

.battle-result.lose .result-text {
  color: #ff6b6b;
}

.result-sub {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Game actions */
.game-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}

.btn.primary {
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
  color: #081018;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 640px) {
  .battle-arena {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: auto;
  }

  .battle-result {
    min-height: 80px;
  }

  .card-deck {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
  }

  .score-board {
    gap: 12px;
  }

  .score-value {
    font-size: 1.6rem;
  }

  .card-content img {
    height: 100px;
  }
}

/* Animations */
@keyframes flip {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
    opacity: 0.3;
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes battleCircle3D {
  0% {
    transform: translateZ(0) rotateY(0deg) scale(0.9);
  }
  25% {
    transform: translateZ(50px) rotateY(90deg) scale(1.1);
  }
  50% {
    transform: translateZ(0) rotateY(180deg) scale(0.9);
  }
  75% {
    transform: translateZ(-50px) rotateY(270deg) scale(1.1);
  }
  100% {
    transform: translateZ(0) rotateY(360deg) scale(0.9);
  }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes winnerPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 24px rgba(61, 220, 132, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 48px rgba(61, 220, 132, 0.6);
  }
}

@keyframes loserShake {
  0%, 100% {
    transform: translateX(0) scale(1);
  }
  25% {
    transform: translateX(-10px) scale(0.98);
  }
  75% {
    transform: translateX(10px) scale(0.98);
  }
}

.card-content.flipping {
  animation: flip 0.8s ease-in-out;
}

.battle-arena.fighting {
  perspective: 1000px;
}

.battle-arena.fighting .card-content img {
  animation: battleCircle3D 2s ease-in-out infinite;
  transform-style: preserve-3d;
}

.battle-arena.fighting .your-card .card-content img {
  animation-delay: 0s;
}

.battle-arena.fighting .opponent-card .card-content img {
  animation-delay: 1s;
}

.battle-card.winner {
  animation: winnerPulse 1.5s ease-in-out infinite;
  border-color: #3ddc84 !important;
  box-shadow: 0 0 48px rgba(61, 220, 132, 0.4) !important;
}

.battle-card.loser {
  animation: loserShake 0.5s ease-in-out, fadeOut 0.8s ease-in-out 0.8s forwards;
}

.battle-card.hidden {
  opacity: 0;
  pointer-events: none;
}

/* End of game.css */
