:root {
  --bg: #24140f;
  --panel: rgba(67, 34, 19, 0.78);
  --text: #f7f4e8;
  --muted: #ffe1a3;
  --accent: #ffd36d;
  --line: rgba(255, 219, 139, 0.34);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
}

.app {
  width: min(100vw, 450px);
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 8px;
}

.hud {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 3;
  min-width: 92px;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 222, 142, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(129, 68, 31, 0.9), rgba(72, 34, 18, 0.9)),
    #7e451f;
  box-shadow:
    0 3px 0 rgba(61, 27, 12, 0.9),
    0 8px 18px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 236, 177, 0.4);
  padding: 5px 12px 6px;
  text-align: center;
}

.hud-label {
  display: block;
  color: #ffe7ad;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
  text-shadow: 0 1px 0 #512710;
}

.hud-value {
  display: block;
  min-height: 24px;
  color: #fff8dc;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
  text-shadow:
    0 2px 0 #7b3a16,
    0 0 8px rgba(255, 212, 109, 0.42);
}

.game-wrap {
  position: relative;
  min-height: 0;
  width: min(100%, calc((100dvh - 16px) * 360 / 640));
  aspect-ratio: 360 / 640;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: #24140f;
  background-image: url("assets/mandu-world-bg.png");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 100% auto;
  touch-action: none;
}

.game-wrap.is-loading {
  visibility: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 11px;
  padding: 22px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 221, 131, 0.18), transparent 38%),
    linear-gradient(rgba(48, 21, 10, 0.68), rgba(48, 21, 10, 0.42));
}

.screen.hidden {
  display: none;
}

.screen h1 {
  margin: 0;
  color: var(--accent);
  font-size: 31px;
  line-height: 1.08;
  letter-spacing: 0;
}

.title-art {
  width: min(92%, 330px);
  height: auto;
  margin-bottom: 2px;
  filter: drop-shadow(0 10px 12px rgba(41, 17, 7, 0.45));
}

.fail-art {
  width: min(78%, 260px);
  height: auto;
  margin-bottom: 4px;
  filter: drop-shadow(0 8px 10px rgba(41, 17, 7, 0.42));
}

.screen p {
  margin: 0;
  color: #fff4ce;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 800;
  text-shadow:
    0 2px 0 rgba(71, 32, 12, 0.74),
    0 0 10px rgba(0, 0, 0, 0.2);
}

.screen-copy {
  border: 1px solid rgba(255, 221, 139, 0.32);
  border-radius: 8px;
  background: rgba(80, 38, 17, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 239, 184, 0.18),
    0 5px 14px rgba(0, 0, 0, 0.18);
  padding: 8px 14px 9px;
}

.final-line {
  min-width: 132px;
  border-radius: 999px;
  background: rgba(255, 211, 109, 0.16);
  padding: 5px 14px 6px;
  color: #fff4ce;
}

.final-line strong {
  display: inline-block;
  min-width: 28px;
  color: #ffe06d;
  font-size: 24px;
  line-height: 1;
}

.hint {
  color: #f7d99b;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.9;
}

.btn {
  position: relative;
  min-width: 150px;
  min-height: 48px;
  margin-top: 8px;
  border: 2px solid #fff1b6;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #fff0a5 0%, #ffc44d 52%, #e68126 100%);
  color: #522508;
  cursor: pointer;
  font: inherit;
  font-size: 17px;
  font-weight: 900;
  box-shadow:
    0 5px 0 #8b3e14,
    0 10px 18px rgba(0, 0, 0, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #8b3e14,
    0 6px 12px rgba(0, 0, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.image-btn {
  width: min(76%, 245px);
  min-width: 0;
  min-height: 0;
  margin-top: 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  line-height: 0;
}

.image-btn img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 8px rgba(45, 19, 7, 0.38));
}

.image-btn:active {
  transform: translateY(3px) scale(0.985);
  box-shadow: none;
}

.rank-btn {
  min-width: 146px;
  min-height: 42px;
  margin-top: 2px;
  padding: 0 22px 2px;
  border-color: #fff1b6;
  background:
    linear-gradient(180deg, #fff6bd 0%, #ffd45a 48%, #e88727 100%);
  color: #5a2608;
  font-size: 16px;
}

.mute-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 232, 166, 0.82);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 239, 183, 0.96), rgba(230, 132, 49, 0.82) 48%, rgba(115, 49, 22, 0.94));
  box-shadow:
    0 4px 0 rgba(73, 31, 12, 0.9),
    0 8px 12px rgba(58, 25, 8, 0.28),
    inset 0 2px 0 rgba(255, 248, 205, 0.42);
  cursor: pointer;
}

.mute-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 rgba(73, 31, 12, 0.9),
    0 4px 8px rgba(58, 25, 8, 0.24),
    inset 0 2px 0 rgba(255, 248, 205, 0.32);
}

.mute-btn.is-muted {
  background:
    radial-gradient(circle at 32% 24%, rgba(230, 213, 183, 0.96), rgba(122, 101, 82, 0.9) 50%, rgba(58, 47, 39, 0.96));
  border-color: rgba(221, 207, 178, 0.84);
}

.music-icon {
  color: #fff4c9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-1px);
  text-shadow:
    0 2px 0 rgba(82, 34, 10, 0.78),
    0 0 8px rgba(255, 246, 185, 0.48);
}

.mute-btn.is-muted .music-icon {
  color: #efe0bd;
  opacity: 0.86;
  text-shadow: 0 2px 0 rgba(45, 34, 27, 0.72);
}

.mute-btn.is-muted::after {
  position: absolute;
  width: 28px;
  height: 4px;
  border-radius: 999px;
  background: #fff4c9;
  box-shadow: 0 1px 0 rgba(45, 34, 27, 0.56);
  transform: rotate(-42deg);
  content: "";
}

strong {
  color: var(--accent);
}

@media (max-height: 620px) {
  .app {
    padding: 6px;
  }

  .hud {
    top: 8px;
    padding: 4px 10px 6px;
  }

  .hud-value {
    font-size: 18px;
    min-height: 20px;
  }

  .screen h1 {
    font-size: 26px;
  }
}
