/* Page shell, tab bar, cards, buttons and other shared primitives (Midnight Board look). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.sheet-open { overflow: hidden; }
button { font-family: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  /* Safe areas matter when installed full screen (viewport-fit=cover). The bottom padding clears the tab bar. */
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
    calc(104px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#main { display: flex; flex-direction: column; gap: 14px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar:empty, .logged-out .tabbar { display: none; }
.tabbar-in { max-width: 560px; margin: 0 auto; display: flex; justify-content: space-around; padding: 8px 6px 10px; }
.tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--muted); font: 600 10.5px var(--font-body);
  padding: 6px 2px; border-radius: 14px; cursor: pointer; touch-action: manipulation;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.on { color: var(--accent); }
.tab:active { background: var(--accent-soft); }

/* Brand row (header of the Játék tab) */
.brandrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font: 700 22px var(--font-head); letter-spacing: -0.02em; }
.brand b { color: var(--accent2); font-weight: inherit; }
.live { font: 600 11px var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.live.offline::before { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.live.connecting::before { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.banner { padding: 12px 14px; border-radius: 16px; background: var(--warn-soft); color: var(--ink); font-size: 13.5px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  padding: 16px;
}
.card > h2, .card-title {
  font-family: var(--font-head);
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em; margin: 0 0 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.card-title .badge { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 500; }
.loading { text-align: center; color: var(--muted); padding: 40px 16px; }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions.tight { margin-top: 0; }
button.primary {
  flex: 1; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 16px;
  padding: 15px 16px; font-size: 15.5px; font-weight: 700; cursor: pointer; touch-action: manipulation;
  box-shadow: var(--glow);
}
button.primary:active { opacity: 0.85; }
button.primary:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
button.primary.danger { background: var(--bad); color: #FFFFFF; box-shadow: none; }
button.ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 16px;
  padding: 13px 14px; font-size: 14.5px; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
button.ghost:active { background: var(--surface-alt); }
button.ghost:disabled { opacity: 0.4; cursor: default; }
button.danger-ghost { color: var(--bad); border-color: var(--bad); background: transparent; }
button.link { background: none; border: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 8px 0; cursor: pointer; }
.wide { width: 100%; flex: none; }

.confirm-panel { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border: 1px solid var(--bad); border-radius: 16px; padding: 14px; margin-top: 12px; }
.confirm-panel p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.confirm-panel .actions { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; z-index: 60;
  max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: no-preference) {
  .toast { transition: opacity 0.2s, transform 0.2s; }
}

/* Backup reminder banner */
.banner.backup { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--warn); }
.banner.backup p { margin: 0; line-height: 1.45; }
.banner.backup .actions { margin-top: 0; }
.banner.backup button.primary { padding: 10px 14px; font-size: 14px; }
.banner.backup button.ghost { padding: 9px 12px; }
