:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --surface: #fffef9;
  --ink: #27283a;
  --muted: #676775;
  --line: #dedbd2;
  --purple: #6150a4;
  --purple-dark: #493b82;
  --lavender: #eeebf8;
  --green: #35634e;
  --green-pale: #eaf2e9;
  --warm: #faf0df;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: radial-gradient(ellipse at 92% 8%, #e7e2f0 0, transparent 38%), var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled,
fieldset:disabled button {
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #2c5eae;
  outline-offset: 4px;
}

button:disabled {
  opacity: 0.47;
}

fieldset:disabled .cell {
  opacity: 0.64;
}

.page-shell {
  width: min(1080px, calc(100% - 64px));
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 86px;
  border-bottom: 1px solid var(--line);
}

.site-sign {
  color: var(--purple-dark);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.site-sign > span {
  margin-right: 7px;
  font-size: 21px;
  vertical-align: -2px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 2px 8px 10px;
  color: var(--ink);
  font-size: 13px;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 31px 0 25px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 40px;
  font-weight: 650;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

h1 > span {
  display: inline-block;
  margin-left: 13px;
  color: var(--purple);
  font-size: 23px;
  vertical-align: 5px;
}

.intro-copy {
  margin-bottom: 2px;
  color: var(--purple-dark);
  font-size: 18px;
  line-height: 1.65;
}

.intro-copy > span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.17fr) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.play-panel,
.side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}

.play-panel {
  padding: 24px;
  box-shadow: 0 8px 26px #38314107;
}

.board-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-heading h2 {
  margin-bottom: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.phase-label {
  flex-shrink: 0;
  padding: 5px 11px;
  border: 1px solid #d9d2eb;
  border-radius: 30px;
  color: var(--purple-dark);
  background: var(--lavender);
  font-size: 12px;
}

.phase-label[data-phase="won"] {
  border-color: #b7cdb9;
  background: var(--green-pale);
  color: var(--green);
}

.phase-label[data-phase="stuck"] {
  border-color: #ddc8a5;
  background: var(--warm);
  color: #775621;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 19px 0 8px;
  padding: 12px 0;
  border-top: 1px solid #ebe7df;
  border-bottom: 1px solid #ebe7df;
}

.metrics > p {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 0;
}

.metrics > p + p {
  border-left: 1px solid var(--line);
}

.metrics strong {
  color: var(--purple-dark);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  width: min(100%, 340px);
  margin: 15px auto 18px;
  padding: 4px;
  border-radius: 18px;
  background-image: radial-gradient(#bdb5ce 0.7px, transparent 0.7px);
  background-size: 14px 14px;
}

.cell,
.board-space {
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
}

.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  padding: 3px;
  border: 1px solid #d1cbdc;
  border-radius: 50%;
  background: #f5f2f9;
  color: #787082;
  line-height: 1.1;
}

.cell-symbol {
  font-size: 23px;
  line-height: 1;
}

.cell-word {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
}

.cell.is-occupied {
  border: 1px solid #64529a;
  background: var(--purple);
  color: white;
  box-shadow: inset 0 -4px 0 #3e30622b, 0 3px 0 #d7d0e4;
}

.cell.is-selected {
  outline: 3px solid var(--purple-dark);
  outline-offset: 2px;
  background: #443477;
}

.cell.is-landing {
  border: 2px dashed var(--green);
  background: var(--green-pale);
  color: #244f3a;
}

.cell:focus-visible {
  outline: 3px solid #2c5eae;
  outline-offset: 3px;
}

.cell.is-selected:focus-visible {
  outline: 3px solid #2c5eae;
  box-shadow: 0 0 0 2px var(--surface), inset 0 -4px 0 #3e30622b;
}

.cell:disabled {
  opacity: 1;
}

.move-feedback {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 86px;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--lavender);
}

.feedback-symbol {
  flex: 0 0 23px;
  color: var(--purple-dark);
  font-size: 24px;
  line-height: 1.2;
}

