:root {
  --bg: #07080c;
  --panel: #12141c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --muted: #9aa3b5;
  --accent: #7cf0c2;
  --danger: #ff6b7a;
  --nav: #0e1016;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Pro Text", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body.app { background: #000; }

#login {
  display: none;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 24px;
  touch-action: auto;
}
#login.show { display: flex; }

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 0.04em;
}
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0d13;
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
}
.login-card button, .nav button, .kbd-bar button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #052016;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}
.login-card button { width: 100%; margin-top: 14px; font-size: 16px; }
.err { color: var(--danger); min-height: 20px; font-size: 13px; margin-top: 10px; }

#stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: env(safe-area-inset-top, 0) 16px env(safe-area-inset-bottom, 0);
}
body.app #stage { padding: 0; gap: 0; }

.phone {
  position: relative;
  width: min(420px, calc(100vw - 24px));
  height: min(860px, calc(100vh - 96px));
  background: #000;
  border-radius: 36px;
  overflow: hidden;
  box-shadow:
    0 0 0 10px #151821,
    0 0 0 12px #2a3040,
    0 40px 80px rgba(0, 0, 0, 0.55);
}
body.app .phone {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

#screen, #player, #touch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#screen { background: #000; }
#player {
  object-fit: contain;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
#player.used { opacity: 1; }
#touch { z-index: 3; }

.hud {
  position: absolute;
  left: 0; right: 0; top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
  font-size: 12px;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.hud b { font-weight: 600; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f5c84c;
  box-shadow: 0 0 8px #f5c84c;
  display: inline-block;
  margin-right: 6px;
}
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0,0,0,.55);
  text-align: center;
  padding: 24px;
}
.overlay.hide { display: none; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.nav {
  width: min(420px, calc(100vw - 24px));
  display: flex;
  gap: 8px;
  background: var(--nav);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px;
}
body.app .nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0));
  background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(16px);
  z-index: 6;
}
.nav button {
  flex: 1;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 8px;
}
.nav button:active { background: rgba(255,255,255,.08); }

.kbd-bar {
  display: none;
  width: min(420px, calc(100vw - 24px));
  gap: 8px;
}
.kbd-bar.show { display: flex; }
body.app .kbd-bar {
  position: absolute;
  left: 8px; right: 8px; bottom: 64px;
  width: auto;
  z-index: 7;
}
.kbd-bar input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #11141c;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  touch-action: auto;
}
.kbd-bar button { flex: 0 0 auto; }

#ime {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
