/* Rebroni Rest(쉼터) — 입구는 사이트 테마(dark / nature)를 따르고, 공간 안은 장면 위 반투명 조작판 */
:root {
  --bg: #0b0d14;
  --bg-2: #141a2c;
  --panel: rgba(255, 255, 255, .05);
  --panel-2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .12);
  --text: #eceef6;
  --muted: #9aa0b8;
  --accent: #f0b878;
  --accent-ink: #1a1006;
  --radius: 18px;
  color-scheme: dark;
}

[data-theme="nature"] {
  --bg: #eef4ec;
  --bg-2: #dfeadb;
  --panel: rgba(34, 96, 56, .06);
  --panel-2: rgba(34, 96, 56, .11);
  --line: rgba(24, 68, 40, .18);
  --text: #1d2b21;
  --muted: #557060;
  --accent: #3f8a5c;
  --accent-ink: #f5faf3;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  word-break: keep-all;
  overflow-wrap: anywhere;
  background: radial-gradient(ellipse at 50% -10%, var(--bg-2), var(--bg) 60%) fixed;
}
body.in-room { overflow: hidden; background: #000; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.en-sub { display: block; font-size: .72em; color: var(--muted); font-weight: 400; letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.6; }

/* ---------- 입구 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; letter-spacing: .02em; }
.topbar h1 .en-sub { display: inline; margin-left: 4px; }
.back { color: var(--text); text-decoration: none; font-size: 20px; padding: 4px 8px; }
.textlink { color: var(--muted); text-decoration: none; font-size: 14px; padding: 8px; }
.textlink:hover { color: var(--text); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 18px; line-height: 1;
}

.hub-main {
  max-width: 1080px; margin: 0 auto;
  padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
}
.intro { text-align: center; padding: 20px 0 28px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
.intro h2 { margin: 0 0 12px; font-size: clamp(26px, 5vw, 38px); font-weight: 600; letter-spacing: -.01em; }
.intro h2 .en-sub { font-size: .45em; margin-top: 6px; letter-spacing: .08em; }
.lead { max-width: 640px; margin: 0 auto; font-size: 15px; line-height: 1.75; color: var(--text); opacity: .9; }
.lead .en-sub { margin-top: 6px; font-size: 13px; }

.rooms {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.room-card {
  position: relative; overflow: hidden;
  display: grid; align-content: end; gap: 6px;
  min-height: 190px; padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #f4f1ea; text-decoration: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
  isolation: isolate;
  transition: transform .25s ease, box-shadow .25s ease;
}
.room-card::before { /* 카드마다 다른 풍경 */
  content: ""; position: absolute; inset: 0; z-index: -1;
  transition: transform 1.2s ease;
}
.room-card::after { /* 글자가 읽히도록 아래쪽 어둡게 */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, .55));
}
.room-card:hover, .room-card:focus-visible { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0, 0, 0, .28); }
.room-card:hover::before { transform: scale(1.06); }
.room-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.room-card .en-sub { color: rgba(244, 241, 234, .72); }
.rc-icon { position: absolute; top: 16px; left: 18px; font-size: 30px; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .35)); }
.rc-title { font-size: 19px; font-weight: 600; }
.rc-title .en-sub { display: inline; margin-left: 6px; font-size: .68em; }
.rc-desc { font-size: 13.5px; line-height: 1.55; color: rgba(244, 241, 234, .9); }

