@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Kalam:wght@400;700&display=swap');

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #e8e2d4;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(0,0,0,0.02) 28px);
  font-family: 'Kalam', cursive;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-x: hidden;
}

.stage {
  width: 100%;
  max-width: 900px;
  position: relative;
}

/* ---- Screen transitions ---- */
.screen {
  display: none;
  opacity: 0;
  transform: translateY(14px);
}

.screen.active {
  display: block;
  animation: screenIn 0.35s ease forwards;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.paper-sheet {
  background: #f5f0e1;
  width: 100%;
  padding: 40px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15), 0 4px 10px rgba(0,0,0,0.1), 0 20px 40px rgba(0,0,0,0.08);
  position: relative;
}

.paper-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 3px;
}

.title {
  font-family: 'Special Elite', cursive;
  text-align: center;
  font-size: 42px;
  color: #2b2b2b;
  margin: 0;
  letter-spacing: 2px;
}

.title.small-title { font-size: 30px; }
.title .two { color: #a13d3d; }

.subtitle {
  text-align: center;
  color: #6b6459;
  margin-top: 4px;
  margin-bottom: 30px;
  font-style: italic;
}

.section-title {
  font-family: 'Special Elite', cursive;
  text-align: center;
  font-size: 24px;
  color: #2b2b2b;
  margin: 6px 0 30px;
}

/* ---- Landing ---- */
.landing-sheet { text-align: center; padding: 70px 40px; }

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.btn-primary, .btn-secondary {
  padding: 14px;
  font-family: 'Special Elite', cursive;
  font-size: 15px;
  border-radius: 3px;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary { background: #2b2b2b; color: #f5f0e1; }
.btn-primary:hover { background: #a13d3d; transform: translateY(-1px); }

.btn-secondary { background: transparent; color: #2b2b2b; border: 2px solid #b5aa92; }
.btn-secondary:hover { background: #eee4c8; }

.back-btn {
  background: none;
  border: none;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: #6b6459;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 0;
}
.back-btn:hover { color: #a13d3d; }

/* ---- Bot grid ---- */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.bot-card {
  background: #f0e8d6;
  border: 2px solid #b5aa92;
  border-radius: 4px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.bot-card:nth-child(odd) { transform: rotate(-0.6deg); }
.bot-card:nth-child(even) { transform: rotate(0.6deg); }

.bot-card:hover { background: #d8c98a; transform: translateY(-3px) rotate(0deg); }

.bot-card svg { width: 64px; height: 64px; margin-bottom: 8px; }

.bot-name {
  font-family: 'Special Elite', cursive;
  font-size: 13px;
  color: #2b2b2b;
  margin: 0 0 4px;
}

.bot-diff {
  font-size: 11px;
  color: #6b6459;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Leaderboard ---- */
.leaderboard-sheet { max-width: 600px; margin: 0 auto; }

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Kalam', cursive;
}

.leaderboard-table th {
  text-align: left;
  font-family: 'Special Elite', cursive;
  font-size: 12px;
  color: #6b6459;
  border-bottom: 2px dashed #b5aa92;
  padding: 8px 6px;
  text-transform: uppercase;
}

.leaderboard-table td {
  padding: 10px 6px;
  border-bottom: 1px solid #e0d6bc;
  color: #2b2b2b;
  font-size: 15px;
}

.leaderboard-table tr.you-row td {
  background: #d8c98a;
  font-weight: bold;
}

/* ---- Board ---- */
.main-layout {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.board-wrap { display: flex; flex-direction: column; align-items: center; }

.board {
  width: 480px;
  height: 480px;
  display: grid;
  grid-template-columns: repeat(8, 60px);
  grid-template-rows: repeat(8, 60px);
  border: 3px solid #2b2b2b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.square {
  width: 60px;
  height: 60px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  cursor: pointer;
  position: relative;
  user-select: none;
  overflow: hidden;
}

.light { background: #f0e8d6; }
.dark { background: #c9bd9e; }
.square.selected { background: #d8c98a !important; }

.square.highlight::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(60,60,60,0.35);
}

.square.king-in-check {
  box-shadow: inset 0 0 0 3px #a13d3d, inset 0 0 20px rgba(161,61,61,0.4);
}

.status {
  margin-top: 16px;
  font-size: 18px;
  color: #2b2b2b;
  font-family: 'Special Elite', cursive;
}

.panel { width: 260px; display: flex; flex-direction: column; gap: 24px; }

.panel-section h2 {
  font-family: 'Special Elite', cursive;
  font-size: 18px;
  border-bottom: 2px dashed #b5aa92;
  padding-bottom: 6px;
  margin-bottom: 14px;
  color: #2b2b2b;
}

.panel-section label { display: block; font-size: 14px; margin-bottom: 4px; color: #6b6459; }

.panel-section select {
  width: 100%;
  padding: 8px;
  margin-bottom: 16px;
  font-family: 'Kalam', cursive;
  font-size: 15px;
  border: 1px solid #b5aa92;
  background: #f5f0e1;
  border-radius: 3px;
}

.panel-section button {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  font-family: 'Special Elite', cursive;
  font-size: 14px;
  background: #2b2b2b;
  color: #f5f0e1;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.panel-section button:hover { background: #a13d3d; }

.move-list {
  padding-left: 20px;
  font-size: 14px;
  color: #2b2b2b;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,28,24,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.torn-card {
  background: #f5f0e1;
  padding: 36px 40px;
  max-width: 360px;
  width: 90%;
  position: relative;
  text-align: center;
  transform: rotate(-0.6deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 10px 30px rgba(0,0,0,0.25);
  clip-path: polygon(0% 2%, 4% 0%, 12% 1%, 20% 0%, 30% 1.5%, 40% 0%, 52% 1%, 62% 0%, 72% 1.5%, 82% 0%, 92% 1%, 100% 2%, 99% 12%, 100% 25%, 99% 38%, 100% 50%, 99% 63%, 100% 76%, 99% 88%, 100% 98%, 92% 100%, 82% 99%, 72% 100%, 62% 99%, 50% 100%, 40% 99%, 30% 100%, 20% 99%, 10% 100%, 0% 98%, 1% 88%, 0% 76%, 1% 63%, 0% 50%, 1% 38%, 0% 25%, 1% 12%);
}

.card-label {
  font-family: 'Special Elite', cursive;
  color: #6b6459;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 20px;
}

.promo-options { display: flex; gap: 12px; justify-content: center; }

.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #f0e8d6;
  border: 2px solid #b5aa92;
  border-radius: 4px;
  padding: 12px 10px;
  font-size: 34px;
  cursor: pointer;
  font-family: 'Kalam', cursive;
  color: #2b2b2b;
  transition: background 0.15s, transform 0.1s;
}

.promo-btn span { font-size: 12px; color: #6b6459; }
.promo-btn:hover { background: #d8c98a; transform: translateY(-2px); }

.card-stamp {
  font-family: 'Special Elite', cursive;
  font-size: 26px;
  color: #a13d3d;
  border: 3px solid #a13d3d;
  display: inline-block;
  padding: 6px 18px;
  transform: rotate(-3deg);
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.card-result { font-family: 'Kalam', cursive; font-size: 18px; color: #2b2b2b; margin-bottom: 24px; }

.gameover-actions { display: flex; gap: 10px; justify-content: center; }

.gameover-actions button {
  padding: 10px 18px;
  font-family: 'Special Elite', cursive;
  font-size: 14px;
  background: #2b2b2b;
  color: #f5f0e1;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.gameover-actions button:hover { background: #a13d3d; }