*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #070B14; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Layered backdrop: warm top gradient + very faint eight-point star lattice */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='112' height='112' viewBox='0 0 112 112'%3E%3Cg fill='none' stroke='%23F3CE7E' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M56 12 100 56 56 100 12 56Z'/%3E%3Crect x='25' y='25' width='62' height='62'/%3E%3Ccircle cx='56' cy='56' r='9'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(180deg, #161617 0%, #131319 10%, #0C1119 24%, #070B14 38%, #070B14 100%);
  background-size: 112px 112px, 100% 100%;
  background-repeat: repeat, no-repeat;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100dvh;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  padding: 8px var(--pad) calc(26px + env(safe-area-inset-bottom));
  animation: fadeUp .32s var(--ease) both;
}
.screen--tight { padding-inline: var(--pad-tight); }
.screen--tabbed { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.screen--flush { padding: 0 0 calc(26px + env(safe-area-inset-bottom)); gap: 0; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  0% { opacity: 0; transform: scale(.82); }
  60% { opacity: 1; transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes sheen {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.18; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 20px; line-height: 1.35; font-weight: 700; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 600; }
p { color: var(--text-2); }
b, strong { font-weight: 700; color: var(--text); }
small { font-size: 12px; color: var(--muted); }
a { color: var(--gold-text); text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font-family: inherit; color: var(--text); }
::placeholder { color: var(--placeholder); }
.ico { display: block; flex: none; }

.helper { font-size: 12px; line-height: 1.7; color: var(--muted); text-align: center; }
.input-hint { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 0; }
.gold { color: var(--gold-text); }
.num { font-variant-numeric: tabular-nums; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-main { flex: 1; min-width: 0; }
.topbar-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}
.section-head h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.section-head a, .section-head button { font-size: 13px; font-weight: 600; color: var(--gold-text); }

.sticky-foot {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  max-width: var(--app-max);
  margin: 0 auto;
  display: grid;
  gap: 8px;
  padding: 14px var(--pad) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(7, 11, 20, 0) 0%, rgba(7, 11, 20, .94) 32%, #070B14 66%);
}
.sticky-foot--tight { padding-inline: var(--pad-tight); }

/* ---------- Accessibility switches ---------- */
html.no-motion *,
html.no-motion *::before,
html.no-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
html.text-lg body { font-size: 16px; }
html.text-lg .answer-input { font-size: 20px; }
html.text-lg .res-word { font-size: 24px; }
