:root {
  --bg: #0a1a38;
  --bg-darker: #071229;
  --card-bg2: #12244a;
  --accent: #f5a623;
  --accent2: #ff8a3d;
  --text: #ffffff;
  --text-dim: #aebadb;
  --border: rgba(255, 255, 255, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  overflow: hidden;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden {
  display: none !important;
}

/* ---------- MENU ---------- */

#menu-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at top right, rgba(245, 166, 35, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-darker) 100%);
}

#menu-screen header {
  flex: 0 0 auto;
  padding: 28px 28px 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, var(--accent2), var(--accent), var(--accent2));
  flex: 0 0 auto;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}

#menu-screen h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

#menu-screen .sub {
  margin: 0 auto;
  color: var(--text-dim);
  font-size: 14px;
}

#categories {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 40px;
}

.categoria-titulo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 26px 6px 12px;
}

.categoria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card-bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.card:active {
  transform: scale(0.97);
  box-shadow: 0 0 0 2px var(--accent);
}

.card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg-darker);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-cover img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(7, 18, 41, 0.85);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  backdrop-filter: blur(2px);
}

.card-body {
  padding: 12px 14px 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.3;
}

/* ---------- VIEWER ---------- */

#viewer-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

#viewer-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.65), transparent);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
}

#btn-back {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 20px;
}

#btn-back:active {
  background: rgba(255, 255, 255, 0.24);
}

#viewer-title {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

#viewer-count {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 48px;
  text-align: right;
}

#viewer-stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

#slide-backdrop {
  position: absolute;
  inset: -30px;
  background-size: cover;
  background-position: center;
  filter: blur(35px) brightness(0.45) saturate(1.2);
  transform: scale(1.15);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#slide-backdrop.loaded {
  opacity: 1;
}

#slide-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

#slide-img.loaded {
  opacity: 1;
}

.tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  z-index: 3;
}

#tap-prev { left: 0; }
#tap-next { right: 0; }

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  z-index: 4;
}

.nav-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.nav-btn.prev { left: 14px; }
.nav-btn.next { right: 14px; }

.nav-btn:disabled {
  opacity: 0.25;
}

#viewer-progress {
  flex: 0 0 auto;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: var(--safe-bottom);
}

#viewer-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  width: 0%;
  transition: width 0.2s ease;
}

/* Empty state (menu with no matching decks, defensive) */
.empty {
  color: var(--text-dim);
  padding: 40px 6px;
  text-align: center;
}

/* Telas largas (versão site): centraliza o conteúdo */
#menu-screen header > *, #categories > * {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.categoria-titulo { padding-left: 6px; }
