:root {
  --paper: #f3efe5;
  --paper-light: #faf8f2;
  --ink: #18203b;
  --muted: #747889;
  --line: #ddd8cc;
  --green: #4f8e67;
  --green-dark: #397354;
  --green-soft: #dce9dc;
  --red: #e56e5d;
  --board: #111b3b;
  --board-light: #172447;
  --white: #ffffff;
  --shadow: 0 18px 45px rgba(24, 32, 59, 0.08);
  font-family: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

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

button {
  font: inherit;
}

.game-app {
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 24px;
}

.topbar,
.brand,
.local-badge,
.intro,
.scoreboard,
.board-heading,
.board-actions,
.guide-header,
.footer {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 46px;
}

.brand {
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  transform: rotate(45deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0.03em;
}

.brand small,
.eyebrow,
.board-kicker,
.score-label,
.key-caption {
  font-family: "DM Mono", "Consolas", monospace;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.local-badge {
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.intro {
  justify-content: space-between;
  gap: 50px;
  padding: 86px 0 48px;
}

.eyebrow,
.board-kicker,
.score-label {
  display: block;
  margin: 0;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

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

h1 {
  max-width: 650px;
  margin: 13px 0 0;
  font-size: clamp(46px, 6vw, 82px);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

h1 em {
  color: var(--green);
  font-style: normal;
}

.intro-copy {
  width: min(100%, 280px);
  padding-top: 31px;
}

.intro-copy p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.primary-button,
.secondary-button,
.action-button,
.touch-key {
  border: 0;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  min-width: 150px;
  padding: 14px 16px;
  color: var(--white);
  background: var(--green);
  font-size: 13px;
}

.primary-button span {
  font-size: 20px;
  font-weight: 400;
  line-height: 0.7;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--green-dark);
  transform: translateY(-2px);
}

.scoreboard {
  gap: 1px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
}

.score-card {
  display: flex;
  flex: 1;
  min-height: 93px;
  flex-direction: column;
  justify-content: center;
  padding: 19px 25px;
  background: var(--paper-light);
}

.score-card-main {
  background: var(--green-soft);
}

.score-card strong {
  margin-top: 7px;
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.status-card strong {
  color: var(--green-dark);
  font-size: 20px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.board-card,
.guide-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-light);
  box-shadow: var(--shadow);
}

.board-card {
  padding: 24px;
}

.board-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 19px;
}

.board-heading h2,
.guide-card h2 {
  margin: 7px 0 0;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.board-size {
  align-self: flex-start;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-family: "DM Mono", "Consolas", monospace;
  font-size: 10px;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  border: 8px solid var(--board);
  border-radius: 8px;
  background: var(--board);
  box-shadow: 0 8px 0 rgba(24, 32, 59, 0.08);
  touch-action: none;
}

#game-board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.game-overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 25px;
  flex-direction: column;
  text-align: center;
  background: rgba(17, 27, 59, 0.91);
  color: var(--white);
}

.game-overlay.is-hidden {
  display: none;
}

.overlay-icon {
  display: grid;
  width: 45px;
  height: 45px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 50%;
  color: var(--board);
  background: var(--green-soft);
  font-size: 22px;
}

.overlay-kicker {
  margin: 0 0 8px;
  color: var(--green-soft);
  font-family: "DM Mono", "Consolas", monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
}

.game-overlay h3 {
  margin-bottom: 9px;
  font-size: 23px;
  letter-spacing: -0.04em;
}

.game-overlay p:not(.overlay-kicker) {
  max-width: 230px;
  margin-bottom: 21px;
  color: #c5cadd;
  font-size: 12px;
  line-height: 1.7;
}

.secondary-button {
  padding: 12px 18px;
  color: var(--ink);
  background: var(--green-soft);
  font-size: 12px;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: var(--white);
  transform: translateY(-2px);
}

.board-actions {
  gap: 9px;
  margin-top: 18px;
}

.action-button {
  min-width: 112px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.action-button:not(:disabled):hover,
.action-button:not(:disabled):focus-visible {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-soft);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-icon {
  display: inline-block;
  margin-right: 6px;
  font-size: 14px;
  font-weight: 400;
}

.guide-card {
  display: flex;
  padding: 27px 25px 22px;
  flex-direction: column;
}

.guide-header {
  justify-content: space-between;
}

.guide-number {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper-light);
  background: var(--ink);
  font-family: "DM Mono", "Consolas", monospace;
  font-size: 10px;
}

.guide-card h2 {
  margin-top: 32px;
  font-size: 25px;
}

.guide-intro {
  margin: 13px 0 29px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.keyboard-guide {
  align-self: center;
  margin: 2px 0 14px;
}

.key-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-top: 5px;
}

.key {
  display: grid;
  width: 37px;
  height: 32px;
  place-items: center;
  border: 1px solid #c9c5ba;
  border-radius: 5px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 2px 0 #c9c5ba;
  font-family: "DM Mono", "Consolas", monospace;
  font-size: 13px;
}

.key-empty {
  visibility: hidden;
}

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

.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(2, 42px);
  gap: 5px;
  align-self: center;
  margin: 10px 0 21px;
}

.touch-key {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--white);
  font-size: 17px;
}

.touch-key:active {
  color: var(--white);
  background: var(--green);
  transform: scale(0.95);
}

.touch-up {
  grid-column: 2;
  grid-row: 1;
}

.touch-left {
  grid-column: 1;
  grid-row: 2;
}

.touch-down {
  grid-column: 2;
  grid-row: 2;
}

.touch-right {
  grid-column: 3;
  grid-row: 2;
}

.guide-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.note-mark {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--red);
  font-size: 11px;
  font-weight: 800;
}

.guide-note p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.footer {
  gap: 13px;
  padding: 24px 0 0;
  color: var(--muted);
  font-family: "DM Mono", "Consolas", monospace;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.footer-rule {
  width: 34px;
  height: 1px;
  background: var(--line);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(79, 142, 103, 0.35);
  outline-offset: 3px;
}

@media (max-width: 780px) {
  .game-app {
    width: min(100% - 30px, 560px);
    padding-top: 20px;
  }

  .intro {
    display: block;
    padding: 61px 0 33px;
  }

  h1 {
    font-size: clamp(45px, 13vw, 72px);
  }

  .intro-copy {
    width: 100%;
    padding-top: 23px;
  }

  .intro-copy p {
    max-width: 320px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .guide-card {
    min-height: auto;
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 480px) {
  .game-app {
    width: min(100% - 22px, 560px);
  }

  .local-badge {
    padding: 7px 9px;
    font-size: 10px;
  }

  .scoreboard {
    align-items: stretch;
  }

  .score-card {
    min-height: 80px;
    padding: 14px 12px;
  }

  .score-card strong {
    font-size: 23px;
  }

  .status-card strong {
    font-size: 14px;
  }

  .score-label {
    font-size: 8px;
    letter-spacing: 0;
  }

  .board-card {
    padding: 14px;
  }

  .board-heading {
    margin-bottom: 13px;
  }

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

  .board-size {
    padding: 6px 7px;
    font-size: 9px;
  }

  .board-wrap {
    border-width: 5px;
  }

  .game-overlay {
    inset: 5px;
  }

  .board-actions {
    margin-top: 13px;
  }

  .action-button {
    flex: 1;
    min-width: 0;
  }

  .footer {
    justify-content: space-between;
    font-size: 8px;
  }

  .footer-rule {
    display: none;
  }
}
