:root {
  color-scheme: light;
  --bg: #d9cba8;
  --stripe: rgba(255, 255, 255, 0.12);
  --ink: #1e1b18;
  --muted: #706a60;
  --green: #7fb08a;
  --green-dark: #2f604d;
  --danger: #a13b30;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--green-dark);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--green-dark);
  color: var(--ink);
  font-family: DengXian, "等线", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  overflow-x: hidden;
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button.secondary { background: #756b5c; }
button:disabled { cursor: default; opacity: 0.45; }

.game-shell {
  width: min(1140px, 100vw);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(8px, 1.8vw, 18px);
  display: flex;
  align-items: stretch;
}

.scene {
  position: relative;
  width: 100%;
  min-height: calc(100vh - clamp(8px, 1.8vw, 18px) * 2);
  min-height: calc(100dvh - clamp(8px, 1.8vw, 18px) * 2);
  display: grid;
  grid-template-rows: minmax(210px, auto) 1fr;
  overflow: hidden;
  border: clamp(6px, 1.2vw, 12px) solid var(--green-dark);
  border-radius: 6px;
  background:
    repeating-linear-gradient(135deg, transparent 0 28px, var(--stripe) 28px 52px),
    var(--bg);
  box-shadow: 0 18px 42px rgba(30, 40, 28, 0.28);
}

.scene-image {
  grid-row: 2;
  width: 100%;
  min-height: 360px;
  display: grid;
  place-items: center;
}

.wobble-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.scene-image.empty {
  color: var(--muted);
  font-weight: 800;
}

.content {
  grid-row: 1;
  padding: clamp(24px, 5vw, 48px) clamp(22px, 5vw, 52px) 8px;
  display: grid;
  align-content: start;
  gap: 12px;
  z-index: 2;
}

.level-title {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 900;
  letter-spacing: 0;
}

.level-label {
  color: var(--muted);
  font-weight: 900;
}

.sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-family: DengXian, "等线", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  font-size: clamp(32px, 5.5vw, 58px);
  font-weight: 900;
  line-height: 1.12;
}

.token {
  min-height: 48px;
  padding: 0 4px;
  color: var(--ink);
  background: transparent;
  border-radius: 4px;
  font-size: inherit;
  font-weight: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.token:hover { background: #efe3d0; }
.token:disabled {
  opacity: 1;
  cursor: default;
}
.token.deleted {
  color: #8e8f89;
  text-decoration: line-through;
  text-decoration-thickness: 0.14em;
  text-decoration-color: #747b78;
}

.current-result {
  margin: 0;
  min-height: 30px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.feedback {
  margin: 0;
  min-height: 48px;
  color: var(--ink);
  font-family: DengXian, "等线", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  font-size: clamp(32px, 5.5vw, 58px);
  font-weight: 900;
  line-height: 1.12;
  white-space: pre-wrap;
}

.message {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.success-arrows {
  position: absolute;
  right: clamp(12px, 4vw, 42px);
  bottom: clamp(12px, 4vw, 42px);
  display: flex;
  gap: 8px;
  z-index: 3;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.success-arrows[hidden] {
  display: none;
}

.arrow-mark {
  width: clamp(42px, 6vw, 66px);
  height: clamp(42px, 6vw, 66px);
  position: relative;
  display: block;
}

.arrow-mark::before,
.arrow-mark::after {
  content: "";
  position: absolute;
  right: 8px;
  width: 70%;
  height: 13px;
  border-radius: 999px;
  background: var(--green);
  transform-origin: right center;
}

.arrow-mark::before {
  top: 50%;
  transform: rotate(45deg);
}

.arrow-mark::after {
  bottom: 50%;
  transform: rotate(-45deg);
}

.success-arrows:hover .arrow-mark::before,
.success-arrows:hover .arrow-mark::after {
  background: var(--green-dark);
}

.scene-image.reveal .wobble-canvas {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .scene-image.reveal .wobble-canvas {
    animation: none;
  }
}

.ending-title {
  margin: 0;
  font-size: clamp(28px, 6vw, 52px);
}

@media (max-width: 700px) {
  .game-shell {
    width: 100%;
    min-height: 100dvh;
    padding: 0;
  }

  .scene {
    min-height: 100dvh;
    grid-template-rows: auto minmax(260px, 1fr);
    border-width: 6px;
    border-radius: 0;
  }

  .content {
    padding: 18px 18px 4px;
    gap: 10px;
  }

  .level-title {
    font-size: clamp(16px, 5vw, 24px);
  }

  .sentence,
  .feedback {
    gap: 4px 8px;
    font-size: clamp(30px, 11vw, 48px);
    line-height: 1.08;
  }

  .token {
    min-height: 40px;
    padding: 0 2px;
  }

  .scene-image {
    min-height: 260px;
  }

  .success-arrows {
    right: 14px;
    bottom: 14px;
    gap: 4px;
  }

  .arrow-mark {
    width: 46px;
    height: 46px;
  }

  .arrow-mark::before,
  .arrow-mark::after {
    height: 10px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .scene {
    grid-template-rows: auto minmax(190px, 1fr);
  }

  .content {
    padding: 12px 22px 2px;
    gap: 6px;
  }

  .level-title {
    font-size: clamp(16px, 4vh, 22px);
  }

  .sentence,
  .feedback {
    font-size: clamp(26px, 8vh, 42px);
    line-height: 1.05;
  }

  .token {
    min-height: 34px;
  }

  .scene-image {
    min-height: 190px;
  }
}
