:root {
  --background:#0b2427;
  --board:#103b3b;
  --cell:#24605a;
  --accent:#f2cf85;
  --accent2:#a5f0ce;
  --text:#fff9e9;
  --muted:#b1ccc3;
  color-scheme:dark;
  font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  font-synthesis:none;
}

* {
  box-sizing:border-box;
}

html,body {
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:var(--background);
  color:var(--text);
}

button {
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  font:inherit;
  color:inherit;
  cursor:pointer;
}

button:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:4px;
}

.icon-button,.hint-button,.primary-button {
  transition:transform .15s ease,background .2s ease,box-shadow .2s ease,color .2s ease;
}

.hint-button:hover {
  color:var(--text);
}

.primary-button:hover {
  box-shadow:0 8px 26px #0003,inset 0 1px 0 #ffffff60;
}

button.icon-button:active,button.hint-button:active,button.primary-button:active {
  transform:translateY(1px) scale(.96);
}

.icon-button:focus-visible,.hint-button:focus-visible,.primary-button:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:4px;
  box-shadow:0 0 0 6px color-mix(in srgb,var(--background) 85%,transparent);
}

.scenery,.scenery-shade {
  position:fixed;
  inset:0;
  pointer-events:none;
}

.scenery {
  background-size:cover;
  background-position:center center;
  opacity:.86;
  transition:opacity .6s;
}

.scenery-shade {
  background:linear-gradient(90deg,color-mix(in srgb,var(--background) 90%,transparent) 0%,color-mix(in srgb,var(--background) 64%,transparent) 34%,color-mix(in srgb,var(--background) 20%,transparent) 72%),linear-gradient(0deg,color-mix(in srgb,var(--background) 92%,transparent),transparent 42%,color-mix(in srgb,var(--background) 45%,transparent));
}

.app-shell {
  position:relative;
  max-width:1400px;
  height:100%;
  height:100dvh;
  margin:auto;
  display:flex;
  flex-direction:column;
  padding:0 4.2vw;
}

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

.brand {
  display:flex;
  align-items:center;
  gap:13px;
  font-size:16px;
  letter-spacing:2px;
  font-weight:600;
}

.brand-mark {
  font-size:35px;
  line-height:1;
  color:var(--accent);
}

.brand-type {
  font-size:10px;
  letter-spacing:1px;
  font-weight:400;
  color:var(--muted);
  border-left:1px solid #ffffff30;
  padding-left:14px;
  margin-left:2px;
}

.top-actions {
  display:flex;
  gap:10px;
}

.icon-button {
  width:38px;
  height:38px;
  border:1px solid #ffffff28;
  border-radius:50%;
  background:#102d2d50;
  font-size:21px;
  transition:background .2s,transform .2s;
}

.icon-button:hover {
  background:#ffffff20;
  transform:translateY(-1px);
}

.icon-button[aria-pressed="true"] {
  opacity:.55;
}

.experience {
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns:minmax(230px,320px) minmax(0,660px);
  align-items:center;
  justify-content:center;
  gap:clamp(30px,5.4vw,88px);
}

.story-panel {
  position:relative;
  margin-top:-22px;
}

.eyebrow {
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--accent);
  font-size:11px;
  letter-spacing:4px;
}

.eyebrow span {
  height:1px;
  width:24px;
  background:var(--accent);
  opacity:.7;
}

h1 {
  font-family:"Songti SC","Noto Serif CJK SC","SimSun",serif;
  font-weight:600;
  font-size:clamp(36px,4.2vw,61px);
  line-height:1.25;
  letter-spacing:5px;
  margin:23px 0 14px;
  text-shadow:0 3px 20px #0005;
}

.subtitle {
  font-family:"Songti SC","SimSun",serif;
  letter-spacing:3px;
  font-size:15px;
  line-height:1.8;
  margin:0;
  color:var(--accent);
}

.description {
  font-size:12px;
  line-height:2.1;
  color:var(--muted);
  max-width:277px;
  letter-spacing:.5px;
  margin:22px 0 32px;
}

