:root {
  --gold: #e8b85a;
  --gold-2: #ffd98a;
  --ink: #07070d;
  --glass: rgba(16, 14, 28, 0.62);
  --glass-2: rgba(30, 26, 52, 0.78);
  --line: rgba(255, 217, 138, 0.28);
  --text: #fff6e6;
  --muted: rgba(255, 246, 230, 0.66);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --en: 'Fredoka', system-ui, sans-serif;
  --hi: 'Noto Sans Devanagari', 'Fredoka', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--en); overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30;
  background: radial-gradient(ellipse at 50% 40%, rgba(7,7,13,0.15), rgba(7,7,13,0.75) 70%);
  opacity: 0; pointer-events: none; transition: opacity .6s ease; }
.overlay.show { opacity: 1; pointer-events: auto; }
.home-inner { text-align: center; padding: 28px; max-width: 420px; }
.logo-hi { font-family: 'Rozha One', var(--hi); font-size: clamp(64px, 20vw, 110px); line-height: 1.05; color: var(--gold-2);
  text-shadow: 0 2px 0 #7a4b14, 0 6px 24px rgba(232,184,90,.45); animation: floaty 5s ease-in-out infinite; }
.logo-en { letter-spacing: .55em; font-weight: 600; font-size: 14px; color: var(--gold); margin: 6px 0 20px .55em; }
.tag-hi { font-family: var(--hi); font-size: 20px; font-weight: 600; }
.tag-hi.big { font-size: 24px; line-height: 1.5; }
.tag-en { color: var(--muted); font-size: 16px; margin-top: 4px; }
.cta { margin-top: 28px; padding: 16px 30px; font-size: 19px; font-weight: 600; border-radius: 999px; color: #2a1606;
  background: linear-gradient(180deg, #ffe2a1, #e8b85a 60%, #c98b2f); box-shadow: 0 5px 0 #7a4b14, 0 12px 32px rgba(232,184,90,.35);
  transition: transform .12s, box-shadow .12s; }
.cta:active { transform: translateY(3px); box-shadow: 0 2px 0 #7a4b14, 0 6px 18px rgba(232,184,90,.3); }
.cta.small { padding: 12px 22px; font-size: 16px; margin-top: 0; }
.ghost { padding: 12px 18px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--gold-2); font-weight: 500; font-size: 15px; background: rgba(255,255,255,.04); }
.fine { margin-top: 18px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.fine.left { text-align: left; }
.splash-emoji { font-size: 72px; animation: floaty 3s ease-in-out infinite; margin-bottom: 12px; }
#embedSplash { background: rgba(0,0,0,.25); }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- chips / hint / toast ---------- */
.chip { position: fixed; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); font-size: 13px; }
.status { top: calc(10px + var(--safe-t)); left: 12px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #999; box-shadow: 0 0 8px currentColor; }
.status.face .dot { background: #5dff9a; color: #5dff9a; }
.status.tilt .dot { background: #ffd35d; color: #ffd35d; }
.status.touch .dot, .status.auto .dot { background: #8fb8ff; color: #8fb8ff; }
.status.clip .dot { background: #ff5d6c; color: #ff5d6c; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.hint { position: fixed; left: 50%; top: 18%; transform: translate(-50%, 10px); z-index: 15; text-align: center; pointer-events: none;
  padding: 14px 20px; border-radius: 20px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); opacity: 0; transition: opacity .5s, transform .5s; max-width: 86vw; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.hint .h-en { font-size: 18px; font-weight: 600; }
.hint .h-hi { font-family: var(--hi); font-size: 16px; color: var(--gold-2); margin-top: 4px; }
.hint .h-arrows { font-size: 26px; letter-spacing: 18px; margin-bottom: 4px; animation: sway 1.6s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: translateX(-10px); } 50% { transform: translateX(10px); } }

.toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) scale(.9); z-index: 40; padding: 10px 18px;
  border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); font-size: 15px; opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* ---------- dock ---------- */
.dock { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); display: flex; gap: 2px;
  padding: 6px; border-radius: 26px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100vw - 16px); }
.dock button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 18px; min-width: 52px; transition: background .2s, transform .1s; }
.dock button span { font-size: 21px; line-height: 1; }
.dock button b { font-size: 10.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.dock button:active { transform: scale(.92); }
.dock button.on { background: rgba(232,184,90,.18); }
.dock button.on b { color: var(--gold-2); }
.dock.rec button[data-act="clip"] { background: rgba(255,80,100,.3); }

/* ---------- sheets ---------- */
.sheet { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow-y: auto; padding: 16px 18px calc(22px + var(--safe-b));
  background: rgba(14, 12, 26, 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line);
  border-radius: 26px 26px 0 0; transform: translateY(105%); transition: transform .35s cubic-bezier(.2,.9,.3,1); touch-action: pan-y; }
.sheet.tall { max-height: 86vh; }
.sheet.show { transform: translateY(0); }
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet h3 { font-size: 20px; font-weight: 600; }
.sheet h3 small { font-family: var(--hi); font-weight: 400; font-size: 14px; color: var(--gold-2); margin-left: 6px; }
.sheet .x { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 16px; }
.world-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.world { text-align: left; padding: 14px; border-radius: 18px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 2px; }
.world i { font-style: normal; font-size: 30px; margin-bottom: 6px; }
.world b { font-size: 16px; font-weight: 600; }
.world small { font-family: var(--hi); font-size: 12px; color: var(--muted); }
.world.on { border-color: var(--gold); background: rgba(232,184,90,.12); }
.rows { display: flex; flex-direction: column; gap: 14px; }
.rows label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); }
.rows label.tog { flex-direction: row; justify-content: space-between; align-items: center; color: var(--text); font-size: 15px; }
input[type=range] { width: 100%; accent-color: var(--gold); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold); }
input[type=text], textarea { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06);
  color: var(--text); font-family: var(--en), var(--hi); font-size: 16px; resize: none; user-select: text; -webkit-user-select: text; }
