:root {
  --bg: #0c1a14;
  --card: rgba(12, 36, 28, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4fff8;
  --muted: #a8c4b4;
  --green: #7dffa0;
  --amber: #ffd56a;
  --sky: #7ec8e3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#versionTag {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 8;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  opacity: 0.55;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  letter-spacing: 0.4px;
  line-height: normal;
}

#stage {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  line-height: 0;
  touch-action: none;
}

#cv {
  display: block;
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(125, 255, 160, 0.1);
  cursor: pointer;
  touch-action: none;
  position: relative;
  z-index: 1;
}

.screen {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  overflow: hidden;
  line-height: normal;
  pointer-events: none;
  z-index: 2;
}

.screen[data-screen="menu"] {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: transparent;
}

.screen[data-screen="menu"]:not(.hidden) {
  pointer-events: auto;
}

.menu-card {
  width: min(340px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 18px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}

.logo-icon {
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  margin-bottom: 8px;
}

h1 {
  margin: 6px 0 4px;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 .c1 { color: var(--amber); }
h1 .c2 { color: var(--green); }

.tagline {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stats > div {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px 6px;
}

.stats .lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats strong {
  font-size: 1.25rem;
  color: var(--text);
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 14px;
  width: 100%;
  margin-top: 8px;
  transition: transform 0.08s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, #5ad67d, #3dbf9a);
  color: #062016;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 4px 0 #2a8f5a, 0 8px 20px rgba(90, 214, 125, 0.25);
}

button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.mode-chip {
  margin-top: 0 !important;
  padding: 10px 8px !important;
  font-size: 0.85rem !important;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
}

.mode-chip.active {
  background: rgba(125, 255, 160, 0.22);
  color: var(--text);
  border-color: var(--green);
}

.hab-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.hab-row button {
  width: auto;
  flex: 0 0 48px;
  margin-top: 0;
  padding: 10px;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
}

.hab-row .hab-mid {
  flex: 1;
  text-align: center;
  font-weight: 700;
  color: var(--amber);
  font-size: 1rem;
}

.mode-label {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.how {
  text-align: left;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.how ol {
  margin: 0;
  padding-left: 1.2em;
}

.how li { margin: 0.35em 0; }
.how b { color: var(--text); }

.ver {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.8;
}

/* Play chrome */
.play-chrome {
  pointer-events: auto;
  z-index: 5;
  line-height: normal;
}

.icon-btn {
  position: absolute;
  top: 12px;
  width: 44px !important;
  height: 44px;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 12px !important;
  background: rgba(0, 0, 0, 0.35) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  font-size: 1.15rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

#btnMenu { left: 12px; }

.hab-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hab-bar button {
  width: 52px;
  margin: 0;
  flex: 0 0 52px;
  height: 48px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.2rem;
  font-weight: 700;
}

.hab-bar .hab-info {
  flex: 1;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.25;
}

.hab-bar .hab-info strong {
  display: block;
  font-size: 1rem;
  color: var(--amber);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