.progress-card {
  border:1px solid color-mix(in srgb,var(--accent) 24%,transparent);
  background:linear-gradient(145deg,#ffffff0d,#051d2250);
  border-radius:18px;
  padding:23px 24px;
  box-shadow:0 12px 30px #00131020,inset 0 1px 0 #ffffff0c;
}

.goal-line {
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  color:var(--muted);
  letter-spacing:1px;
}

.level-label {
  font-size:10px;
  color:var(--accent);
  border:1px solid color-mix(in srgb,var(--accent) 25%,transparent);
  border-radius:5px;
  padding:3px 7px;
}

.score-line {
  display:flex;
  align-items:baseline;
  gap:8px;
  margin:10px 0 15px;
  font-size:13px;
  color:var(--muted);
  font-variant-numeric:tabular-nums;
}

.score-line>strong {
  font-size:38px;
  font-weight:500;
  color:var(--text);
  line-height:1.3;
  letter-spacing:-1px;
}

.score-star {
  margin-left:auto;
  color:var(--accent);
  font-size:23px;
}

.progress-track {
  height:8px;
  position:relative;
  border-radius:8px;
  background:#031e2670;
  box-shadow:inset 0 1px 3px #0007;
  overflow:hidden;
}

#progress-fill {
  height:100%;
  width:0;
  background:linear-gradient(90deg,var(--accent2),var(--accent));
  box-shadow:0 0 15px var(--accent2);
  border-radius:8px;
  transition:width .55s cubic-bezier(.2,.8,.2,1);
}

.progress-track i {
  position:absolute;
  left:33.3%;
  top:0;
  bottom:0;
  width:1px;
  background:#0b242750;
}

.progress-track i:last-child {
  left:66.6%;
}

.progress-caption {
  display:flex;
  justify-content:space-between;
  gap:8px;
  font-size:10px;
  color:var(--muted);
  margin-top:12px;
  opacity:.8;
}

.special-tip {
  display:flex;
  align-items:center;
  gap:14px;
  margin:27px 8px 0;
  color:var(--muted);
}

.special-tip-icon {
  display:grid;
  place-items:center;
  width:36px;
  height:36px;
  flex:none;
  border-radius:10px;
  border:1px solid #ffffff25;
  color:var(--accent);
  background:linear-gradient(135deg,#f2cf8520,transparent);
  font-size:23px;
  transform:rotate(-7deg);
}

.special-tip p {
  font-size:10px;
  line-height:1.9;
  margin:0;
}

.special-tip strong {
  font-size:12px;
  font-weight:500;
  color:var(--text);
}

.play-panel {
  width:min(100%,calc(100dvh - 235px));
  justify-self:center;
  position:relative;
}

.board-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  height:56px;
  margin:0 10px 9px;
}

.chapter {
  display:flex;
  gap:9px;
  align-items:center;
  font-size:11px;
  letter-spacing:2px;
  color:var(--text);
  text-shadow:0 1px 7px #000a;
}

.chapter i {
  width:5px;
  height:5px;
  transform:rotate(45deg);
  background:var(--accent);
  box-shadow:0 0 9px #f2cf8580;
}

.moves-badge {
  display:flex;
  align-items:center;
  gap:10px;
  background:color-mix(in srgb,var(--board) 80%,transparent);
  border:1px solid color-mix(in srgb,var(--accent) 40%,transparent);
  border-radius:15px;
  padding:8px 15px;
  box-shadow:0 4px 18px #0002;
}

.moves-badge strong {
  font-size:27px;
  line-height:1.1;
  font-weight:500;
  color:var(--accent);
  font-variant-numeric:tabular-nums;
}

.moves-badge span {
  font-size:10px;
  letter-spacing:1px;
  color:var(--muted);
}

.moves-badge.low {
  border-color:#f39870;
}

.moves-badge.low strong {
  color:#ffb487;
}