textarea { font-family: var(--hi), var(--en); line-height: 1.5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.theme-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.theme { flex: 0 0 auto; padding: 10px 14px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); font-size: 15px; }
.theme.on { border-color: var(--gold); background: rgba(232,184,90,.16); }

/* ---------- world controls (chips) ---------- */
.controls { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 94vw; }
.controls button { padding: 8px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); font-size: 14px; }
.controls button.on { background: rgba(232,184,90,.25); border-color: var(--gold); }
.controls .slider { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; }
.controls .slider input { width: 140px; }

/* ---------- HUD (modes) ---------- */
#hud { position: fixed; inset: 0; z-index: 18; pointer-events: none; }
#hud > * { pointer-events: auto; }
.panel { position: absolute; left: 50%; transform: translateX(-50%); text-align: center; padding: 18px 20px; border-radius: 24px;
  background: var(--glass-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); width: min(360px, 88vw); }
.panel.mid { top: 50%; transform: translate(-50%, -50%); }
.panel h4 { font-size: 21px; font-weight: 600; margin-bottom: 4px; }
.panel .hi { font-family: var(--hi); color: var(--gold-2); font-size: 16px; margin-bottom: 10px; }
.panel p { color: var(--muted); font-size: 14px; line-height: 1.45; margin-bottom: 14px; }
.panel .btn-row { justify-content: center; }
.progress { height: 6px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; margin: 10px 0 4px; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffe2a1, #e8b85a); transition: width .2s; }

.gamebar { position: absolute; top: calc(10px + var(--safe-t)); right: 12px; left: auto; display: flex; gap: 8px; align-items: center; }
.gamebar .chip { position: static; }
.timer { position: absolute; top: calc(48px + var(--safe-t)); left: 12px; right: 12px; height: 5px; border-radius: 5px; background: rgba(255,255,255,.12); overflow: hidden; }
.timer > i { display: block; height: 100%; background: linear-gradient(90deg, #7dffb0, #ffe27d, #ff7d8a); transform-origin: left; }
.banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, 0) scale(.8); padding: 14px 24px; border-radius: 22px; text-align: center;
  background: var(--glass-2); border: 1px solid var(--line); opacity: 0; transition: all .35s cubic-bezier(.2,1.4,.4,1); pointer-events: none; }
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.banner b { display: block; font-size: 22px; }
.banner span { font-family: var(--hi); color: var(--gold-2); font-size: 17px; }
.pop { animation: pop .35s ease; }
@keyframes pop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

.pip { position: fixed; z-index: 22; right: 12px; top: calc(52px + var(--safe-t)); width: 96px; border-radius: 14px; border: 1px solid var(--line); transform: scaleX(-1); background: #000; }
#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: -10px; top: -10px; }

@media (orientation: landscape) {
  .hint { top: 12%; }
  .controls { bottom: calc(80px + var(--safe-b)); }
}
