:root {
  color-scheme: dark;
  --fg: #fff;
  --fraco: rgba(255, 255, 255, .55);
  --vidro: rgba(30, 30, 32, .72);
  --linha: rgba(255, 255, 255, .12);
  --ativo: rgba(255, 255, 255, .2);
  --bom: #30d158;
  --medio: #ffd60a;
  --mau: #ff453a;
  --topo: max(8px, env(safe-area-inset-top));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #000; color: var(--fg); overflow: hidden; overscroll-behavior: none; touch-action: none;
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; touch-action: manipulation; }

/* o ecrã do PC: ocupa tudo; se a proporção for diferente, fica centrado sem cortar (posição dada pelo app.js) */
#tela { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; background: #000; touch-action: none; }
#mira { position: fixed; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; z-index: 5; }
#mira[hidden] { display: none; }

/* ---- ecrã inicial ---- */
#inicio { position: fixed; inset: 0; display: grid; place-items: center; background: #000; z-index: 20; padding: 24px; }
#inicio[hidden] { display: none; }
#inicio .cx { text-align: center; max-width: 460px; }
#inicio h1 { font-size: 34px; margin: 14px 0 6px; font-weight: 700; letter-spacing: -.5px; }
#inicio p { margin: 6px 0; font-size: 17px; }
#inicio .fraco, .fraco { color: var(--fraco); font-size: 14px; }
#inicio .codigo { font: 600 56px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 10px; margin: 18px 0 6px; }
.logo { width: 76px; height: 58px; margin: 0 auto; border: 3px solid #fff; border-radius: 12px; position: relative; }
.logo::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 26px; height: 3px; background: #fff; transform: translateX(-50%); border-radius: 2px; }
#iBotoes { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn { min-width: 220px; padding: 13px 20px; border-radius: 14px; border: 0; background: #fff; color: #000; font-weight: 600; font-size: 17px; }
.btn.sec { background: rgba(255, 255, 255, .12); color: #fff; }
.passos { text-align: left; margin: 14px auto 0; padding-left: 20px; color: var(--fraco); font-size: 15px; }
.passos li { margin: 6px 0; }

/* ---- barra (à RustDesk: discreta, em cima, recolhe sozinha) ---- */
#barra {
  position: fixed; top: var(--topo); left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 16px;
  background: var(--vidro); border: 1px solid var(--linha);
  -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
  touch-action: none; transition: opacity .2s;
}
#barra[hidden] { display: none; }
#barra button {
  width: 42px; height: 38px; border: 0; border-radius: 11px; background: transparent; padding: 0;
  display: grid; place-items: center; position: relative;
}
#barra button:active { background: var(--ativo); }
#barra button[aria-pressed="true"] { background: var(--ativo); }
#barra button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#barra .sep { width: 1px; height: 22px; background: var(--linha); margin: 0 3px; }
#barra .pega { width: 18px; cursor: grab; opacity: .45; }
#barra .lig { width: auto; padding: 0 9px; gap: 6px; display: flex; font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
#barra .lig i { width: 8px; height: 8px; border-radius: 50%; background: var(--bom); display: block; }
#barra .letra { position: absolute; right: 4px; bottom: 3px; font: 700 9px system-ui; opacity: .8; }
#barra.recolhida { padding: 0; border-radius: 0 0 12px 12px; top: 0; }
#barra.recolhida > * { display: none; }
#barra.recolhida > .abrir { display: grid; width: 64px; height: 22px; border-radius: 0 0 12px 12px; }
#barra .abrir { display: none; }
#barra.recolhida .abrir svg { width: 18px; height: 18px; }

/* ---- menus ---- */
.pop {
  position: fixed; top: calc(var(--topo) + 52px); left: 50%; transform: translateX(-50%); z-index: 11;
  width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow: auto;
  padding: 10px 14px 14px; border-radius: 18px; background: var(--vidro); border: 1px solid var(--linha);
  -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
}
.pop[hidden] { display: none; }
.pop h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--fraco); font-weight: 600; }
.seg { display: flex; background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 8px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: rgba(255, 255, 255, .22); font-weight: 600; }
.seg + .seg { margin-top: 6px; }
.linha { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.linha button { border: 0; background: rgba(255, 255, 255, .12); padding: 7px 12px; border-radius: 9px; font-size: 14px; }
.pop table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pop td { padding: 6px 0; border-bottom: 1px solid var(--linha); vertical-align: top; }
.pop td:first-child { color: var(--fraco); width: 46%; padding-right: 8px; }

/* ---- teclas extra (por cima do teclado do iPad) ---- */
#teclas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; display: flex; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  overflow-x: auto; background: var(--vidro); border-top: 1px solid var(--linha);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); scrollbar-width: none;
}
#teclas[hidden] { display: none; }
#teclas::-webkit-scrollbar { display: none; }
#teclas button {
  flex: none; min-width: 50px; height: 42px; padding: 0 12px; border: 0; border-radius: 9px;
  background: rgba(255, 255, 255, .14); font-size: 15px; font-weight: 500;
}
#teclas button.mod[data-estado="1"] { background: #fff; color: #000; }
#teclas button.mod[data-estado="2"] { background: #fff; color: #000; box-shadow: inset 0 -3px 0 #0a84ff; }
#teclas .esp { width: 10px; flex: none; }

/* ---- pequenos ---- */
#stats {
  position: fixed; top: calc(var(--topo) + 2px); right: 12px; z-index: 9; padding: 5px 9px; border-radius: 9px;
  background: rgba(0, 0, 0, .55); font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none; white-space: pre;
}
#stats[hidden] { display: none; }
#nota {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: min(560px, 90vw); padding: 10px 16px; border-radius: 12px; background: var(--vidro); border: 1px solid var(--linha);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); opacity: 0; transition: opacity .25s; pointer-events: none; text-align: center;
}
#nota.on { opacity: 1; }
#religar {
  position: fixed; top: calc(var(--topo) + 56px); left: 50%; transform: translateX(-50%); z-index: 9; padding: 7px 14px;
  border-radius: 10px; background: rgba(255, 69, 58, .85); font-size: 14px; font-weight: 600;
}
#religar[hidden] { display: none; }
#pergunta {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 31;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-radius: 14px;
  background: var(--vidro); border: 1px solid var(--linha); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
#pergunta[hidden] { display: none; }
#pergunta button { border: 0; background: rgba(255, 255, 255, .14); padding: 8px 12px; border-radius: 9px; font-size: 14px; }
#pergunta button:first-of-type { background: #fff; color: #000; font-weight: 600; }
#entrada { position: fixed; left: -100px; top: 0; width: 10px; height: 10px; opacity: 0; font-size: 16px; }

#inicio .login { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
#inicio .login input { font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--fraco); background: transparent; color: inherit; min-width: 240px; }
#inicio .login .fraco { flex-basis: 100%; min-height: 1.2em; }