.board-wrap {
  width:100%;
  aspect-ratio:1;
  position:relative;
  isolation:isolate;
}

.board-halo {
  position:absolute;
  inset:1.5%;
  z-index:-1;
  border-radius:8%;
  box-shadow:0 22px 60px #001f2470,0 0 70px color-mix(in srgb,var(--accent2) 9%,transparent);
}

#game {
  position:absolute;
  inset:0;
  touch-action:none;
}

#game canvas {
  width:100%!important;
  height:100%!important;
  display:block;
  touch-action:none;
}

.loading {
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  background:var(--board);
  border:1px solid var(--accent);
  border-radius:4%;
  pointer-events:none;
  transition:opacity .3s;
}

.loading span {
  color:var(--accent);
  font-size:55px;
  animation:breathe 1.5s ease-in-out infinite;
}

.loading p {
  font-size:12px;
  color:var(--muted);
  letter-spacing:3px;
}

.loading.done {
  opacity:0;
}

.board-footer {
  display:flex;
  align-items:center;
  gap:7px;
  min-height:45px;
  padding:6px 12px 0;
  font-size:10px;
  color:var(--muted);
  letter-spacing:.5px;
}

.instruction-dot {
  width:4px;
  height:4px;
  border-radius:50%;
  background:var(--accent);
}

.hint-button {
  margin-left:auto;
  border:0;
  background:transparent;
  font-size:11px;
  white-space:nowrap;
  padding:7px 0 7px 8px;
  color:var(--accent);
}

.hint-button .hint-decoration {
  margin-left:5px;
  font-size:17px;
}

.page-footer {
  height:37px;
  flex:none;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  font-size:9px;
  letter-spacing:3px;
  color:var(--muted);
  opacity:.6;
}

.footer-line {
  width:35px;
  height:1px;
  background:var(--muted);
  opacity:.4;
}

.result-overlay {
  position:fixed;
  inset:0;
  z-index:30;
  background:#04151dd9;
  backdrop-filter:blur(7px);
  display:grid;
  place-items:center;
  padding:20px;
}

.result-overlay[hidden] {
  display:none;
}