.c-candle::before { background: radial-gradient(circle at 70% 38%, rgba(255, 190, 110, .85), rgba(220, 110, 40, .35) 18%, transparent 46%), radial-gradient(circle at 40% 52%, rgba(255, 170, 90, .5), transparent 30%), linear-gradient(160deg, #2a1810, #0d0806); }
.c-wish::before { background: radial-gradient(circle at 72% 30%, rgba(255, 170, 90, .9) 0 3px, rgba(255, 140, 60, .35) 10px, transparent 28px), radial-gradient(circle at 40% 18%, rgba(255, 190, 110, .8) 0 2px, transparent 16px), radial-gradient(circle at 20% 40%, rgba(255, 190, 110, .7) 0 1.5px, transparent 12px), linear-gradient(180deg, #070a20, #1d1640 55%, #3b2452); }
.c-self::before { background: radial-gradient(circle at 70% 40%, rgba(255, 255, 255, .9), rgba(190, 170, 255, .45) 14%, rgba(110, 120, 255, .18) 32%, transparent 55%), linear-gradient(160deg, #0b1230, #251942); }
.c-walk::before { background: radial-gradient(circle at 78% 22%, rgba(255, 240, 200, .9), rgba(255, 220, 160, .3) 12%, transparent 30%), linear-gradient(180deg, #9cc4e6 0%, #f7dcc0 45%, #6a9a70 46%, #3d6e46 70%, #c8ae84 71%, #b89c74 82%, #2c4a30 83%); }
.c-ocean::before { background: radial-gradient(ellipse at 30% 0%, rgba(220, 250, 255, .55), transparent 40%), linear-gradient(105deg, transparent 40%, rgba(210, 245, 255, .16) 45%, transparent 52%), linear-gradient(180deg, #5cc8e0, #1a70b0 55%, #0a3164); }

.c-temple::before { background: radial-gradient(circle at 74% 34%, rgba(255, 220, 140, .85), rgba(240, 170, 80, .3) 14%, transparent 34%), linear-gradient(180deg, transparent 52%, rgba(46, 107, 82, .9) 52% 55%, transparent 55%), linear-gradient(180deg, #3f4651 0 52%, #d6ccb2 56%, #b8874f); }
.c-walk::after, .c-ocean::after { background: linear-gradient(180deg, transparent 15%, rgba(0, 0, 0, .68)); }

.notes { margin-top: 26px; padding: 16px 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.notes p { margin: 0 0 8px; }
.notes p:last-child { margin: 0; }

/* ---------- 공간 ---------- */
.room {
  position: fixed; inset: 0; z-index: 20;
  background: #000; color: #f1eee8;
  --muted: rgba(241, 238, 232, .66);
  --accent: #f0b878;
  --accent-ink: #1a1006;
  color-scheme: dark;
}
#stage { position: absolute; inset: 0; display: block; touch-action: none; cursor: pointer; }
.room[data-room="ocean"] #stage { cursor: grab; }

.room-bar {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .45), transparent);
  transition: opacity .5s;
}
.rb-title { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-title .en-sub { display: inline; margin-left: 6px; }
.rb-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px; border-radius: 12px;
  color: #f1eee8; text-decoration: none; font-size: 14px;
  background: rgba(12, 14, 22, .42);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.rb-btn[aria-pressed="true"] { border-color: var(--accent); }
.rb-btn.pulse { border-color: var(--accent); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(240, 184, 120, .18); } }
.rb-vol { width: 96px; accent-color: var(--accent); }
.rb-vol[hidden] { display: none; }

.room-msg {
  position: absolute; z-index: 2; left: 50%; top: calc(64px + env(safe-area-inset-top));
  width: min(560px, calc(100% - 32px));
  margin: 0; padding: 10px 16px; border-radius: 14px;
  transform: translate(-50%, -6px);
  text-align: center; font-size: 15px; line-height: 1.55;
  color: #fbf7ef; text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
  background: rgba(10, 12, 20, .32);
  opacity: 0; pointer-events: none;
  transition: opacity .9s, transform .9s;
}
.room-msg.show { opacity: 1; transform: translate(-50%, 0); }
.room-msg .en-sub { color: rgba(251, 247, 239, .72); margin-top: 2px; }
/* 위쪽에 조작판이 있는 공간은 안내 문구를 아래쪽에 */
.room[data-room="walk"] .room-msg, .room[data-room="ocean"] .room-msg { top: auto; bottom: calc(24px + env(safe-area-inset-bottom)); }

.panel { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.panel > * { pointer-events: auto; }
.dock {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  display: grid; gap: 10px; justify-items: center;
  padding: 12px 14px; border-radius: 18px;
  background: rgba(12, 14, 22, .46);
  border: 1px solid rgba(255, 255, 255, .13);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  transition: opacity .5s;
}
.dock.top { top: calc(62px + env(safe-area-inset-top)); bottom: auto; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; }
.hint { margin: 0; text-align: center; font-size: 14px; }
.hint .en-sub, .btn .en-sub, .check .en-sub, .field .en-sub, .fine .en-sub, .kept summary .en-sub { display: inline; margin-left: 4px; }
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 40px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .1);
  color: #f6f2ea; font-size: 14px; text-decoration: none;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, .16); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary .en-sub { color: rgba(26, 16, 6, .7); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.btn.wide { width: min(100%, 320px); }
.btn.on { background: rgba(240, 184, 120, .32); border-color: var(--accent); box-shadow: 0 0 0 6px rgba(240, 184, 120, .15); }
.btn:focus-visible, .seg button:focus-visible, .rb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill {
  display: inline-flex; align-items: center; min-height: 30px; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .14);
}
.pill:empty { display: none; }

.seg { display: inline-flex; flex-wrap: wrap; justify-content: center; padding: 3px; gap: 3px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .12); }
.seg button {
  min-height: 34px; padding: 4px 12px; border-radius: 9px; border: 0;
  background: transparent; color: #f1eee8; font-size: 14px;
}
.seg button[aria-pressed="true"] { background: rgba(255, 255, 255, .2); font-weight: 600; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.field select {
  min-height: 36px; padding: 4px 8px; border-radius: 10px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .18); color: #f1eee8;
}
.field select option { background: #161a26; color: #f1eee8; }

/* 소원 */
.wish-form { display: flex; gap: 8px; width: 100%; }
.wish-form input {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 14px; border-radius: 12px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; font-size: 16px; /* 16px 미만이면 iOS가 확대함 */
}
.wish-form input::placeholder { color: rgba(255, 255, 255, .5); }
.wish-form input:focus { outline: none; border-color: var(--accent); }
.kept { width: 100%; font-size: 14px; }
.kept summary { cursor: pointer; text-align: center; color: var(--muted); list-style-position: inside; }
.kept ul { list-style: none; margin: 8px 0; padding: 0; max-height: 28vh; overflow: auto; display: grid; gap: 6px; }
.kept li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.kept li span { flex: 1; min-width: 0; }
.kept li small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.kept .x { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .08); color: #fff; font-size: 16px; line-height: 1; }
.js-pray { touch-action: none; }

/* 나를 찾는 명상 */
.self-breath { /* 빛 바로 위 */
  position: absolute; left: 50%; top: calc(40% - 16vmin - 30px);
  transform: translate(-50%, -50%);
  pointer-events: none !important;
  font-size: 15px; letter-spacing: .08em; color: #f3f1ff; font-weight: 600;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
  text-align: center; white-space: nowrap;
}
.self-prompt {
  position: absolute; left: 16px; right: 16px; top: calc(40% + 16vmin + 26px);
  margin: 0; text-align: center; pointer-events: none !important;
  font-size: clamp(17px, 2.6vw, 22px); line-height: 1.6; color: #f3f1ff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity 1.4s ease;
}
.self-prompt.show { opacity: 1; }
.self-prompt .en-sub { font-size: .7em; margin-top: 4px; color: rgba(243, 241, 255, .7); }
.panel[data-room="self"] .only-run, .panel[data-room="self"] .only-done { display: none; }
.panel[data-room="self"][data-state="run"] .only-idle, .panel[data-room="self"][data-state="done"] .only-idle { display: none; }
.panel[data-room="self"][data-state="run"] .only-run, .panel[data-room="self"][data-state="done"] .only-done { display: flex; }
.only-idle { display: grid; gap: 10px; justify-items: center; width: 100%; }

/* 화면만 보기 */
.room.bare .dock, .room.bare .room-msg { opacity: 0; pointer-events: none; }
.room.bare .room-bar > :not(#bare-btn) { opacity: 0; pointer-events: none; }
.room.bare .room-bar { background: none; }
.room.bare #bare-btn { opacity: .55; }

@media (max-width: 560px) {
  .hide-xs { display: none; }
  .rb-vol { display: none; } /* 휴대폰은 기기 볼륨 버튼으로 */
  .rb-title { font-size: 15px; }
  .rb-title .en-sub { display: none; }
  .dock { padding: 10px; gap: 8px; }
  .btn .en-sub, .check .en-sub, .field .en-sub { display: none; }
  .hint .en-sub, .fine .en-sub { display: block; margin: 2px 0 0; }
  .seg button { padding: 4px 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .room-card, .room-card::before, .room-msg, .self-prompt { transition: none; }
  .rb-btn.pulse { animation: none; }
}
