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

html,
body {
  margin: 0;
  height: 100%;
  background: #1a1a24;
  touch-action: manipulation;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

#canvas-wrap {
  position: relative;
  line-height: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

#game {
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.touch-controls {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.touch-controls.hidden {
  display: none;
}

.touch-controls__left,
.touch-controls__right {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  min-width: 52px;
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: rgba(26, 26, 30, 0.78);
  color: #f7f7f7;
  font: 700 22px/1 "Gowun Batang", serif;
  touch-action: manipulation;
}

.touch-btn:active {
  transform: translateY(1px) scale(0.99);
  background: rgba(52, 52, 58, 0.86);
}

.touch-btn--jump {
  min-width: 92px;
  font-size: 18px;
}

#menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem;
  background: rgba(15, 12, 28, 0.72);
  backdrop-filter: blur(4px);
}

#menu.menu-hidden {
  display: none;
}

#menu-title {
  margin: 0 0 0.75rem;
  font-family: "Gowun Batang", serif;
  font-weight: 700;
  font-size: clamp(1.75rem, 6vw, 2.35rem);
  letter-spacing: 0.04em;
  color: #f5e6c8;
  text-align: center;
  text-shadow: 0 2px 0 #2c1810, 0 0 24px rgba(255, 200, 120, 0.25);
  transform: translateY(-2.5rem);
}

#menu-title + .muted {
  margin-top: -2.5rem;
}

.muted {
  margin: 0;
  font-family: "Gowun Batang", serif;
  font-size: 0.95rem;
  color: rgba(245, 230, 200, 0.75);
}

#char-row {
  display: flex;
  gap: 1rem;
}

.char-btn,
#btn-start {
  font-family: "Gowun Batang", serif;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid rgba(245, 230, 200, 0.45);
  background: rgba(40, 32, 56, 0.9);
  color: #f5e6c8;
  min-width: 5.5rem;
  min-height: 3rem;
  padding: 0.5rem 1rem;
}

.char-btn.selected {
  border-color: #e8b86d;
  background: rgba(90, 60, 40, 0.95);
  box-shadow: 0 0 0 2px rgba(232, 184, 109, 0.35);
}

.char-btn:focus-visible,
#btn-start:focus-visible {
  outline: 2px solid #e8b86d;
  outline-offset: 2px;
}

#btn-start {
  min-width: 10rem;
  font-size: 1.35rem;
  border-color: #c9e89d;
  background: rgba(45, 70, 40, 0.95);
}

#btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden-until-ready[hidden] {
  display: none !important;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 6, 14, 0.82);
  backdrop-filter: blur(3px);
  z-index: 5;
}

#victory-overlay {
  z-index: 6;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  max-width: 20rem;
  text-align: center;
  padding: 1.5rem 1.25rem;
  border-radius: 12px;
  border: 2px solid rgba(245, 230, 200, 0.35);
  background: rgba(32, 26, 48, 0.96);
}

.modal-card h2 {
  margin: 0 0 0.75rem;
  font-family: "Gowun Batang", serif;
  font-size: 1.35rem;
  color: #f5e6c8;
}

.modal-stat {
  margin: 0 0 1.25rem;
  font-family: "Gowun Batang", serif;
  font-size: 1.05rem;
  color: rgba(245, 230, 200, 0.9);
}

.modal-btn {
  font-family: "Gowun Batang", serif;
  font-size: 1.15rem;
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid #e8b86d;
  background: rgba(70, 50, 36, 0.95);
  color: #f5e6c8;
  min-width: 9rem;
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
}

.modal-btn:focus-visible {
  outline: 2px solid #e8b86d;
  outline-offset: 2px;
}

.modal-card--victory {
  border-color: rgba(160, 220, 140, 0.55);
}

.modal-btn--victory {
  border-color: #a8d96f;
  background: rgba(38, 72, 38, 0.95);
}

.modal-btn--victory:focus-visible {
  outline-color: #c9e89d;
}