.result-card {
  max-width:390px;
  width:100%;
  text-align:center;
  border:1px solid color-mix(in srgb,var(--accent) 50%,transparent);
  border-radius:26px;
  background:radial-gradient(ellipse at 50% 0%,#9ad6b51c,transparent 70%),var(--board);
  padding:34px 36px;
  box-shadow:0 30px 90px #0008;
  animation:arrive .35s ease-out;
}

.result-stars {
  font-size:35px;
  color:var(--accent);
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:center;
  height:72px;
  text-shadow:0 0 35px #f2cf8540;
}

.result-stars b {
  font-size:57px;
  font-weight:400;
  transform:translateY(-9px);
}

.result-eyebrow {
  font-size:10px;
  letter-spacing:3px;
  color:var(--muted);
}

.result-card h2 {
  font-family:"Songti SC","SimSun",serif;
  font-weight:500;
  font-size:35px;
  letter-spacing:4px;
  margin:18px 0 12px;
}

.result-card p {
  font-size:12px;
  line-height:1.9;
  color:var(--muted);
  margin:0;
}

.result-score {
  display:flex;
  flex-direction:column;
  gap:4px;
  margin:24px 0;
  color:var(--accent);
}

.result-score strong {
  font-size:40px;
  font-weight:500;
  letter-spacing:1px;
  font-variant-numeric:tabular-nums;
}

.result-score span {
  font-size:10px;
  letter-spacing:2px;
  color:var(--muted);
}

.primary-button {
  width:100%;
  border:1px solid #fff3;
  border-radius:12px;
  padding:14px 22px;
  background:linear-gradient(135deg,var(--accent),color-mix(in srgb,var(--accent) 75%,#a66d37));
  color:#283329;
  font-size:14px;
  font-weight:600;
  box-shadow:0 6px 22px #0002;
}

.primary-button .button-arrow {
  float:right;
}

.is-loss .result-stars {
  opacity:.5;
}

.is-loss .result-stars b {
  font-size:45px;
}

.is-loss .result-stars {
  font-size:0;
}

@keyframes breathe {
  50% {
    opacity:.45;
    transform:scale(.9);
  }
}

@keyframes arrive {
  from {
    opacity:0;
    transform:translateY(16px) scale(.97);
  }
  to {
    opacity:1;
    transform:none;
  }
}

@media(max-width:760px) and (orientation:portrait) {
  .app-shell {
    padding:0 15px;
  }
  .topbar {
    height:62px;
  }
  .brand {
    font-size:13px;
    gap:9px;
    letter-spacing:1px;
  }
  .brand-mark {
    font-size:29px;
  }
  .brand-type {
    font-size:9px;
    padding-left:9px;
    margin:0;
  }
  .icon-button {
    width:32px;
    height:32px;
    font-size:19px;
  }
  .top-actions {
    gap:7px;
  }
  .experience {
    display:flex;
    flex-direction:column;
    justify-content:center;
    gap:10px;
    padding:10px 0 4px;
  }
  .story-panel {
    margin:0;
    width:min(100%,calc(100dvh - 343px));
    min-width:0;
  }
  .eyebrow,.description,.special-tip {
    display:none;
  }
  h1 {
    font-size:28px;
    text-align:center;
    letter-spacing:5px;
    margin:0 0 5px;
    line-height:1.4;
  }
  .subtitle {
    text-align:center;
    font-size:10px;
    letter-spacing:2px;
    line-height:1.4;
    margin-bottom:14px;
  }
  .progress-card {
    padding:12px 15px;
    border-radius:13px;
    position:relative;
  }
  .goal-line {
    font-size:9px;
    letter-spacing:.5px;
  }
  .level-label {
    font-size:8px;
    position:absolute;
    top:13px;
    right:15px;
    padding:2px 5px;
  }
  .score-line {
    margin:2px 0 7px;
    gap:5px;
    font-size:10px;
    line-height:1;
  }
  .score-line>strong {
    font-size:25px;
    line-height:1.1;
  }
  .score-star {
    font-size:18px;
  }
  .progress-caption {
    display:none;
  }
  .progress-track {
    height:5px;
  }
  .play-panel {
    width:min(100%,calc(100dvh - 343px));
    min-width:0;
  }
  .board-toolbar {
    height:35px;
    margin:0 7px 5px;
  }
  .chapter {
    font-size:9px;
    letter-spacing:1px;
    gap:7px;
  }
  .moves-badge {
    padding:5px 10px;
    gap:7px;
    border-radius:10px;
  }
  .moves-badge strong {
    font-size:20px;
  }
  .moves-badge span {
    font-size:8px;
    letter-spacing:0;
  }
  .board-footer {
    min-height:37px;
    font-size:9px;
    padding:4px 5px 0;
    gap:5px;
    letter-spacing:0;
  }
  .hint-button {
    font-size:10px;
  }
  .page-footer {
    height:22px;
    font-size:8px;
    letter-spacing:2px;
  }
  .scenery {
    background-position:60% center;
  }
  .scenery-shade {
    background:linear-gradient(0deg,color-mix(in srgb,var(--background) 95%,transparent),color-mix(in srgb,var(--background) 43%,transparent) 55%,color-mix(in srgb,var(--background) 64%,transparent));
  }
}

@media(max-height:660px) and (orientation:portrait) {
  .topbar {
    height:50px;
  }
  .experience {
    gap:5px;
    padding-top:5px;
  }
  h1 {
    font-size:22px;
    line-height:1.4;
  }
  .subtitle {
    display:none;
  }
  .story-panel {
    width:min(100%,calc(100dvh - 261px));
  }
  .progress-card {
    padding:8px 12px;
    margin-top:9px;
  }
  .level-label {
    top:9px;
    right:12px;
  }
  .score-line>strong {
    font-size:22px;
  }
  .play-panel {
    width:min(100%,calc(100dvh - 261px));
  }
  .page-footer {
    display:none;
  }
}

@media(max-height:570px) and (orientation:landscape) {
  .app-shell {
    padding:0 5vw;
  }
  .topbar {
    height:48px;
  }
  .brand-mark {
    font-size:26px;
  }
  .icon-button {
    height:30px;
    width:30px;
  }
  .experience {
    grid-template-columns:minmax(160px,260px) minmax(0,420px);
    gap:6vw;
  }
  .story-panel {
    margin:0;
  }
  .eyebrow {
    font-size:8px;
    letter-spacing:2px;
  }
  h1 {
    font-size:32px;
    margin:12px 0 9px;
  }
  .subtitle {
    font-size:11px;
    letter-spacing:2px;
  }
  .description,.special-tip {
    display:none;
  }
  .progress-card {
    margin-top:16px;
    padding:13px 16px;
    border-radius:13px;
  }
  .score-line {
    margin:5px 0 9px;
  }
  .score-line>strong {
    font-size:30px;
  }
  .goal-line {
    font-size:10px;
  }
  .progress-caption {
    font-size:8px;
  }
  .play-panel {
    width:min(100%,calc(100dvh - 132px));
  }
  .board-toolbar {
    height:31px;
    margin-bottom:3px;
  }
  .chapter {
    font-size:9px;
    letter-spacing:1px;
  }
  .moves-badge {
    padding:4px 8px;
    gap:5px;
    border-radius:8px;
  }
  .moves-badge strong {
    font-size:19px;
  }
  .moves-badge span {
    font-size:8px;
  }
  .board-footer {
    min-height:28px;
    font-size:8px;
    padding-top:2px;
  }
  .hint-button {
    font-size:9px;
    padding:3px;
  }
  .page-footer {
    height:17px;
    font-size:8px;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after {
    animation:none!important;
    transition:none!important;
  }
}

.score-mote {
  position:fixed;
  z-index:25;
  pointer-events:none;
  color:var(--accent);
  font-size:18px;
  text-shadow:0 0 12px var(--accent);
  will-change:transform,opacity;
}

.description {
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

h1 {
  overflow-wrap:anywhere;
}

.brand {
  min-width:0;
}

#brand-title {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:220px;
}

@media(max-width:760px) and (orientation:portrait) {
  h1 {
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    display:block;
  }
  .brand #brand-title {
    max-width:150px;
  }
}

@media(max-width:760px) and (orientation:portrait),(max-height:570px) and (orientation:landscape) {
  .description {
    display:none;
  }
}

@media(max-width:760px) and (orientation:portrait) {
  .subtitle {
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
}

.result-card {
  max-height:calc(100dvh - 40px);
  overflow-y:auto;
}

@media(max-height:500px) {
  .result-overlay {
    padding:12px;
  }
  .result-card {
    max-width:540px;
    padding:16px 24px;
    max-height:calc(100dvh - 24px);
    border-radius:19px;
  }
  .result-stars {
    height:36px;
    font-size:22px;
    gap:10px;
  }
  .result-stars b {
    font-size:36px;
    transform:translateY(-3px);
  }
  .result-eyebrow {
    font-size:9px;
    line-height:1.2;
    letter-spacing:2px;
  }
  .result-card h2 {
    font-size:25px;
    line-height:1.2;
    margin:8px 0 5px;
    letter-spacing:3px;
  }
  .result-card p {
    font-size:11px;
    line-height:1.5;
  }
  .result-score {
    flex-direction:row;
    align-items:baseline;
    justify-content:center;
    gap:10px;
    margin:10px 0;
  }
  .result-score strong {
    font-size:30px;
    line-height:1.1;
  }
  .result-score span {
    font-size:9px;
  }
  .primary-button {
    padding:10px 18px;
    font-size:13px;
  }
  .is-loss .result-stars b {
    font-size:32px;
  }
}
