/* Boxwood Web App — Sandstone Theme */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #FDFBF7;
  --surface: #F5F3EF;
  --text: #1C1917;
  --text-secondary: #78716C;
  --text-tertiary: #A8A29E;
  --accent: #B98B8B;
  --border: #E7E5E4;
  --board-light: #E8E0D5;
  --board-dark: #B7A99A;
  --success: #6B9080;
  --success-muted: rgba(107, 144, 128, 0.15);
  --error: #C4746E;
  --error-muted: rgba(196, 116, 110, 0.15);
  --selected: rgba(107, 144, 128, 0.5);
  --legal-dot: rgba(107, 144, 128, 0.35);
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Satoshi', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--text);
}

.nav-logo img {
  border-radius: 3px;
}

.nav-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* Main layout */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
  height: calc(100vh - 52px);
  height: calc(100dvh - 52px);
}

/* Board */
#board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0;
}

#board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(calc(100vw - 2rem), 400px);
  height: min(calc(100vw - 2rem), 400px);
  border-radius: 4px;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  touch-action: none;
}

/* Clip corners via individual corner squares */
.square:first-child { border-top-left-radius: 4px; }
.square:nth-child(8) { border-top-right-radius: 4px; }
.square:nth-child(57) { border-bottom-left-radius: 4px; }
.square:last-child { border-bottom-right-radius: 4px; }

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  overflow: visible;
}

.square.light {
  background: var(--board-light);
}

.square.dark {
  background: var(--board-dark);
}

.square.selected {
  background: var(--selected) !important;
}

.square.last-move-from {
  background: rgba(185, 139, 139, 0.3) !important;
}

.square.last-move-to {
  background: rgba(185, 139, 139, 0.5) !important;
}

/* Legal move indicators */
.square .legal-dot {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--legal-dot);
  pointer-events: none;
}

.square .legal-capture {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 5px solid var(--legal-dot);
  pointer-events: none;
  box-sizing: border-box;
}

/* Pieces */
.square svg {
  width: 85%;
  height: 85%;
  pointer-events: none;
}

/* Piece being dragged — lifted out of grid flow, follows finger */
.square.dragging svg {
  position: fixed;
  width: auto;
  height: auto;
  z-index: 500;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
  will-change: transform;
}

/* Dim the piece on its origin square while dragging */
.square.drag-origin svg {
  opacity: 0.2;
}

/* Feedback overlay */
.feedback {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 100;
}

.feedback.hidden {
  opacity: 0;
}

.feedback.correct {
  background: var(--success-muted);
  opacity: 1;
}

.feedback.incorrect {
  background: var(--error-muted);
  opacity: 1;
}

/* Info bar */
#info-bar {
  width: 100%;
  max-width: 400px;
  padding: 1rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#puzzle-counter {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 60px;
}

#progress-bar-track {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

/* Message */
#message {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 0.75rem 0 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-height: 3.5rem;
}

#message.success {
  color: var(--success);
}

/* Responsive */
@media (min-width: 600px) {
  #board {
    width: 400px;
    height: 400px;
  }
}

/* Completion screen */
.completion {
  text-align: center;
  padding: 3rem 1.5rem;
}

.completion h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.completion p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.completion .cta {
  display: inline-block;
  font-family: 'Satoshi', system-ui, sans-serif;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--text);
  padding: 0.75rem 1.75rem;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}

.completion .cta:hover {
  background: #0c0a09;
}
