/* ==========================================================================
   Impossible Chess - Main Styles & Design System
   ========================================================================== */

:root {
  --bg-main: #121416;
  --bg-card: #1c1f23;
  --bg-card-hover: #262a30;
  --border-color: #2f353d;
  --accent-green: #2e8253;
  --accent-green-hover: #38a167;
  --accent-gold: #e5a93c;
  --accent-danger: #c92a2a;
  --text-main: #f0f2f5;
  --text-muted: #9ba3af;
  --light-square: #f0d9b5;
  --dark-square: #b58863;
  --selected-square: #f7ec59;
  --last-move: rgba(255, 255, 0, 0.45);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

header {
  text-align: center;
  margin-bottom: 12px;
  width: 100%;
  max-width: 960px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.badge-impossible {
  font-size: 0.65rem;
  background: linear-gradient(135deg, #b31010, #ff4d4d);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 1px;
}

.game-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 960px;
  align-items: center;
}

@media (min-width: 860px) {
  .game-layout {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
  }
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 460px;
}

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 460px;
}

@media (min-width: 860px) {
  .sidebar-column {
    max-width: 320px;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  width: 100%;
}

.status-box {
  background: #15181b;
  border-left: 4px solid var(--accent-gold);
}

.status-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.status-active {
  color: #fff;
}

.status-check {
  color: #ff3b30;
}

.status-mate {
  color: #f59f00;
}

.status-draw {
  color: #9ba3af;
}

.button-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.button-group-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

button {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: #272c33;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: #3f4752;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.btn-primary {
  background: var(--accent-green);
  border-color: var(--accent-green-hover);
}

button.btn-primary:hover:not(:disabled) {
  background: var(--accent-green-hover);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-item label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}

select {
  background: #14171a;
  color: #fff;
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  outline: none;
  touch-action: manipulation;
  max-width: 65%;
  flex: 1;
  text-overflow: ellipsis;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.modal-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.promotion-pieces {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.promo-btn {
  width: 60px;
  height: 60px;
  font-size: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #282e37;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, border-color 0.1s;
}

.promo-btn:hover {
  transform: scale(1.08);
  border-color: var(--accent-gold);
  background: #333a46;
}

.victory-card {
  border: 1px solid #735118;
  background: radial-gradient(circle at top, #231e13 0%, #17191c 80%);
}

.victory-badge {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.victory-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
  text-align: left;
}

.victory-stat-item {
  background: #111417;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
}

.victory-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.victory-stat-val {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.share-btn-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.btn-whatsapp {
  background: #1e5e3a;
  border-color: #25804e;
  color: #fff;
}

.btn-whatsapp:hover {
  background: #25804e;
}

.btn-twitter {
  background: #192734;
  border-color: #2b3d4f;
  color: #93c5fd;
}

.btn-twitter:hover {
  background: #243447;
}

/* Live Global Ticker */
.ticker-wrap {
  display: flex;
  align-items: center;
  background: #15181c;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
  width: 100%;
  max-width: 960px;
  font-size: 0.75rem;
}

.ticker-label {
  background: #272c33;
  color: #4ade80;
  font-weight: 800;
  padding: 6px 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-right: 1px solid var(--border-color);
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  padding: 6px 0;
}

.ticker-marquee {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 30s linear infinite;
  color: #d1d5db;
}

.ticker-wrap:hover .ticker-marquee {
  animation-play-state: paused;
}

@keyframes marquee {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(-100%, 0);
  }
}

.ticker-badge {
  background: #2e8253;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-right: 4px;
}

/* Post-Game Analysis Badges */
.badge-move-best {
  background: #1c3829;
  color: #4ade80;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.75rem;
}

.badge-move-good {
  background: #1f2937;
  color: #e5e7eb;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.badge-move-inaccuracy {
  background: #3b3017;
  color: #fcd34d;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.badge-move-mistake {
  background: #3d2417;
  color: #fb923c;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.badge-move-blunder {
  background: #3d1717;
  color: #f87171;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.75rem;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 10px;
}

.analysis-table th,
.analysis-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #232830;
  text-align: center;
}

.analysis-table th {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

footer {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Mobile Responsive */
@media (max-width: 520px) {
  body {
    padding: 8px 6px;
  }

  header h1 {
    font-size: 1.15rem;
  }

  .card {
    padding: 10px;
  }

  .button-group,
  .button-group-3 {
    gap: 5px;
  }

  button {
    min-height: 40px;
    font-size: 0.8rem;
  }

  .setting-item {
    font-size: 0.8rem;
  }

  select {
    font-size: 0.8rem;
    max-width: 60%;
  }

  .modal-card {
    padding: 14px;
    max-width: 95vw;
  }

  .promo-btn {
    width: clamp(48px, 14vw, 58px);
    height: clamp(48px, 14vw, 58px);
    font-size: clamp(28px, 9vw, 36px);
  }
}

@media (max-width: 380px) {
  header h1 {
    font-size: 1rem;
  }

  .button-group-3 {
    grid-template-columns: 1fr;
  }
}