:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #223432;
  background: #f5f3ed;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(231, 200, 163, .25), transparent 29rem),
    radial-gradient(circle at 95% 86%, rgba(141, 174, 163, .15), transparent 28rem),
    #f5f3ed;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, .arrow:focus-visible { outline: 3px solid #d76f4c; outline-offset: 4px; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1280px, calc(100% - 96px));
  min-height: 100vh;
  margin: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #dedfd7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.055em;
}

.brand-mark {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fffaf3;
  background: #263b37;
  font-size: 25px;
  font-weight: 500;
  line-height: 1;
}

.brand-dot { color: #d46e4c; }

.top-link {
  border: 0;
  padding: 10px 0 10px 14px;
  color: #52605b;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.top-link span { margin-left: 7px; color: #d36d4c; }
.top-link:hover { color: #d36d4c; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(350px, .88fr) minmax(470px, 1fr);
  align-items: center;
  gap: clamp(36px, 6vw, 108px);
  padding: 54px 0 58px;
}

.intro { align-self: center; padding-bottom: 3px; }

.eyebrow, .panel-kicker, .small-label, .dialog-eyebrow {
  color: #a06951;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .16em;
}

.eyebrow { display: flex; align-items: center; gap: 11px; }
.eyebrow-line { width: 20px; height: 1px; background: currentColor; }

h1 {
  margin: 24px 0 23px;
  color: #203532;
  font-size: clamp(44px, 4.5vw, 70px);
  font-weight: 800;
  line-height: 1.21;
  letter-spacing: -.075em;
  white-space: nowrap;
}

h1 em { color: #d96f4e; font-style: normal; }

.lead {
  max-width: 400px;
  margin: 0;
  color: #77827b;
  font-size: 15px;
  line-height: 2;
}

.level-card {
  max-width: 438px;
  margin-top: 54px;
  padding: 27px 30px 24px;
  border: 1px solid rgba(211, 210, 195, .8);
  border-radius: 20px;
  background: rgba(255, 253, 247, .58);
}

.level-card-top, .level-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.level-total, .level-card-bottom {
  color: #929991;
  font-size: 12px;
}

.level-number {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 15px;
  font-size: 54px;
  font-weight: 770;
  line-height: 1;
  letter-spacing: -.075em;
  font-variant-numeric: tabular-nums;
}

.level-suffix { color: #aeb4aa; font-size: 18px; font-weight: 500; letter-spacing: 0; }
.progress-track { height: 5px; overflow: hidden; border-radius: 10px; background: #e7e8dd; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: #d9704e; transition: width .32s ease; }
.level-card-bottom { margin-top: 15px; }
.level-card-bottom span:last-child { color: #5c6b64; font-weight: 650; font-variant-numeric: tabular-nums; }

.toolbox { margin-top: 34px; }
.toolbox .small-label { color: #89928a; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 13px; }

.tool-button {
  min-height: 45px;
  padding: 0 17px;
  border: 1px solid #d8dbd1;
  border-radius: 11px;
  color: #4a5d55;
  background: rgba(255, 255, 255, .32);
  font-size: 13px;
  font-weight: 650;
  transition: background .2s, border-color .2s, transform .2s;
}

.tool-button span { margin-right: 7px; color: #cc7353; font-size: 19px; vertical-align: -1px; }
.tool-button:hover { transform: translateY(-2px); border-color: #c1c9bd; background: #fffdf8; }

.game-panel {
  width: 100%;
  min-width: 0;
  padding: clamp(20px, 2.5vw, 34px);
  border: 1px solid #e9e8df;
  border-radius: 28px;
  background: #fffefa;
  box-shadow: 0 22px 60px rgba(48, 57, 44, .07), 0 4px 15px rgba(48, 57, 44, .025);
}

.panel-head, .panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head { margin: 0 2px 23px; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.panel-kicker { color: #aaa89a; font-size: 11px; }
.panel-head h2 { margin: 7px 0 0; font-size: 20px; font-weight: 760; letter-spacing: -.04em; }
.panel-head h2 span { margin-left: 3px; color: #a9aea5; font-size: 13px; font-weight: 500; letter-spacing: 0; }

.level-select-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #e5e7de;
  border-radius: 9px;
  color: #68776e;
  background: #fffefa;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.level-select-button:hover { border-color: #bdc8bb; background: #f7f8f1; }
.level-select-button span { font-size: 17px; line-height: 1; }

.board-wrap {
  width: 100%;
  padding: clamp(10px, 2vw, 22px);
  overflow: auto;
  border: 1px solid #edece2;
  border-radius: 19px;
  background: #3c4561;
}

.board { display: block; width: 100%; height: auto; overflow: visible; touch-action: manipulation; }
.grid-dots { fill: #78819b; }
.arrow { color: #f0a0a1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.arrow.moving { pointer-events: none; }
.arrow-1 { color: #74d1b4; }
.arrow-2 { color: #f5cf52; }
.arrow-3 { color: #ada1ec; }
.arrow-4 { color: #70bddf; }
.arrow-5 { color: #d694d8; }
.arrow-6 { color: #a7d461; }
.arrow-7 { color: #edaf7e; }
.arrow-line { fill: none; stroke: currentColor; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; }
.arrow-head, .arrow-tail { fill: currentColor; }
.arrow-hit { fill: none; stroke: transparent; stroke-width: 40; stroke-linejoin: round; stroke-linecap: round; }
.cell-hit { fill: transparent; cursor: pointer; }
.arrow:hover, .arrow.hovered, .arrow:focus-visible { filter: brightness(.86) drop-shadow(0 3px 2px rgba(64, 75, 61, .16)); }
.arrow.shake { animation: shake .32s ease; }
.arrow.hint { animation: hint 1s ease-in-out 2; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes hint {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); opacity: 1; }
  50% { filter: drop-shadow(0 0 12px #e4a450); opacity: .55; }
}

.panel-footer { min-height: 48px; margin: 14px 2px 0; }
.board-tip { flex: 0 0 auto; color: #81948a; font-size: 12px; white-space: nowrap; }
.board-tip span { margin-right: 5px; color: #76a792; font-size: 8px; vertical-align: 2px; }
.status-message { color: #929b90; font-size: 12px; text-align: right; line-height: 1.5; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 31px;
  border-top: 1px solid #dedfd7;
  color: #9ca59a;
  font-size: 12px;
}

.dialog-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 43, 39, .47);
  backdrop-filter: blur(5px);
}

.dialog {
  position: relative;
  width: min(100%, 440px);
  max-height: min(680px, 90vh);
  overflow: auto;
  padding: 38px;
  border: 1px solid #f0ede2;
  border-radius: 24px;
  background: #fffefa;
  box-shadow: 0 30px 80px rgba(15, 31, 25, .16);
  animation: dialog-in .28s cubic-bezier(.2,.8,.2,1);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 19px;
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 50%;
  color: #809087;
  background: #f4f4ed;
  font-size: 24px;
  line-height: 1;
}

.dialog-close:hover { background: #e9ebe3; }
.dialog-icon { width: 53px; height: 53px; display: grid; place-items: center; margin-bottom: 26px; border-radius: 15px; color: #fff; background: #d97652; font-size: 32px; }
.dialog h2 { margin: 9px 0 11px; font-size: 30px; letter-spacing: -.065em; }
.dialog p { margin: 0 0 26px; color: #849087; font-size: 14px; line-height: 1.9; }
.primary-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 53px; padding: 0 18px; border: 0; border-radius: 11px; color: #fff; background: #284540; font-size: 14px; font-weight: 700; }
.primary-button:hover { background: #365b51; }
.primary-button span { font-size: 22px; font-weight: 400; }
.rules { display: grid; gap: 18px; margin: 23px 0 30px; }
.rules div { display: flex; gap: 16px; color: #64736b; font-size: 14px; line-height: 1.65; }
.rules b { color: #d46e4c; font-size: 13px; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }

.level-tile {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid #e1e6da;
  border-radius: 11px;
  color: #375149;
  background: #f8f9f3;
  font-size: 22px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.level-tile span { color: #9ba69b; font-size: 10px; font-weight: 500; }
.level-tile:hover:not(:disabled), .level-tile.current { border-color: #b9c9b9; background: #e9f0e7; }
.level-tile:disabled { border-color: #ededeb; color: #c3cac0; background: #f8f8f5; }

@media (max-width: 1050px) {
  .page-shell { width: min(900px, calc(100% - 56px)); }
  .layout { grid-template-columns: minmax(290px, .78fr) minmax(400px, 1fr); gap: 28px; }
  h1 { font-size: clamp(38px, 4.5vw, 52px); }
  .level-card { margin-top: 34px; }
}

@media (max-width: 800px) {
  .page-shell { width: min(650px, calc(100% - 40px)); }
  .topbar { height: 76px; }
  .layout { display: flex; flex-direction: column; align-items: stretch; gap: 29px; padding: 34px 0 32px; }
  .intro { align-self: stretch; }
  h1 { margin: 17px 0 13px; font-size: clamp(39px, 7vw, 56px); }
  .lead { max-width: 560px; }
  .level-card { max-width: none; margin-top: 23px; padding: 18px 21px; }
  .level-number { font-size: 40px; margin: 6px 0 11px; }
  .toolbox { margin-top: 18px; }
  .footer { padding: 18px 0 24px; }
}

@media (max-width: 480px) {
  .page-shell { width: calc(100% - 28px); }
  .brand { font-size: 17px; }
  .brand-mark { width: 33px; height: 33px; }
  .layout { padding-top: 24px; gap: 23px; }
  h1 { font-size: clamp(34px, 9.2vw, 43px); }
  .lead { font-size: 13px; line-height: 1.7; }
  .eyebrow { font-size: 10px; }
  .game-panel { padding: 16px; border-radius: 21px; }
  .panel-head { margin-bottom: 15px; }
  .panel-head { flex-wrap: wrap; }
  .panel-actions { width: 100%; justify-content: flex-end; }
  .panel-head h2 { font-size: 18px; }
  .board-wrap { padding: 5px; border-radius: 14px; }
  .status-message { font-size: 11px; }
  .footer { flex-direction: column; gap: 6px; }
  .dialog { padding: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
