:root {
  --bg: #081018;
  --bg-soft: #101b27;
  --panel: rgba(10, 20, 31, 0.86);
  --panel-strong: rgba(13, 25, 39, 0.98);
  --border: rgba(167, 193, 214, 0.16);
  --text: #eef6fc;
  --muted: #90a6bb;
  --accent: #ffb84d;
  --accent-deep: #d87d14;
  --success: #7be0a3;
  --danger: #ff7070;
  --square-light: #f0dcc2;
  --square-dark: #93714d;
  --highlight: rgba(255, 184, 77, 0.88);
  --selection: rgba(77, 163, 255, 0.8);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 184, 77, 0.18), transparent 24%),
    radial-gradient(circle at top right, rgba(84, 179, 255, 0.18), transparent 22%),
    linear-gradient(180deg, #071019 0%, #0d1721 48%, #0a131c 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 92%);
  pointer-events: none;
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 28px;
}

.hero-copy,
.hero-card,
.board-panel,
.control-card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  background: linear-gradient(145deg, rgba(14, 25, 36, 0.92), rgba(8, 16, 24, 0.82));
  border-radius: var(--radius-xl);
  padding: 32px;
}

.eyebrow,
.toolbar-label,
.card-label {
  margin: 0 0 10px;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-size: clamp(2.6rem, 4vw, 4.5rem);
  line-height: 0.95;
  margin: 0;
}

.hero-text {
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.75;
  margin: 18px 0 22px;
}

.hero-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-pills span,
.badge {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
  color: #d7e6f3;
  font-size: 0.92rem;
}

.hero-card {
  background:
    linear-gradient(140deg, rgba(255, 184, 77, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(13, 24, 37, 0.95), rgba(10, 19, 29, 0.88));
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.score-name {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.hero-card strong {
  font-size: 1.35rem;
}

.card-footnote {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.6;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.72fr);
  gap: 24px;
  align-items: start;
}

.board-panel {
  background: linear-gradient(180deg, rgba(13, 24, 36, 0.95), rgba(9, 17, 27, 0.9));
  border-radius: var(--radius-xl);
  padding: 24px;
}

.board-toolbar,
.card-header,
.button-row,
.status-strip,
.timers,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-toolbar h2,
.card-header h3 {
  margin: 0;
  font-size: 1.35rem;
}

.ghost-btn,
.primary-btn,
.secondary-btn,
select,
input {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font: inherit;
}

.ghost-btn,
.secondary-btn,
select,
input {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.ghost-btn,
.primary-btn,
.secondary-btn {
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.ghost-btn:hover,
.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  padding: 12px 16px;
}

input {
  width: 100%;
  padding: 12px 14px;
}

.primary-btn {
  background: linear-gradient(180deg, #ffc260, #f39d2f);
  color: #1d1407;
  border: 0;
  padding: 13px 18px;
  font-weight: 800;
}

.secondary-btn {
  padding: 13px 18px;
}

.timers {
  margin: 18px 0;
}

.timer-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.timer-card span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.timer-card strong {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-size: 1.6rem;
}

.timer-card--active {
  border-color: rgba(255, 184, 77, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 184, 77, 0.28);
}

.timer-card--accent {
  background:
    linear-gradient(160deg, rgba(84, 179, 255, 0.12), transparent 55%),
    rgba(255, 255, 255, 0.05);
}

.board-frame {
  position: relative;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 12px rgba(255, 255, 255, 0.03),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.square {
  position: relative;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1;
  user-select: none;
  cursor: pointer;
}

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

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

.square::before,
.square::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.square--selected::before {
  opacity: 1;
  box-shadow: inset 0 0 0 4px var(--selection);
}

.square--move::after {
  opacity: 1;
  inset: auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(18, 25, 33, 0.28);
}

.square--capture::after {
  opacity: 1;
  border: 4px solid rgba(18, 25, 33, 0.24);
  border-radius: 999px;
  inset: 10px;
}

.piece {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.piece--w {
  color: #fffef8;
  text-shadow:
    -1px -1px 0 rgba(19, 26, 33, 0.75),
    1px -1px 0 rgba(19, 26, 33, 0.75),
    -1px 1px 0 rgba(19, 26, 33, 0.75),
    1px 1px 0 rgba(19, 26, 33, 0.75);
}

.piece--b {
  color: #111f2e;
  text-shadow:
    -1px -1px 0 rgba(255, 248, 236, 0.28),
    1px -1px 0 rgba(255, 248, 236, 0.28),
    -1px 1px 0 rgba(255, 248, 236, 0.28),
    1px 1px 0 rgba(255, 248, 236, 0.28);
}

.last-move {
  box-shadow: inset 0 0 0 999px rgba(255, 211, 112, 0.18);
}

.board-legend {
  position: absolute;
  pointer-events: none;
  color: rgba(238, 246, 252, 0.74);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.board-legend--files {
  left: 0;
  right: 0;
  bottom: -28px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  text-align: center;
}

.board-legend--ranks {
  top: 0;
  bottom: 0;
  left: -24px;
  display: grid;
  grid-template-rows: repeat(8, minmax(0, 1fr));
  align-items: center;
}

.status-strip {
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  line-height: 1.6;
}

#thinking-indicator {
  color: var(--accent);
}

.side-panel {
  display: grid;
  gap: 18px;
}

.control-card {
  background: linear-gradient(180deg, rgba(16, 28, 42, 0.88), rgba(10, 18, 28, 0.92));
  border-radius: var(--radius-lg);
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field span {
  color: #d9e7f2;
  font-weight: 600;
}

select {
  width: 100%;
  padding: 12px 14px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.mode-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.mode-chip:hover {
  transform: translateY(-1px);
}

.mode-chip--active {
  background: linear-gradient(180deg, rgba(255, 184, 77, 0.18), rgba(255, 184, 77, 0.08));
  border-color: rgba(255, 184, 77, 0.6);
}

.mode-section {
  margin-top: 18px;
}

.mode-note {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.info-pill {
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #dff0ff;
  background: rgba(84, 179, 255, 0.15);
  border: 1px solid rgba(84, 179, 255, 0.24);
}

.info-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-tile {
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.info-tile strong {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
}

.button-row {
  margin-top: 18px;
}

.button-row button {
  flex: 1;
}

.move-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.move-list li {
  display: grid;
  grid-template-columns: 46px 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.move-index {
  color: var(--muted);
}

.move-cell {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
}

.tips-list {
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
  margin: 18px 0 0;
}

.tips-list li + li {
  margin-top: 4px;
}

@media (max-width: 980px) {
  .hero,
  .app-layout {
    grid-template-columns: 1fr;
  }

  .hero-card {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 18px;
  }

  .hero-copy,
  .hero-card,
  .board-panel,
  .control-card {
    padding: 18px;
    border-radius: 22px;
  }

  .board-toolbar,
  .toolbar-actions,
  .status-strip,
  .timers,
  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-toggle,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .board-toolbar h2 {
    font-size: 1.15rem;
  }

  .board-legend--files {
    bottom: -24px;
    font-size: 0.72rem;
  }

  .board-legend--ranks {
    left: -18px;
    font-size: 0.72rem;
  }

  .move-list li {
    grid-template-columns: 38px 1fr 1fr;
  }
}
