.shogi-demo {
  --shogi-ink: #26372f;
  --shogi-board: #dfbb79;
  --shogi-board-line: #72512f;
  clear: both;
  margin: 3rem 0;
  padding: 1.5rem;
  border-block: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

.shogi-demo__heading,
.shogi-demo__settings,
.shogi-demo__layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.shogi-demo__heading {
  margin-bottom: 1rem;
}

.shogi-demo__heading h2 {
  margin: 0;
}

.shogi-demo__eyebrow {
  margin: 0 0 0.2rem;
  color: #73d1b2;
  font-size: 0.76rem;
  font-weight: 700;
}

.shogi-demo__settings {
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.shogi-demo__settings fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0;
  margin: 0;
  border: 0;
}

.shogi-demo__settings legend {
  margin-bottom: 0.35rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

.shogi-demo__settings label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.shogi-demo__settings input,
.shogi-demo__settings select {
  accent-color: #24745e;
}

.shogi-demo__settings select {
  min-height: 38px;
  padding: 0.3rem 0.55rem;
}

.shogi-demo__status {
  min-height: 1.6rem;
  margin: 0.75rem 0;
  color: #d4f2e7;
  font-weight: 600;
}

.shogi-demo__layout {
  display: grid;
  grid-template-areas:
    "board gote"
    "board sente";
  grid-template-columns: minmax(0, 1fr) 150px;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  gap: 0.75rem 1rem;
}

.shogi-demo__hand {
  min-width: 0;
}

#shogi-gote-hand-panel {
  grid-area: gote;
}

#shogi-sente-hand-panel {
  grid-area: sente;
}

.shogi-demo__hand h3,
.shogi-demo__notation h3 {
  margin-bottom: 0.55rem;
  font-size: 1rem;
}

.shogi-demo__hand-pieces {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.4rem;
}

.shogi-demo__hand-piece {
  min-width: 3.8rem;
  min-height: 2.6rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1rem;
}

.shogi-demo__hand-piece:disabled {
  cursor: default;
  opacity: 0.52;
}

.shogi-demo__hand-piece.is-selected {
  outline: 2px solid #73d1b2;
  outline-offset: 1px;
}

.shogi-demo__empty-hand {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
}

.shogi-demo__board-wrap {
  grid-area: board;
  min-width: 0;
  width: 100%;
  max-width: 560px;
  justify-self: center;
}

.shogi-demo__board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--shogi-board-line);
  background: var(--shogi-board);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
}

.shogi-demo__square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--shogi-board-line);
  border-radius: 0;
  background: var(--shogi-board);
  color: var(--shogi-ink);
  cursor: pointer;
  line-height: 1;
}

.shogi-demo__square:focus-visible {
  z-index: 2;
  outline: 3px solid #21745f;
  outline-offset: -3px;
}

.shogi-demo__square.is-selected {
  background: #f2dcaa;
  box-shadow: inset 0 0 0 3px #246e5a;
}

.shogi-demo__square.is-last-move {
  background: #e9cd91;
}

.shogi-demo__square.is-target::after {
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(36, 110, 90, 0.68);
  content: "";
}

.shogi-demo__square.is-capture::after {
  position: absolute;
  inset: 8%;
  border: 3px solid rgba(157, 61, 42, 0.8);
  border-radius: 50%;
  content: "";
}

.shogi-demo__piece {
  display: grid;
  place-items: center;
  width: 78%;
  height: 84%;
  clip-path: polygon(50% 0, 100% 24%, 89% 100%, 11% 100%, 0 24%);
  background: #f4dfad;
  color: #27251d;
  font-family: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.9rem, 2.1vw, 2rem);
  font-weight: 700;
  pointer-events: none;
}

.shogi-demo__piece.is-gote {
  transform: rotate(180deg);
}

.shogi-demo__files {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  padding-top: 0.2rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
  text-align: center;
}

.shogi-demo__notation {
  max-width: 620px;
  margin: 1.25rem 0 0 auto;
}

.shogi-demo__notation ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem 1rem;
  max-height: 9rem;
  padding-left: 1.5rem;
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.78);
  font-variant-numeric: tabular-nums;
}

.shogi-demo__note {
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.83rem;
}

.shogi-demo__promotion {
  width: min(92vw, 380px);
  padding: 1.4rem;
  border: 1px solid #507b69;
  background: #f5f0e3;
  color: #25352d;
}

.shogi-demo__promotion::backdrop {
  background: rgba(7, 17, 14, 0.68);
}

.shogi-demo__promotion h2 {
  font-size: 1.25rem;
}

.shogi-demo__promotion form > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

@media (max-width: 760px) {
  .shogi-demo {
    padding: 1.1rem 0;
  }

  .shogi-demo__layout {
    display: flex;
    flex-direction: column;
  }

  .shogi-demo__board-wrap {
    order: 0;
    width: min(100%, 560px);
    align-self: center;
  }

  .shogi-demo__hand {
    flex-basis: auto;
  }

  .shogi-demo__notation {
    margin-left: 0;
  }
}

@media (max-width: 440px) {
  .shogi-demo__heading {
    align-items: flex-start;
  }

  .shogi-demo__heading .btn {
    flex: 0 0 auto;
    padding: 0.65rem 0.8rem;
  }

  .shogi-demo__settings fieldset {
    gap: 0.6rem;
  }

  .shogi-demo__settings fieldset label {
    font-size: 0.88rem;
  }

  .shogi-demo__piece {
    width: 88%;
    height: 88%;
    font-size: clamp(0.86rem, 5.8vw, 1.45rem);
  }

  .shogi-demo__notation ol {
    grid-template-columns: 1fr;
  }
}
