:root {
  --bg-dark: #0a0a0a;
  --panel-dark: #111;
  --accent-neon: #0ff;
  --danger-neon: #f0f;
  --text-light: #e0e0e0;
  --shadow-neon: rgba(0, 255, 255, 0.5);
}
a.btn.position-absolute {
  top: 15px !important;
  left: 15px !important;
  z-index: 1000;
}
html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', system-ui, Arial;
  background: var(--bg-dark);
  color: var(--text-light);
}

/* MAIN CONTAINER */
.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;   /* ✅ use min-height instead */
    display: flex;
  flex-direction: column;
}

.status {
  animation: glowText 1.5s infinite alternate;
}

@keyframes glowText {
  from { text-shadow: 0 0 5px #0ff; }
  to { text-shadow: 0 0 20px #0ff; }
}

.history {
  margin-top: 15px;
  padding: 15px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,255,255,0.2);
  text-align: center;
}
/* HEADER */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  position: relative;
  margin-bottom: 10px;
}

.topbar h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 1.8rem;
  color: #0ff;
  text-shadow: 0 0 10px #0ff;
}
/* RULES BUTTON */
.rules-text {
  position: absolute;
  right: 20px;
  color: #aaa;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
  cursor: pointer;
  transition: 0.2s ease;
}

.rules-text:hover {
  opacity: 1;
  text-decoration: underline;
}

/* LAYOUT GRID */
.content {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
    flex: 1;              /* 🔥 take remaining space */
  align-items: center;
}

/* CONTROLS PANEL */
.controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: flex-start;
  justify-content: center; /* 🔥 center vertically */
  height: 90%;
    background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,255,255,0.2);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(0,255,255,0.1);
}

.controls label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BUTTONS */
.btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0ff, #00c3ff);
  color: #000;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(0,255,255,0.6);
  transition: all 0.25s ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 25px rgba(0,255,255,0.9);
}
.back-btn {
  color: #0ff;
  font-size: 1.2rem;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: 0.2s ease;
}

.back-btn:hover {
  background: rgba(0,255,255,0.15);
  box-shadow: 0 0 10px #0ff;
}
.btn.ghost {
  background: transparent;
  color: var(--accent-neon);
  border: 1px solid var(--accent-neon);
}

/* BOARD */
.board-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: auto; /* 🔥 limit height */
  padding: 10px;
  background: radial-gradient(circle at center, #111 40%, #000 100%);
  border-radius: 16px;
  box-shadow: 
    0 0 30px rgba(0,255,255,0.3),
    inset 0 0 15px rgba(0,255,255,0.2);
}

#boardCanvas {
  max-width: 100%;
  height: auto;
  display: block;
} 

/* STATUS */
.status {
  font-weight: 600;
  color: var(--accent-neon);
  text-align: center;
}

/* FOOTER */
.footer {
  margin-top: 12px;
  color: #666;
  text-align: center;
}
@media (min-width: 1025px) {
  .content {
    grid-template-columns: 280px 1fr;
    gap: 50px;
  }
}
/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .content {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .controls {
    align-items: center;
    text-align: center;
  }
}
/* 🔥 DESKTOP (FIXED — KEEP SIDE LAYOUT) */
@media (min-width: 1025px) {
  .content {
    grid-template-columns: 320px 1fr;
  }

}

/* 📱 TABLET */
@media (min-width: 641px) and (max-width: 1024px) {
  .content {
    grid-template-columns: 1fr; /* stack */
  }

  .controls {
    align-items: center;
    text-align: center;
  }

}

/* 📱 MOBILE */
@media (max-width: 640px) {
  .app-shell {
    margin: 5px;
    padding: 5px;
  }

  h1 {
    font-size: 1.3rem;
    text-align: center;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .controls {
    align-items: center;
    text-align: center;
    gap: 10px;
  }

  .controls label {
    font-size: 0.9rem;
  }

  .btn {
    padding: 6px 10px;
    font-size: 0.85rem;
  }


  .status {
    font-size: 0.9rem;
  }

  .footer {
    font-size: 0.8rem;
  }
}

/* 📱 SMALL DEVICES */
@media (max-width: 360px) {


  .btn {
    font-size: 0.8rem;
  }
}

/* POPUP */
#rulesPopup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.rules-box {
  background: #222;
  padding: 20px;
  width: 85%;
  max-width: 420px;
  border-radius: 12px;
  animation: popIn 0.3s ease;
}

