* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #d9eff7 url("images/sky-grass-field-background.webp") center / cover no-repeat fixed;
  color: #1b1f27;
  min-height: 100vh;
  overflow: hidden;
}

/* 게임 화면이 창 전체를 여백 없이 채우도록 배치한다. */
.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #d9eff7;
}

/* 조작 버튼은 게임 화면 위에 겹쳐 두어 플레이 영역을 줄이지 않는다. */
.topbar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 auto 0 2px;
}

button {
  font: inherit;
}

.btn {
  border: 1px solid #c7cedb;
  background: #fff;
  color: #1b1f27;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: #eef2f8;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn[aria-pressed="true"] {
  background: #ffe9c9;
  border-color: #e0ab6a;
  color: #6b3d10;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: #d9eff7 url("images/sky-grass-field-background.webp") center / cover no-repeat;
}

/* 전체 화면에서도 게임 화면이 여백 없이 창을 꽉 채운다. */
.app:fullscreen,
.app:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #d9eff7;
}

/* 시작 화면 안내는 시작 내용 안에 함께 표시한다. */

.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 영상은 화면에 보이지 않고 입 모양 인식에만 쓰인다 */
.stage video {
  object-fit: cover;
  background: #14171d;
  opacity: 0;
}

.hud {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud span {
  background: rgba(12, 15, 20, 0.62);
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

#livesEl {
  color: #ff6b8a;
  letter-spacing: 2px;
}

.status {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 13px;
  max-width: calc(100% - 20px);
  border-radius: 999px;
  background: rgba(12, 15, 20, 0.68);
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* 문구가 없을 때는 빈 띠를 그리지 않는다. */
.status:empty {
  display: none;
}

/* 안내 문구는 3초가 지나면 서서히 사라진다. */
.status.is-hidden {
  opacity: 0;
}

.over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: rgba(10, 13, 18, 0.66);
  color: #fff;
  text-align: center;
}

.over[hidden] {
  display: none;
}

/* 시작 화면은 게임 위에 표시하며, 낮은 화면에서는 내용만 스크롤한다. */
.start-screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 56px 16px 28px;
  text-align: center;
  background: #d9eff7 url("images/sky-grass-field-background.webp") center / cover no-repeat;
}

.start-screen[hidden] {
  display: none;
}

.start-content {
  width: 100%;
  max-width: 440px;
  margin: auto;
}

.start-content h1 {
  margin: 0 0 10px;
  font-size: clamp(20px, 4vw, 28px);
}

.start-rabbit {
  display: block;
  width: auto;
  height: clamp(60px, 16vh, 130px);
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto;
}

.start-content p {
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.5;
}

.start-content .btn {
  margin-top: 4px;
}

/* 시작 버튼은 토끼 버튼 이미지를 그대로 사용한다. */
.start-content .btn.rabbit-start {
  display: block;
  margin: 6px auto 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  min-height: 0;
  line-height: 0;
}

.btn.rabbit-start:hover:not(:disabled),
.btn.rabbit-start:focus:not(:disabled) {
  background: none;
}

.btn.rabbit-start img {
  display: block;
  width: auto;
  height: clamp(56px, 11vh, 88px);
  max-width: 100%;
  object-fit: contain;
}

.btn.rabbit-start:active:not(:disabled) img {
  transform: translateY(1px);
}

.btn.rabbit-start:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
}

.stage.is-start .hud {
  visibility: hidden;
}

.stage.is-start .status {
  z-index: 3;
  width: calc(100% - 20px);
  border-radius: 12px;
}

.stage.is-start {
  min-height: 0;
}

.over p {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
}

.over .ranking-status {
  margin: 0;
  max-width: 340px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #ffe6a7;
}

.over .ranking-status:empty {
  display: none;
}

@media (max-width: 420px) {
  .topbar h1 {
    font-size: 15px;
  }

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

  .status {
    font-size: 12px;
  }
}