.move-feedback h3 {
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.move-feedback p {
  margin-bottom: 0;
  color: #585269;
  font-size: 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.move-feedback[data-phase="won"] {
  background: var(--green-pale);
}

.move-feedback[data-phase="stuck"] {
  background: var(--warm);
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.button-primary {
  background: var(--purple);
  color: white;
}

.button-secondary {
  border-color: #d6d0de;
  background: var(--surface);
  color: var(--purple-dark);
}

@media (hover: hover) {
  .button-primary:hover:enabled {
    background: var(--purple-dark);
  }

  .button-secondary:hover:enabled,
  .board-choice:hover:enabled {
    background: #f3eff9;
  }

  .cell:hover:enabled {
    border-color: var(--purple-dark);
  }
}

.board-caption {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.side-panel {
  overflow: hidden;
}

.side-section {
  padding: 23px;
}

.side-section + .side-section {
  border-top: 1px solid var(--line);
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 15px;
  font-weight: 600;
}

.small-note {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
}

.board-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 15px;
}

.board-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 48px;
  padding: 8px;
  border: 1px solid #ded8e5;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.board-choice > span {
  color: var(--muted);
  font-size: 12px;
}

.board-choice[aria-pressed="true"] {
  border: 2px solid var(--purple);
  background: var(--lavender);
  color: var(--purple-dark);
  font-weight: 600;
}

.section-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.invitation-section {
  background: #fbfaf5;
}

.section-symbol {
  color: var(--purple);
  font-size: 21px;
}

.share-button {
  width: 100%;
  margin-top: 13px;
}

.invitation {
  margin-top: 14px;
}

.invitation label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.invitation input {
  display: block;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid #cfc7dc;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 13px;
}

.invitation .button {
  width: 100%;
  margin-top: 8px;
}

.empty-trail {
  margin: 16px 0 0;
  padding-left: 13px;
  border-left: 2px solid #ddd6e8;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.move-log {
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}

.move-log:empty {
  display: none;
}

.move-log > li {
  position: relative;
  padding: 10px 0 10px 29px;
  border-top: 1px solid #eeebe4;
  font-size: 12px;
}

.move-log > li:first-child {
  border-top: 0;
}

.log-step {
  position: absolute;
  top: 11px;
  left: 0;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--purple-dark);
  text-align: center;
  line-height: 21px;
}

.log-route,
.log-count {
  display: block;
}

.log-count {
  margin-top: 3px;
  color: var(--muted);
}

.link-notice {
  margin: 0 0 18px;
  padding: 12px 16px;
  border: 1px solid #d8c9a9;
  border-radius: 12px;
  background: var(--warm);
  color: #6c5024;
  font-size: 13px;
}

.confirm-region {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 20px 23px;
  border: 2px solid #a28bc7;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 16px #56437a0a;
}

.confirm-region h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.confirm-region p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.confirm-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.page-footer {
  padding: 22px 0 25px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 800px) {
  .page-shell {
    width: min(680px, calc(100% - 40px));
  }

  .intro {
    align-items: flex-start;
    gap: 13px;
  }

  .intro-copy {
    max-width: 285px;
    font-size: 16px;
  }

  h1 {
    font-size: 33px;
    white-space: nowrap;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .board {
    width: min(100%, 310px);
  }

  .confirm-region {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .confirm-actions > .button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: calc(100% - 28px);
  }

  .page-header {
    min-height: 59px;
  }

  .site-sign {
    font-size: 12px;
    letter-spacing: 0.03em;
  }

  .site-sign > span {
    margin-right: 4px;
    font-size: 18px;
  }

  .home-link {
    gap: 7px;
    font-size: 12px;
  }

  .intro {
    display: block;
    padding: 16px 3px 14px;
  }

  .intro .eyebrow {
    display: none;
  }

  h1 {
    font-size: 29px;
  }

  h1 > span {
    font-size: 19px;
    vertical-align: 3px;
  }

  .intro-copy {
    max-width: none;
    margin: 7px 0 0;
    font-size: 14px;
    line-height: 1.65;
  }

  .intro-copy > br {
    display: none;
  }

  .intro-copy > span {
    display: block;
    font-size: 12px;
  }

  .play-panel {
    padding: 15px 13px 13px;
    border-radius: 20px;
  }

  .board-heading h2 {
    font-size: 22px;
  }

  .metrics {
    margin: 12px 0 5px;
    padding: 10px 0;
  }

  .metrics > p {
    gap: 4px;
  }

  .metrics strong {
    font-size: 23px;
  }

  .board {
    gap: 5px;
    width: min(100%, 284px);
    margin: 10px auto 13px;
    padding: 3px;
  }

  .cell-symbol {
    font-size: 21px;
  }

  .move-feedback {
    gap: 8px;
    min-height: 82px;
    padding: 11px;
  }

  .feedback-symbol {
    flex-basis: 20px;
    font-size: 22px;
  }

  .move-feedback h3 {
    font-size: 13px;
  }

  .game-actions {
    gap: 6px;
    margin-top: 12px;
  }

  .game-actions .button {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 12px;
  }

  .side-section {
    padding: 19px;
  }

  .confirm-region {
    padding: 16px;
  }

  .confirm-actions {
    flex-wrap: wrap;
  }

  .confirm-actions .button {
    min-width: 120px;
  }
}
