:root {
  --grass: #3d6b3a;
  --grass-deep: #2a4d2a;
  --sky: #87b8c9;
  --water: #2f7a8a;
  --earth: #c4a574;
  --cow: #8b5a2b;
  --cream: #f0e6d4;
  --ink: #1a2418;
  --accent: #d9772e;
  --danger: #c45c4a;
  --ok: #4a9a5c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--grass-deep);
  color: var(--cream);
  font-family: "Noto Sans SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, #6a9e7a 0%, transparent 55%),
    linear-gradient(180deg, #4a7a55 0%, #2a4d2a 100%);
}

#game {
  display: block;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  max-width: 960px;
  max-height: 540px;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  background: #6a9eb0;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(26, 50, 28, 0.55) 0%, rgba(26, 36, 24, 0.82) 100%);
  z-index: 10;
  animation: fadeIn 0.45s ease;
}

#title-screen {
  background:
    linear-gradient(180deg, rgba(18, 28, 16, 0.35) 0%, rgba(18, 22, 14, 0.72) 100%),
    url("/assets/bg_title.jpg?v=20260817e") center / cover no-repeat;
}

#ending-screen {
  background:
    linear-gradient(180deg, rgba(18, 28, 16, 0.45) 0%, rgba(18, 22, 14, 0.82) 100%),
    url("/assets/poster.jpg?v=20260817e") center 30% / cover no-repeat;
}

.title-poster {
  position: relative;
  z-index: 1;
  width: min(42vw, 220px);
  height: auto;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  margin-bottom: 0.6rem;
  animation: brandRise 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.title-art-row {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  justify-content: center;
  margin: 0.4rem 0 0.6rem;
}

.title-art-row figure {
  margin: 0;
}

.title-art-row img {
  display: block;
  width: min(34vw, 150px);
  height: auto;
  max-height: 200px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

.title-art-row figcaption {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: rgba(240, 230, 212, 0.85);
}

.ending-poster {
  width: 96px;
  height: auto;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.build-badge {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: #1a2418;
  background: linear-gradient(90deg, #e8c85a, #d9772e);
  font-weight: 700;
}

#visit-stats {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 30;
  margin: 0;
  padding: 0 12px;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: rgba(240, 230, 212, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

#visit-stats span {
  color: #f0e6d4;
  font-weight: 600;
}


.overlay.hidden,
.hidden {
  display: none !important;
}

.title-glow {
  position: absolute;
  width: 70vmin;
  height: 70vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 168, 90, 0.28) 0%, transparent 70%);
  pointer-events: none;
  animation: pulseGlow 3.2s ease-in-out infinite;
}

.brand {
  position: relative;
  font-family: "Ma Shan Zheng", cursive;
  font-size: clamp(4.5rem, 18vw, 7.5rem);
  line-height: 1;
  color: var(--cream);
  text-shadow:
    0 4px 0 rgba(45, 30, 12, 0.35),
    0 0 40px rgba(217, 119, 46, 0.35);
  letter-spacing: 0.08em;
  animation: brandRise 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.ending-brand {
  font-size: clamp(3rem, 12vw, 5rem);
  margin-bottom: 0.4rem;
}

.tagline {
  position: relative;
  margin-top: 0.6rem;
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  letter-spacing: 0.2em;
  color: #e8d7b8;
}

.howto {
  position: relative;
  margin: 1.4rem 0 1.8rem;
  font-size: 0.95rem;
  opacity: 0.85;
  max-width: 22rem;
  line-height: 1.6;
}

button {
  position: relative;
  appearance: none;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #e8a04a 0%, var(--accent) 100%);
  color: #2a1a0a;
  cursor: pointer;
  box-shadow: 0 6px 0 #8a4a18, 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #8a4a18, 0 14px 28px rgba(0, 0, 0, 0.28);
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8a4a18, 0 6px 12px rgba(0, 0, 0, 0.2);
}

#result-screen h2,
#ending-screen h2 {
  font-family: "Ma Shan Zheng", cursive;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  margin-bottom: 0.8rem;
}

#result-msg,
.ending-text {
  max-width: 22rem;
  line-height: 1.75;
  margin-bottom: 1.5rem;
  opacity: 0.92;
  font-size: 1rem;
}

#result-screen button + button {
  margin-top: 0.75rem;
}

#hud {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, calc(100vh * 16 / 9), 960px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  z-index: 5;
  pointer-events: none;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

#level-label {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  opacity: 0.85;
}

#level-name {
  font-family: "Ma Shan Zheng", cursive;
  font-size: 1.45rem;
}

.power-wrap {
  min-width: 9rem;
  max-width: 12rem;
  flex: 1;
  text-align: right;
}

.power-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  margin-bottom: 0.35rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.power-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(20, 30, 18, 0.55);
  border: 2px solid rgba(240, 230, 212, 0.55);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

#power-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6bbf6a 0%, #e8c04a 55%, #d9553a 100%);
  transform-origin: left center;
  transition: width 0.05s linear;
}

#power-fill.pulse {
  animation: powerPulse 0.35s ease-in-out infinite;
}

#hint {
  position: absolute;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(26, 36, 24, 0.72);
  border: 1px solid rgba(240, 230, 212, 0.25);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  max-width: min(90vw, 28rem);
  text-align: center;
  pointer-events: none;
  animation: hintBob 2.4s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes brandRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes powerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@keyframes hintBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@media (max-width: 520px) {
  #hud {
    flex-direction: column;
    align-items: stretch;
  }

  .power-wrap {
    max-width: none;
    text-align: left;
  }

  .howto {
    font-size: 0.85rem;
  }
}
