/* === Basic layout === */
:root {
  --primary-color: #d4a574;
  --secondary-color: #8b4513;
  --accent-brown: #8b6f47;
  --accent-mahogany: #6b4423;
  --bg-color: #0a0a0a;
  --card-bg: rgba(212, 165, 116, 0.05);
  --card-hover: rgba(212, 165, 116, 0.12);
  --text-color: #ffffff;
  --text-secondary: #c9b8a3;
  --text-muted: #9a8770;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-color);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212, 165, 116, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139, 69, 19, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #0a0a0a 0%, #000000 100%);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  overflow-x: hidden;
  overscroll-behavior: none;
  /* Prevent rubber-banding/refresh */
}

header {
  background-color: #050505;
  background-image: url('../img/header_bg.png');
  background-repeat: repeat;
  /* Blend the pattern with the dark background to keep it subtle */
  background-blend-mode: overlay;
  color: white;
  width: 100%;
  padding: 1rem 0;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 10;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.header-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

header h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(212, 165, 116, 0.5));
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* === Navigation === */
.header-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  /* Use theme color */
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
}

.nav-link:hover {
  background-color: rgba(212, 165, 116, 0.15);
  /* Primary color hint */
  color: #fff;
  border-color: rgba(212, 165, 116, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-link:active {
  transform: translateY(0);
}

/* === Module Header === */
.module-header {
  display: flex;
  justify-content: space-between;
  /* Align title and button to opposite ends */
  align-items: center;
  /* Vertical alignment */
  margin-bottom: 10px;
  /* Reduced margin for tighter layout */
  padding: 8px 12px;
  /* Compact padding */
  width: min(90vmin, 500px);
  /* Matches the width of the board */
  box-sizing: border-box;
  /* Includes padding and borders in width */
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  /* Gradient background */
  border-radius: 6px;
  /* Rounded corners */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  /* Subtle shadow for depth */
  color: var(--text-color);
}

.module-header .module-name {
  font-size: 1.4rem;
  /* Slightly smaller font size */
  font-weight: 700;
  /* Strong emphasis */
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
  /* Subtle shadow for visibility */
}

.module-header button,
.module-header .module-nav-button {
  background-color: var(--accent-mahogany);
  color: var(--text-color);
  border: none;
  padding: 5px 10px;
  /* Smaller padding to reduce button size */
  border-radius: 4px;
  font-size: 0.9rem;
  /* Compact button text size */
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.module-header button:hover,
.module-header .module-nav-button:hover {
  background-color: var(--accent-brown);
  /* Slightly lighter hover color */
  transform: translateY(-1px);
  /* Subtle hover effect */
}

/* === Exercise Info === */
.exercise-info {
  font-size: 1.15rem;
  /* Adjust to match proportions */
  font-weight: 500;
  text-align: center;
  padding: 8px 12px;
  /* Compact padding */
  margin-top: 10px;
  /* Reduced spacing above */
  width: min(90vmin, 500px);
  /* Matches the width of the board */
  box-sizing: border-box;
  /* Includes padding and borders in width */
  color: var(--text-secondary);
  background-color: var(--card-bg);
  border-radius: 6px;
  /* Rounded corners for consistency */
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* Subtle border */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  /* Depth for emphasis */
}

.exercise-info p {
  margin: 5px 0;
  /* Compact spacing */
}

.exercise-info p:first-child {
  font-weight: 600;
  color: var(--text-color);
  /* Brighter for visibility */
  font-size: 1.3rem;
  /* Slightly larger for emphasis */
}

/* === Board container === */
#draughts-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

/* === Board grid === */
#board {
  width: min(90vmin, 500px);
  /* always fills screen but stays responsive */
  height: min(90vmin, 500px);
  /* forces explicit size, prevents collapsing */
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  border: 8px solid #3e2723;
  border-radius: 4px;
  background-color: #3e2723;
  touch-action: none;
  box-sizing: border-box;
  /* Prevent scroll/zoom on board */
}

/* keeps desktop version the same */

/* === Squares === */
.square {
  width: 100%;
  height: 100%;
  font-size: min(5vw, 2rem);
  /* scales piece size too */
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.square.light {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 30%),
    linear-gradient(160deg, #eecfa1 0%, #deb887 60%, #cdaa7d 100%);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.15);
}

.square.dark {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
    linear-gradient(160deg, #9e764a 0%, #805b36 100%);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
}

.square.dark::before {
  content: attr(data-square-number);
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: min(2vw, 12px);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  display: none;
  z-index: 5;
  /* Default off */
}

#board.show-numbers .square.dark::before {
  display: block;
}

/* === Highlighting for moves, selection etc === */
/* === Highlighting for moves, selection etc === */
.square.highlight {
  box-shadow: inset 0 0 20px rgba(255, 206, 84, 0.8), 0 0 15px rgba(255, 206, 84, 0.5);
  z-index: 2;
}

.square.valid-move {
  background: radial-gradient(circle, rgba(255, 206, 84, 0.4) 0%, transparent 70%);
  box-shadow: inset 0 0 10px rgba(255, 206, 84, 0.3);
}

/* === Pieces (if rendered as text/icons) === */
.piece {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: transform 0.1s ease;
  pointer-events: none;
}

.piece.dragging {
  opacity: 0.6;
  transform: scale(1.1);
}

/* Captured piece fade out animation */
.piece.fading-out {
  opacity: 0 !important;
  transform: scale(0.8) !important;
  transition: opacity 0.25s ease, transform 0.25s ease !important;
}

.piece-image {
  width: 80%;
  height: 80%;
  object-fit: contain;
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: none;
  /* Prevent browser handling of gestures */
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.4));
}

/* === Scrollbar styling === */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #e4b584, #a0522d);
}

/* === Feedback message animations === */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}