:root {
  --bg: #f6f0e7;
  --panel: #fff7ec;
  --ink: #2a241d;
  --muted: #6e6256;
  --accent: #f0822e;
  --accent-dark: #c75a11;
  --shadow: 0 20px 40px rgba(53, 37, 23, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, #ffd7b8 0%, #f9efe4 48%, #e8f2ea 100%),
    var(--bg);
  display: flex;
  flex-direction: column;
  touch-action: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  background: #efe2d6;
  color: var(--ink);
  box-shadow: 0 10px 18px rgba(60, 40, 20, 0.15);
}

.back-btn {
  padding: 6px 12px;
  font-size: 12px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.title-main {
  font-size: 22px;
  font-weight: 700;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-sub {
  font-size: 13px;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 16px;
  font-weight: 600;
  align-items: center;
}

.stars {
  display: inline-flex;
  gap: 4px;
}

.star {
  color: #f2b933;
  text-shadow: 0 6px 14px rgba(242, 185, 51, 0.35);
}

.star.dim {
  color: #c9c3b8;
  text-shadow: none;
}

.coin-block {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.coin-icon {
  width: 16px;
  height: 16px;
  background: url("assets/td/coin.svg") center/contain no-repeat;
  display: inline-block;
}

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3e4d5;
  box-shadow: 0 8px 14px rgba(90, 60, 30, 0.18);
  font-size: 12px;
}

.tool-btn.disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
  box-shadow: none;
}

.tool-icon {
  width: 20px;
  height: 20px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.ice-icon {
  background-image: url("assets/snake/ice.svg");
}

.wheel-icon {
  background-image: url("assets/snake/wheel.svg");
}

.scope-icon {
  background-image: url("assets/snake/scope.svg");
}

.tool-cost {
  color: #6e4c2a;
  font-weight: 700;
}

.main {
  flex: 1;
  display: flex;
  padding: 0 20px 20px;
}

.playfield {
  position: relative;
  flex: 1;
  background: linear-gradient(180deg, #fffaf2, #f2e5d6);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 60vh;
}

.word-display {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.86);
  padding: 10px 16px;
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(120, 90, 60, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 5;
  max-width: 85%;
}

.word-zh {
  font-size: 16px;
  color: var(--muted);
}

.word-en {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  font-size: 22px;
  letter-spacing: 2px;
}

.word-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
}

.word-char.pending {
  color: #c2b0a1;
}

.word-char.done {
  color: var(--accent-dark);
  font-weight: 700;
}

.word-char.space {
  min-width: 14px;
}

.message {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 13px;
  z-index: 5;
}

.effect-status {
  position: absolute;
  right: 16px;
  top: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 12px;
  z-index: 5;
}

.letter-bubble {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #2d241a;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 18px rgba(60, 40, 20, 0.2);
  pointer-events: none;
  user-select: none;
}

.letter-bubble.space {
  background: rgba(255, 255, 255, 0.7);
  border-style: dashed;
  color: transparent;
}

.snake-head {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at top, #fff8e4, #ffd39f);
  border: 3px solid #f6b46d;
  box-shadow: 0 12px 20px rgba(90, 60, 30, 0.2);
  z-index: 4;
}

.snake-head::before,
.snake-head::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a341e;
  top: 16px;
}

.snake-head::before {
  left: 12px;
}

.snake-head::after {
  right: 12px;
}

.snake-seg {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at top, #ffffff, #f7c57b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #4a341e;
  box-shadow: 0 8px 14px rgba(70, 44, 20, 0.2);
  z-index: 3;
}

.snake-seg.separator {
  background: #f0822e;
  color: transparent;
  box-shadow: 0 8px 14px rgba(240, 130, 46, 0.3);
}

.tail-badge {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2f7d74;
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 14px rgba(47, 125, 116, 0.35);
  z-index: 2;
}

@media (max-width: 900px) {
  .word-en {
    font-size: 20px;
    letter-spacing: 2px;
  }
}

@media (max-width: 640px) and (orientation: portrait) {
  body {
    touch-action: manipulation;
  }

  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .title-main {
    font-size: 18px;
  }

  .title-sub {
    font-size: 12px;
  }

  .stats {
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
  }

  .tools {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tool-btn {
    font-size: 11px;
    padding: 4px 8px;
  }

  .main {
    padding: 0 12px 12px;
  }

  .playfield {
    min-height: 58vh;
    border-radius: 16px;
  }

  .word-display {
    top: 10px;
    padding: 8px 12px;
    border-radius: 14px;
  }

  .word-zh {
    font-size: 14px;
  }

  .word-en {
    font-size: 18px;
    letter-spacing: 1px;
  }
}
