:root {
  --ink: #243328;
  --muted: #6e7a70;
  --cream: #f7f4ed;
  --paper: #fffdf8;
  --line: #e2e2d8;
  --leaf: #416b56;
  --leaf-dark: #2f5541;
  --leaf-soft: #e5eee5;
  --gold: #d2a04d;
  --light-square: #eeeed2;
  --dark-square: #769656;
  --shadow: 0 18px 50px rgba(41, 63, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgba(215, 229, 211, 0.48), transparent 25rem),
    radial-gradient(circle at 90% 85%, rgba(239, 224, 191, 0.38), transparent 24rem),
    var(--cream);
  font-family: "DM Sans", Arial, sans-serif;
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.04em;
  font-size: 19px;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--leaf);
  font-size: 23px;
  line-height: 1;
}

.free-pill {
  padding: 7px 12px;
  border: 1px solid #d7dfd5;
  border-radius: 20px;
  color: var(--leaf);
  background: rgba(255, 255, 255, 0.52);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  min-height: calc(100vh - 83px);
  padding: 40px 20px 70px;
}

.screen {
  width: min(800px, 100%);
  margin: auto;
  animation: enter 320ms ease both;
}

.welcome {
  text-align: center;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--leaf);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(48px, 7vw, 70px);
  letter-spacing: -0.07em;
  line-height: 0.98;
}

em {
  color: var(--leaf);
  font-weight: inherit;
}

.intro {
  max-width: 520px;
  margin: 22px auto 34px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.choice-grid {
  display: grid;
  gap: 14px;
}

.home-choices {
  max-width: 590px;
  margin: 0 auto;
}

.choice-card,
.color-card {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 19px 21px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.84);
  box-shadow: 0 5px 0 rgba(49, 76, 59, 0.04);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.choice-card:hover,
.color-card:hover,
.opening-card:hover,
.variation-card:hover {
  border-color: #a9bda9;
  box-shadow: 0 12px 26px rgba(45, 76, 57, 0.1);
  transform: translateY(-3px);
}

.choice-card.featured {
  border-color: var(--leaf);
  color: white;
  background: var(--leaf);
}

.card-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--leaf);
  background: var(--leaf-soft);
  font-size: 24px;
}

.featured .card-icon {
  color: white;
  background: rgba(255, 255, 255, 0.17);
}

.card-copy {
  display: grid;
  gap: 4px;
}

strong {
  font-size: 16px;
}

small {
  color: var(--muted);
  font-size: 13px;
}

.featured small {
  color: rgba(255, 255, 255, 0.7);
}

.arrow {
  margin-left: auto;
  font-size: 20px;
}

.footnote {
  margin-top: 30px;
  color: #89948b;
  font-size: 13px;
}

.footnote span {
  color: var(--gold);
}

