:root {
  --paper: #f5ead7;
  --paper-2: #f0dcc0;
  --paper-3: #fbf5ea;
  --ink: #1f1a14;
  --muted: #5f564a;
  --board-light: #f6f0e6;
  --board-dark: #6f5b4c;
  --accent: #d24a3a;
  --accent-2: #b99a7a;
  --human: #d24a3a;
  --ai: #2f231f;
  --panel: rgba(255, 255, 255, 0.78);
  --border: rgba(31, 26, 20, 0.14);
  --shadow: 0 16px 30px -24px rgba(31, 26, 20, 0.35);
  --font-ui: "Space Grotesk", sans-serif;
  --font-display: "Fraunces", serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  background: radial-gradient(circle at top, #fff7e2 0%, var(--paper) 40%, var(--paper-2) 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: -10%;
  background:
    radial-gradient(circle at 10% 12%, rgba(210, 74, 58, 0.18), transparent 45%),
    radial-gradient(circle at 88% 78%, rgba(31, 26, 20, 0.12), transparent 45%);
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(120deg, rgba(255, 255, 255, 0.6), transparent 45%);
  opacity: 0.6;
  z-index: -1;
  pointer-events: none;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title {
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 0.04em;
  font-family: var(--font-display);
  font-weight: 600;
}

.status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status__actions {
  display: flex;
  justify-content: flex-end;
}

#statusMessage {
  font-size: 12px;
  color: var(--muted);
}

button,
.portal-link {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--ink);
  color: var(--paper-3);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.8px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.portal-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

select {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 24px;
  align-items: start;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(80vmin, 560px);
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--board-dark);
}

.square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.15s ease;
}

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

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

.square.legal::after {
  content: "";
  width: 18%;
  height: 18%;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.85;
}

.square.selected .piece {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
}

.square.last-from {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
}

.square.last-to {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.piece {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  box-shadow: inset -6px -6px 10px rgba(0, 0, 0, 0.2),
    0 8px 16px rgba(0, 0, 0, 0.25);
  animation: pop 0.12s ease;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}

.piece.red {
  background: radial-gradient(circle at 30% 30%, #e97272, var(--human));
}

.piece.black {
  background: radial-gradient(circle at 30% 30%, #5a5a58, var(--ai));
}

.piece.king::after {
  content: "";
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2) inset;
}

.panel {
  background: var(--panel);
  padding: 16px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 16px;
  font-family: var(--font-ui);
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-row span:last-child {
  font-weight: 600;
}

.panel-row.hint {
  font-size: 14px;
  color: var(--muted);
}

.label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.pill.red {
  background: rgba(196, 61, 61, 0.15);
  color: var(--human);
}

.pill.dark {
  background: rgba(47, 46, 44, 0.12);
  color: var(--ai);
}

.footer {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.site-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: none;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-copy {
  font-weight: 600;
  letter-spacing: 0.02em;
}

@keyframes pop {
  from {
    transform: scale(0.96);
    opacity: 0.8;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }

  .board {
    width: min(90vmin, 520px);
    margin: 0 auto;
  }

  .panel {
    width: min(90vmin, 520px);
    margin: 0 auto;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-footer {
    font-size: 0.9rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-link {
    display: none;
  }

  .status {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .status__text {
    gap: 2px;
  }
}