.rules-box h2 {
  text-align: center;
}

.close-rules {
  margin-top: 15px;
  width: 100%;
  padding: 10px;
  background: #444;
  border: none;
  border-radius: 8px;
  color: #fff;
}

.close-rules:hover {
  background: #666;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==============================
   SEO CONTENT
============================== */

.seo-content {
  max-width: 900px;
  margin: 45px auto 20px;
  padding: 28px 30px;
  color: #d8d8d8;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(0,255,255,0.12);
  border-radius: 16px;
}

.seo-content h2 {
  margin: 0 0 12px;
  color: #f0f0f0;
  font-size: 1.45rem;
}

.seo-content h2:not(:first-child) {
  margin-top: 32px;
}

.seo-content p,
.seo-content li {
  color: #aaa;
  font-size: 15px;
  line-height: 1.75;
}

.seo-content ol {
  padding-left: 22px;
}

.seo-content li {
  margin-bottom: 6px;
}

.faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq details {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(0,255,255,0.10);
  border-radius: 10px;
  padding: 0 15px;
}

.faq summary {
  cursor: pointer;
  padding: 14px 0;
  color: #e8e8e8;
  font-weight: 600;
}

.faq details p {
  margin: 0;
  padding: 0 0 14px;
}

@media (max-width: 640px) {
  .seo-content {
    margin-top: 30px;
    padding: 22px 18px;
  }

  .seo-content h2 {
    font-size: 1.25rem;
  }

  .seo-content p,
  .seo-content li {
    font-size: 14px;
  }
}
/* =========================================================
   RESULT SCREEN — COMPACT
========================================================= */

.result-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: none;
  justify-content: center;
  align-items: center;

  padding: 12px;
  box-sizing: border-box;

  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(8px);

  overflow: hidden;
}

.result-screen.show {
  display: flex;
}


/* ================= RESULT CARD ================= */

.result-card {
  width: min(92vw, 480px);
  max-height: calc(100vh - 24px);

  box-sizing: border-box;

  padding: 20px 20px;

  background:
    radial-gradient(
      circle at 50% 0%,
      rgba(0, 255, 255, 0.08),
      transparent 45%
    ),
    #111;

  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 18px;

  box-shadow:
    0 0 28px rgba(0, 255, 255, 0.16),
    0 15px 45px rgba(0, 0, 0, 0.7);

  text-align: center;

  animation: resultCardIn 0.35s cubic-bezier(.2,.8,.2,1);

  overflow: hidden;
}


/* ================= ICON ================= */

.result-icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 5px;

  filter:
    drop-shadow(0 0 8px rgba(255,255,255,.25));
}


/* ================= TITLE ================= */

.result-card h2 {
  margin: 0;

  font-size: 1.65rem;
  line-height: 1.15;
  font-weight: 800;

  color: #0ff;

  text-shadow:
    0 0 8px #0ff,
    0 0 18px rgba(0,255,255,.35);
}


/* ================= SUBTITLE ================= */

.result-subtitle {
  margin: 5px 0 14px;

  color: #999;
  font-size: 0.82rem;
  line-height: 1.3;
}


/* ================= ACCURACY ================= */

.accuracy-box {
  padding: 11px 15px;
  margin-bottom: 12px;

  background: rgba(255,255,255,.035);

  border: 1px solid rgba(0,255,255,.15);
  border-radius: 12px;
}

.accuracy-label {
  color: #999;
  font-size: .72rem;
  margin-bottom: 1px;
}

.accuracy-value {
  font-size: 2rem;
  line-height: 1.1;
  font-weight: 800;

  color: #0ff;

  text-shadow:
    0 0 10px rgba(0,255,255,.55);
}


/* ================= MOVE ANALYSIS ================= */

.move-analysis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;

  margin-bottom: 12px;
}

.analysis-item {
  padding: 9px 5px;

  border-radius: 11px;

  background: rgba(255,255,255,.035);

  border: 1px solid rgba(255,255,255,.08);

  display: flex;
  flex-direction: column;
  align-items: center;
}

.analysis-icon {
  width: 25px;
  height: 25px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  margin-bottom: 3px;

  font-weight: 900;
  font-size: .85rem;
}

