:root {
  --ink: #f4efe4;
  --ink-soft: rgba(244, 239, 228, .72);
  --night: #1b1f33;
  --glass: rgba(20, 22, 36, .32);
  --glass-line: rgba(255, 255, 255, .16);
  --accent: #e7b98a;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--font); }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; }

/* 입장 화면 */
.enter {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 24px; text-align: center;
  background: linear-gradient(180deg, #2f3460 0%, #6b5a7a 55%, #e3a27e 100%);
  transition: opacity 1.2s ease;
}
.enter.leaving { opacity: 0; pointer-events: none; }
.enter-mark { width: 52px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.enter h1 { margin: 6px 0 0; font-size: 28px; font-weight: 500; letter-spacing: 6px; padding-left: 6px; }
.enter p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.enter-name {
  margin-top: 22px; display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 48px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); border: 1px solid var(--glass-line); font-size: 15px;
}
.enter-name span { color: var(--ink-soft); font-size: 14px; }
.enter-name input {
  width: 9.5em; min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; text-align: center; letter-spacing: 1px;
}
.enter-name input { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.enter-name input::placeholder { color: rgba(244, 239, 228, .45); }
.enter-name:focus-within { border-color: var(--accent); }
.enter .enter-error { color: #ffd7c2; font-size: 13px; margin-top: 8px; }
.enter .enter-name + .enter-error + button, .enter .enter-name ~ button { margin-top: 18px; }
.enter button {
  margin-top: 26px; min-height: 48px; padding: 0 28px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); border: 1px solid var(--glass-line); font-size: 15px; letter-spacing: 2px; cursor: pointer;
}
.enter button:focus-visible, .actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* HUD: 조용하게. 기대 있으면 사라진다. */
.hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 1.2s ease; }
.hud.faded { opacity: 0; }
.hud.faded .actions button { pointer-events: none; }
.count {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; margin: 0;
  font-size: 12px; color: var(--ink-soft); text-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.hint, .whisper {
  position: absolute; left: 16px; right: 16px; margin: 0; text-align: center;
  font-size: 13px; color: var(--ink-soft); text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  transition: opacity .8s ease;
}
.hint { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px); }
.whisper { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 92px); opacity: 0; }
.whisper.on { opacity: 1; }
.actions {
  position: absolute; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 10px; padding: 0 16px;
}
.actions button {
  pointer-events: auto; min-width: 64px; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line); font-size: 14px; letter-spacing: 1px; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
/* 소리 설정: 아래에서 올라오는 얇은 시트 */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 18px 20px max(20px, env(safe-area-inset-bottom));
  background: rgba(22, 24, 38, .86); border-top: 1px solid var(--glass-line); border-radius: 18px 18px 0 0;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); font-size: 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet h2 { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: 2px; }
.sheet-head button { background: none; border: 0; color: var(--ink-soft); min-height: 44px; padding: 0 4px; cursor: pointer; }
.row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .1);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stepper output { min-width: 44px; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.row input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: rgba(255, 255, 255, .18); position: relative; cursor: pointer; transition: background .3s; }
.row input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .3s; }
.row input[type="checkbox"]:checked { background: #b8875d; }
.row input[type="checkbox"]:checked::after { transform: translateX(18px); }
.row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sheet-note { margin: 10px 0 0; color: var(--ink-soft); font-size: 12px; }
.credits { margin: 6px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; line-height: 1.8; max-height: 55vh; overflow-y: auto; }
.credits a { color: var(--ink); }
.credits-btn {
  position: absolute; top: max(8px, env(safe-area-inset-top)); right: 12px; pointer-events: auto;
  min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 12px; letter-spacing: 1px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.hud.faded .credits-btn { pointer-events: none; }
.credits-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.resume {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); font-size: 13px; cursor: pointer;
}
/* 알림: 누가 들어오거나 합장으로 인사하면 화면 위쪽에 잠깐 (버튼이 숨어 있어도 보인다) */
.toasts { position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 46px); left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 10px 18px; border-radius: 999px;
  background: rgba(22, 24, 38, .72); border: 1px solid rgba(231, 185, 138, .55); color: var(--ink); font-size: 14px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(-8px); transition: opacity .45s ease, transform .45s ease;
}
.toast.on { opacity: 1; transform: none; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .enter, .hud, .hint, .whisper { transition: none; }
}
