/* Giao diện phòng luyện khai cuộc */

:root {
  color-scheme: dark;
  --bg: #312e2b;
  --panel: #262421;
  --muted: #c3c2c1;
  --green: #81b64c;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: white;
  font:
    16px/1.5 system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  color: white;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #b5df83;
  outline-offset: 4px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
.top {
  height: 80px;
  border-bottom: 1px solid #ffffff0d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5vw;
  background: #262421;
}
.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  background: var(--green);
  color: #213318;
  padding: 2px 12px;
  border-radius: 10px;
  font-size: 32px;
}
.sub {
  color: var(--muted);
  font-size: 13px;
}
.top button,
.secondary {
  background: #ffffff0c;
  border: 1px solid #ffffff12;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 650;
}
.primary {
  background: var(--green);
  box-shadow: 0 4px 0 #45753c;
  border-radius: 9px;
  padding: 13px 20px;
  font-weight: 800;
  font-size: 16px;
}
.primary:hover {
  background: #a3d160;
}
main {
  max-width: 1180px;
  margin: auto;
  padding: 38px 28px 60px;
}
h1 {
  font-size: 38px;
  letter-spacing: -1.4px;
  line-height: 1.2;
  margin: 12px 0;
}
h2 {
  font-size: 21px;
  margin: 0;
}
p {
  color: var(--muted);
}
.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #a9d779;
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 34px;
}
.counter {
  background: var(--panel);
  border: 1px solid #ffffff0c;
  border-radius: 12px;
  padding: 16px 24px;
  color: var(--muted);
  font-size: 14px;
}
.counter strong {
  color: #a9d779;
  font-size: 27px;
  margin-right: 8px;
}
.group {
  margin: 30px 0;
}
.group-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 15px;
}
.group-title span {
  font-size: 12px;
  color: var(--muted);
  background: #ffffff09;
  padding: 3px 9px;
  border-radius: 20px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid #ffffff0c;
  border-radius: 12px;
  padding: 15px;
  text-align: left;
  transition:
    transform 0.18s,
    border-color 0.18s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--green);
}
.card h3 {
  font-size: 17px;
  margin: 12px 0 4px;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.mini {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 5px;
  overflow: hidden;
}
.mini > div {
  display: flex;
  align-items: center;
}
.mini svg {
  width: 100%;
  height: 100%;
}
.light {
  background: #eeeed2;
  color: #769656;
}
.dark {
  background: #769656;
  color: #eeeed2;
}
.mode {
  max-width: 700px;
  margin: 25px auto;
  text-align: center;
}
.mode-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 30px 0;
}
.mode-option {
  padding: 25px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--panel);
}
.mode-option.active {
  border-color: var(--green);
  background: #35412b;
}
.mode-option b {
  display: block;
  font-size: 18px;
}
.mode-option span {
  font-size: 42px;
}
.mode-option small {
  color: var(--muted);
}
.study {
  display: grid;
  grid-template-columns: minmax(0, 660px) minmax(290px, 1fr);
  gap: 26px;
  align-items: start;
}
.player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 13px;
  font-size: 14px;
}
.player.bottom {
  margin: 14px 0 0;
}
.player b {
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: #45423e;
  font-size: 23px;
}
.board {
  position: relative;
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  border-radius: 7px;
  box-shadow: 0 10px 30px #0002;
}
.squares {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  height: 100%;
  overflow: hidden;
  border-radius: 7px;
}
.square {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 0;
  aspect-ratio: 1;
}
.square.mark.light {
  background: #f7f769;
}
.square.mark.dark {
  background: #baca2b;
}
.coord {
  position: absolute;
  font-weight: 750;
  font-size: clamp(10px, 1.3vw, 15px);
  z-index: 1;
}
.rank {
  left: 5%;
  top: 1%;
}
.file {
  right: 5%;
  bottom: 0;
}
.dot:after {
  content: "";
  position: absolute;
  width: 27%;
  height: 27%;
  background: #0003;
  left: 36.5%;
  top: 36.5%;
  border-radius: 50%;
}
.capture:after {
  content: "";
  position: absolute;
  inset: 3%;
  border: 7px solid #0003;
  border-radius: 50%;
}
.pieces,
.arrows,
.badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  transition:
    left 0.2s ease,
    top 0.2s ease;
  filter: drop-shadow(0 2px 1px #0003);
}
.piece svg {
  width: 100%;
  height: 100%;
}
.piece.dragging {
  transition: none;
  z-index: 10;
}
.arrows {
  width: 100%;
  height: 100%;
  z-index: 12;
}
.badges {
  z-index: 13;
}
.badge {
  position: absolute;
  width: 6%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fa412d;
  color: white;
  display: grid;
  place-items: center;
  font-size: clamp(14px, 2.2vw, 26px);
  font-weight: 900;
  transform: translate(-10%, -10%);
  box-shadow: 0 2px 5px #0003;
}
.badge.good {
  background: #81b64c;
  font-size: 20px;
}
.panel {
  background: var(--panel);
  border: 1px solid #ffffff0c;
  border-radius: 12px;
  overflow: hidden;
}
.panel-head,
.panel-body {
  padding: 22px;
}
.panel-head {
  border-bottom: 1px solid #ffffff10;
}
.tag {
  font-size: 12px;
  color: #acd984;
  display: block;
  margin-top: 6px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.progress {
  height: 7px;
  background: #ffffff13;
  border-radius: 10px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: var(--green);
  transition: width 0.25s;
}
.moves {
  max-height: 250px;
  min-height: 100px;
  overflow: auto;
  margin: 20px -8px;
}
.move-row {
  display: grid;
  grid-template-columns: 35px 1fr 1fr;
  align-items: center;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 14px;
}
.move-row:nth-child(odd) {
  background: #ffffff05;
}
.move-row > span {
  color: #8e8b87;
}
.move-row button {
  padding: 6px;
  background: transparent;
  text-align: left;
  border-radius: 4px;
}
.move-row button.current {
  background: #81b64c33;
  color: #bce595;
}
.move-row small {
  color: #aaa69f;
  margin-left: 7px;
}
.feedback {
  background: #333c2b;
  border-left: 3px solid var(--green);
  padding: 13px;
  border-radius: 6px;
  font-size: 14px;
  min-height: 70px;
}
.feedback.wrong {
  background: #482f29;
  border-color: #fa412d;
}
.feedback strong {
  display: block;
  margin-bottom: 3px;
}
.feedback small {
  color: var(--muted);
}
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin: 15px 0;
}
.switch input {
  accent-color: var(--green);
  width: 17px;
  height: 17px;
}
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.controls .primary {
  grid-column: 1/-1;
}
.review {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.review button {
  flex: 1;
}
.back {
  background: none;
  color: var(--muted);
  padding: 0;
  margin-bottom: 22px;
}
.finish {
  background: #33422a;
  border: 1px solid #81b64c55;
  padding: 20px;
  border-radius: 10px;
  margin-top: 16px;
  text-align: center;
}
.finish h2 {
  font-size: 22px;
}
.finish button {
  margin: 6px 2px;
}
.hidden {
  display: none !important;
}
footer {
  text-align: center;
  color: #99948e;
  font-size: 11px;
  margin-top: 40px;
}
.empty {
  color: #a29c93;
  font-size: 13px;
  padding: 20px 8px;
}
.note {
  color: #a49e96;
  font-size: 12px;
  text-align: center;
  margin-top: 15px;
}
@media (max-width: 850px) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .study {
    grid-template-columns: 1fr;
    max-width: 660px;
    margin: auto;
  }
  .panel {
    width: 100%;
  }
  .moves {
    max-height: 190px;
  }
  .top {
    padding: 0 20px;
  }
  .counter {
    display: none;
  }
}
@media (max-width: 480px) {
  main {
    padding: 25px 12px 35px;
  }
  h1 {
    font-size: 30px;
  }
  .top {
    height: 68px;
  }
  .brand {
    font-size: 18px;
  }
  .brand .sub {
    display: none;
  }
  .cards {
    gap: 10px;
  }
  .card {
    padding: 10px;
  }
  .card h3 {
    font-size: 15px;
  }
  .mode-options {
    gap: 8px;
  }
  .mode-option {
    padding: 18px 5px;
  }
  .mode-option b {
    font-size: 15px;
  }
  .panel-body,
  .panel-head {
    padding: 17px;
  }
  .badge {
    font-size: 17px;
  }
  .coord {
    font-size: 11px;
  }
  .intro {
    margin-bottom: 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

html {
  -webkit-text-size-adjust: 100%;
}
body {
  min-width: 280px;
}
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.square {
  touch-action: none;
}
.study > * {
  min-width: 0;
}
.board {
  width: 100%;
}
.mode-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.mode {
  max-width: 850px;
}
.learning-board {
  touch-action: pan-y;
}
.learning-board .square {
  touch-action: pan-y;
}
.lesson {
  margin-top: 16px;
  background: #262421;
  border: 1px solid #81b64c44;
  border-radius: 12px;
  padding: 18px;
}
.lesson h2 {
  margin: 7px 0;
  font-size: 22px;
}
.lesson h2 small {
  color: #c3c2c1;
  font-weight: 500;
  font-size: 16px;
}
.lesson p {
  margin: 6px 0 16px;
  font-size: 14px;
  min-height: 42px;
}
.lesson-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px;
}
.lesson-actions button {
  min-height: 48px;
}
.card-foot {
  flex-wrap: wrap;
  gap: 3px 8px;
}
@media (max-width: 600px) {
  .mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mode-option {
    min-height: 150px;
  }
  .top {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }
  .top button {
    font-size: 12px;
    padding: 10px;
    min-height: 44px;
  }
  .brand {
    font-size: 16px;
    gap: 8px;
  }
  .brand-icon {
    font-size: 27px;
    padding: 2px 9px;
  }
  main {
    padding: 20px max(10px, env(safe-area-inset-right))
      calc(30px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }
  .study {
    gap: 18px;
  }
  .study .board {
    border-radius: 4px;
  }
  .back {
    min-height: 44px;
    margin-bottom: 10px;
  }
  .group-title h2 {
    font-size: 19px;
  }
  .counter {
    display: none;
  }
  .panel-body > .switch {
    min-height: 44px;
    margin: 4px 0;
  }
  .controls button,
  .review button,
  .finish button {
    min-height: 46px;
  }
  .lesson {
    padding: 14px;
    margin-top: 10px;
  }
  .lesson p {
    min-height: 0;
  }
  .lesson-actions {
    gap: 9px;
  }
  .lesson-actions button {
    font-size: 15px;
    padding: 10px;
  }
  .player {
    margin-bottom: 8px;
  }
  .player.bottom {
    margin-top: 8px;
  }
  .intro p {
    font-size: 14px;
  }
  .move-row button {
    min-height: 42px;
  }
  .note {
    line-height: 1.6;
  }
  .card h3 {
    overflow-wrap: anywhere;
  }
  .mode-option small {
    font-size: 11px;
  }
  .finish button {
    max-width: 100%;
  }
}
@media (max-width: 350px) {
  h1 {
    font-size: 26px;
  }
  .eyebrow {
    font-size: 10px;
    letter-spacing: 1.3px;
  }
  .brand {
    font-size: 14px;
  }
  .brand-icon {
    display: none;
  }
  .card-foot {
    font-size: 11px;
  }
  .group-title {
    gap: 7px;
  }
  .group-title h2 {
    font-size: 17px;
  }
}

/* Board appearance follows the supplied reference. */
.board,
.study .board,
.squares,
.mini {
  border-radius: 0;
  box-shadow: none;
}
.square {
  outline-offset: -3px;
}
.square.light,
.mini .light {
  background: #eeeed2;
  color: #769656;
}
.square.dark,
.mini .dark {
  background: #769656;
  color: #eeeed2;
}
.square.mark.light {
  background: #f7f769;
}
.square.mark.dark {
  background: #baca2b;
}
.piece {
  filter: none;
}
.coord {
  font-family: Arial, sans-serif;
  font-weight: 400;
  font-size: clamp(10px, 2.6vw, 16px);
  line-height: 1.15;
}
.coord.rank {
  left: 5%;
  top: 7%;
}
.coord.file {
  right: 5%;
  bottom: 1%;
}
@media (max-width: 600px) {
  .study .board {
    width: calc(100% + 20px);
    margin-left: -10px;
  }
  .coord {
    font-size: clamp(10px, 2.5vw, 15px);
  }
}