.analysis-number {
  font-size: 1.15rem;
  line-height: 1.1;
  font-weight: 800;
}

.analysis-label {
  margin-top: 1px;
  color: #999;
  font-size: .68rem;
}


/* ================= COLORS ================= */

.analysis-item.excellent .analysis-icon {
  color: #0ff;
  border: 1px solid #0ff;
  box-shadow: 0 0 7px rgba(0,255,255,.3);
}

.analysis-item.excellent .analysis-number {
  color: #0ff;
}

.analysis-item.good .analysis-icon {
  color: #7cff7c;
  border: 1px solid #7cff7c;
}

.analysis-item.good .analysis-number {
  color: #7cff7c;
}

.analysis-item.blunder .analysis-icon {
  color: #ff7b7b;
  border: 1px solid #ff7b7b;
}

.analysis-item.blunder .analysis-number {
  color: #ff7b7b;
}


/* ================= SCORE ================= */

.result-score {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 18px;

  margin: 4px 0 12px;
}

.result-score div:not(.score-divider) {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.result-score span {
  color: #888;
  font-size: .7rem;
}

.result-score strong {
  font-size: 1.5rem;
  line-height: 1.1;
  color: #f0f0f0;
}

.score-divider {
  color: #555;
  font-size: 1.2rem;
}


/* ================= MESSAGE ================= */

.result-message {
  padding: 10px 12px;

  margin-bottom: 13px;

  border-radius: 10px;

  background: rgba(0,255,255,.045);
  border: 1px solid rgba(0,255,255,.12);

  color: #ddd;

  font-size: .78rem;
  line-height: 1.35;
}


/* ================= BUTTONS ================= */

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.result-actions .btn {
  min-height: 42px;

  padding: 9px 10px;

  text-decoration: none;

  display: flex;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;

  font-size: .82rem;
}

.result-primary {
  background: linear-gradient(135deg, #0ff, #00c3ff);
  color: #000;
}

.result-secondary {
  background: transparent;
  color: #0ff;

  border: 1px solid #0ff;

  box-shadow: none;
}

.result-secondary:hover {
  background: rgba(0,255,255,.08);
  box-shadow: 0 0 15px rgba(0,255,255,.22);
}


/* ================= WIN / LOSE ================= */

.result-screen.result-win .result-card {
  border-color: rgba(0,255,255,.35);
}

.result-screen.result-win .result-icon {
  animation: winnerPulse 1.2s ease-in-out infinite alternate;
}

.result-screen.result-loss .result-card {
  border-color: rgba(240,0,255,.25);
}

.result-screen.result-loss .result-icon {
  animation: lossPulse 1.4s ease-in-out infinite alternate;
}


/* ================= ANIMATIONS ================= */

@keyframes resultFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes resultCardIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes winnerPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.06);
  }
}

@keyframes lossPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.03);
  }
}


/* ================= MOBILE ================= */

@media (max-width: 640px) {

  .result-screen {
    padding: 8px;
  }

  .result-card {
    width: min(94vw, 440px);
    padding: 16px 14px;
    border-radius: 16px;
  }

  .result-icon {
    font-size: 32px;
    margin-bottom: 4px;
  }

  .result-card h2 {
    font-size: 1.4rem;
  }

  .result-subtitle {
    margin: 4px 0 10px;
    font-size: .75rem;
  }

  .accuracy-box {
    padding: 9px 12px;
    margin-bottom: 9px;
  }

  .accuracy-value {
    font-size: 1.7rem;
  }

  .move-analysis {
    gap: 6px;
    margin-bottom: 9px;
  }

  .analysis-item {
    padding: 7px 3px;
  }

  .analysis-icon {
    width: 22px;
    height: 22px;
    font-size: .75rem;
    margin-bottom: 2px;
  }

  .analysis-number {
    font-size: 1rem;
  }

  .analysis-label {
    font-size: .62rem;
  }

  .result-score {
    gap: 15px;
    margin: 3px 0 9px;
  }

  .result-score strong {
    font-size: 1.3rem;
  }

  .result-message {
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: .72rem;
  }

  .result-actions {
    gap: 7px;
  }

  .result-actions .btn {
    min-height: 38px;
    padding: 7px 8px;
    font-size: .75rem;
  }
}
