:root {
  --bg: #eef1f5;
  --text: #1d2330;
  --muted: #5c6577;
  --line: #d5dae3;
  --accent: #2f6df6;
  --accent-dark: #1f56cd;
}

* { box-sizing: border-box; }

html,
body { height: 100%; }

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #04060f;
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

/* 게임 화면이 창(라운지 플레이 화면 포함) 전체를 채운다 */
.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #04060f;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 내 얼굴 카메라: 무대 왼쪽 아래 구석의 작은 사각형 (플레이 영역을 가리지 않게) */
.facecam {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  width: clamp(72px, 18%, 116px);
  aspect-ratio: 4 / 3;
  border: 2px solid #39406e;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0e1e;
}

.facecam video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.facecam-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1px 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-align: center;
  background: rgba(5, 8, 20, 0.74);
}

.blinklight {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #39406e;
  transition: background 0.12s, box-shadow 0.12s;
}

.facecam.is-closed { border-color: #55e6ff; }

.facecam.is-closed .blinklight {
  background: #55e6ff;
  box-shadow: 0 0 10px 2px rgba(85, 230, 255, 0.7);
}

.facecam.is-hot { border-color: #ffd166; }

.facecam.is-hot .blinklight {
  background: #ffd166;
  box-shadow: 0 0 10px 2px rgba(255, 209, 102, 0.7);
}

.stage-hint {
  margin: 0;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.72);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-hint.is-hidden { display: none; }

/* 무대 위에 떠 있는 조작·상태 표시 (아래 흰 영역 대신) */
.dock {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  max-width: calc(100% - 100px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

/* HUD */
.hud {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
  color: #fff;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hud-item b { font-size: 15px; }

.hearts {
  display: flex;
  gap: 2px;
  font-size: 17px;
  line-height: 1;
}

.heart { color: #ff5a5f; }
.heart.is-lost { color: rgba(255, 255, 255, 0.26); }

.meters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-left { min-width: 0; }

.meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.meter-label { width: 44px; opacity: 0.85; }

.meter-bar {
  display: block;
  width: 78px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.meter-bar b {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #7de3ff;
  transition: width 0.08s linear;
}

#smileBar { background: #ffd166; }
#jawBar { background: #9ef7a0; }

/* 게임 오버 */
.gameover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8, 11, 16, 0.74);
  color: #fff;
  text-align: center;
}

.gameover[hidden] { display: none; }

.gameover-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.gameover-score {
  margin: 0;
  font-size: 15px;
}

.gameover-score b { font-size: 20px; }

.gameover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.revive {
  background: #ffcf4d;
  border-color: #ffcf4d;
  color: #3a2a00;
  font-weight: 700;
}

.btn.revive:hover:not(:disabled) {
  background: #ffc01f;
  border-color: #ffc01f;
}

.revive-msg {
  margin: 0;
  min-height: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #ffd166;
}

.revive-msg:empty { display: none; }
.revive-msg.is-error { color: #ff9aa2; }

/* 컨트롤 — 무대 위 오버레이 버튼 */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.dock .btn {
  padding: 7px 12px;
  font-size: 13px;
  background: rgba(9, 13, 26, 0.66);
  border-color: rgba(150, 170, 220, 0.42);
  color: #eaf1ff;
}

.dock .btn:hover:not(:disabled) { border-color: rgba(190, 210, 255, 0.8); }

.dock .btn.primary {
  background: rgba(47, 109, 246, 0.88);
  border-color: rgba(140, 180, 255, 0.75);
}

/* 아이템 상점 — 시작 화면(인트로) 위에 뜨는 패널 */
.shop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: min(340px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  border-radius: 12px;
  border: 1px solid rgba(150, 170, 220, 0.42);
  background: rgba(9, 13, 26, 0.95);
  color: #eaf1ff;
  text-align: left;
}

.shop[hidden] { display: none; }

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shop-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.shop .btn {
  padding: 7px 11px;
  font-size: 12px;
  background: rgba(9, 13, 26, 0.66);
  border-color: rgba(150, 170, 220, 0.42);
  color: #eaf1ff;
}

.shop .btn:hover:not(:disabled) { border-color: rgba(190, 210, 255, 0.8); }

.shop-balance {
  margin: 8px 0 0;
  font-size: 13px;
  color: rgba(233, 240, 255, 0.82);
}

.shop-balance b { font-size: 15px; color: #fff; }

.shop-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(150, 170, 220, 0.24);
  background: rgba(255, 255, 255, 0.06);
}

.shop-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.shop-name { font-size: 13px; font-weight: 700; }

.shop-desc {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(233, 240, 255, 0.68);
}

.shop .btn.buy {
  flex: none;
  font-weight: 700;
  background: rgba(47, 109, 246, 0.9);
  border-color: rgba(140, 180, 255, 0.75);
  color: #fff;
}

.shop .btn.buy:hover:not(:disabled) {
  background: rgba(64, 124, 255, 0.98);
  border-color: rgba(180, 205, 255, 0.9);
}

.shop-msg {
  margin: 8px 0 0;
  min-height: 16px;
  font-size: 12px;
  line-height: 1.5;
  color: #ffd166;
}

.shop-msg:empty { display: none; }
.shop-msg.is-error { color: #ffb0b8; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) { border-color: #b9c1cd; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* 시작 화면 */
.startscreen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 14px 72px;
  overflow: auto;
  text-align: center;
  color: #fff;
  background: radial-gradient(130% 100% at 50% 0%, rgba(44, 66, 140, 0.94), rgba(4, 6, 15, 0.97));
}

.startscreen[hidden] { display: none; }

.startscreen-title {
  margin: 0;
  font-size: clamp(24px, 7vw, 38px);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #ffe9a8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.startscreen-sub {
  margin: 0;
  font-size: clamp(12px, 2.6vw, 14px);
  opacity: 0.82;
}

.startscreen-rules {
  margin: 6px 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: clamp(11px, 2.4vw, 13px);
  line-height: 1.5;
}

.startscreen-rules b { color: #8ce0ff; }

.startscreen .btn { margin-top: 4px; }

/* 인트로의 충전·상점 줄 */
.intro-shop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.intro-shop .btn {
  background: rgba(9, 13, 26, 0.66);
  border-color: rgba(150, 170, 220, 0.42);
  color: #eaf1ff;
}

.intro-shop .btn:hover:not(:disabled) { border-color: rgba(190, 210, 255, 0.8); }

.lucat-balance {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 13px;
  color: rgba(233, 240, 255, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.lucat-balance[hidden] { display: none; }

.lucat-balance b { font-size: 15px; color: #fff; }

.lucat-msg {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(233, 240, 255, 0.86);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.lucat-msg:empty { display: none; }
.lucat-msg.is-error { color: #ffb0b8; }

.status {
  margin: 0;
  font-size: 13px;
  color: rgba(233, 240, 255, 0.86);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.status:empty { display: none; }

.error {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #ffb0b8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.error:empty { display: none; }

/* 시작 화면 안쪽의 개인정보 안내 (아래 흰 영역 제거) */
.notice {
  margin: 10px 0 0;
  max-width: 34em;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .meter-bar { width: 54px; }
  .hud-row { gap: 8px; }
  .startscreen-rules { gap: 2px; }
  .dock { max-width: calc(100% - 92px); }
  .dock .btn { padding: 6px 10px; font-size: 12px; }
  .startscreen { padding-bottom: 96px; }
}