.back-button {
  margin: 0 0 34px;
  padding: 0;
  border: 0;
  color: var(--leaf);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.screen:not(.welcome) .intro {
  margin-left: 0;
}

.color-choices {
  grid-template-columns: 1fr 1fr;
}

.color-card {
  display: grid;
  min-height: 185px;
  grid-template-columns: auto 1fr auto;
  padding: 27px;
}

.color-card span:nth-child(2) {
  display: grid;
  gap: 7px;
}

.large-piece {
  font-family: Georgia, serif;
  font-size: 64px;
  line-height: 1;
}

.white-piece {
  color: #fdfcf6;
  filter: drop-shadow(0 1px 1px #526d5a);
  -webkit-text-stroke: 1px #526d5a;
}

.dark-card {
  color: #fff;
  background: var(--ink);
}

.dark-card small {
  color: #a9b5ad;
}

.opening-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.opening-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.opening-toolbar input {
  flex: 1;
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.88);
  font: inherit;
  font-size: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.opening-toolbar input:focus {
  border-color: #9ab39d;
  box-shadow: 0 0 0 4px rgba(65, 107, 86, 0.09);
}

.opening-toolbar span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.opening-card {
  display: grid;
  min-height: 180px;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.opening-card .opening-piece {
  color: var(--leaf);
  font-family: Georgia, serif;
  font-size: 36px;
}

.opening-card small {
  display: block;
  margin-top: 6px;
  line-height: 1.45;
}

.opening-card .opening-arrow {
  align-self: end;
  color: var(--leaf);
  font-size: 13px;
  font-weight: 700;
}

.variation-list {
  display: grid;
  gap: 11px;
}

.variation-card {
  display: flex;
  align-items: center;
  gap: 17px;
  width: 100%;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 248, 0.88);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.variation-number {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--leaf);
  background: var(--leaf-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.variation-copy {
  display: grid;
  gap: 4px;
}

.variation-copy > span {
  color: var(--leaf);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.trainer {
  width: min(1100px, 100%);
  margin: auto;
  animation: enter 320ms ease both;
}

.trainer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.trainer-top .back-button {
  margin: 0;
}

.move-progress {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.trainer-grid {
  display: grid;
  grid-template-columns: minmax(440px, 610px) minmax(290px, 1fr);
  gap: 28px;
  align-items: stretch;
}

.board-wrap {
  overflow: hidden;
  border: 1px solid rgba(67, 94, 76, 0.18);
  border-radius: 9px;
  background: var(--light-square);
  box-shadow: 0 13px 34px rgba(41, 63, 49, 0.14);
}

.chess-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 7px;
  background: var(--light-square);
}

.square {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  transition: background 180ms ease;
}

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

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

.square.highlight-from {
  background: #bbcb69;
}

.square.highlight-to {
  background: #f5f682;
}

.coordinate {
  display: none;
}

.coordinate.file {
  right: 4px;
  bottom: 2px;
}

.coordinate.rank {
  top: 3px;
  left: 4px;
}

.piece {
  position: absolute;
  z-index: 3;
  display: grid;
  width: 12.5%;
  height: 12.5%;
  place-items: center;
  pointer-events: none;
  transition: transform 420ms cubic-bezier(0.2, 0.84, 0.25, 1);
}

.piece-art {
  width: 94%;
  height: 94%;
  overflow: visible;
}

.piece.white {
  color: #f8f8ed;
  --piece-stroke: #333333;
}

.piece.black {
  color: #333333;
  --piece-stroke: #333333;
}

.lesson-card {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.84);
  box-shadow: var(--shadow);
}

.lesson-card h2 {
  margin: 0 0 8px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 34px;
  letter-spacing: -0.05em;
  line-height: 1;
}

.lesson-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.lesson-variation {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 5px 8px;
  border-radius: 20px;
  color: var(--leaf);
  background: var(--leaf-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.move-lesson {
  margin-top: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.move-number,
.notation-label {
  color: var(--leaf);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.move-lesson h3 {
  margin: 8px 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 23px;
  letter-spacing: -0.04em;
}

.move-lesson p {
  min-height: 62px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.notation-wrap {
  flex: 1;
  margin: 20px 0;
}

.notation-label {
  display: block;
  margin-bottom: 10px;
}

.notation {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.notation span {
  min-width: 33px;
  padding: 5px 7px;
  border-radius: 7px;
  color: var(--muted);
  background: #f0f1ea;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.notation .active {
  color: white;
  background: var(--leaf);
}

.trainer-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
}

.secondary-button,
.next-button {
  min-height: 47px;
  border-radius: 11px;
  font-weight: 700;
}

.secondary-button {
  padding: 0 13px;
  border: 1px solid var(--line);
  color: var(--leaf);
  background: transparent;
  font-size: 13px;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.next-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  color: white;
  background: var(--leaf);
  font-size: 14px;
  transition: background 180ms ease;
}

.next-button:hover {
  background: var(--leaf-dark);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding-top: 20px;
  }

  .trainer-grid {
    grid-template-columns: 1fr;
  }

  .trainer {
    max-width: 610px;
  }

  .lesson-card {
    min-height: 390px;
  }
}

@media (max-width: 580px) {
  .site-header {
    width: min(100% - 26px, 1180px);
    padding-top: 15px;
  }

  .app-shell {
    min-height: calc(100vh - 70px);
    padding: 22px 13px 40px;
  }

  .color-choices,
  .opening-list {
    grid-template-columns: 1fr;
  }

  .color-card {
    min-height: 120px;
  }

  .opening-card {
    min-height: 135px;
  }

  .lesson-card {
    min-height: 370px;
    padding: 21px;
  }
}
