:root {
  --bg: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e6e8ec;
  --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --text: #edeef1;
    --muted: #9aa1ac;
    --border: #262a34;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.site-header .wrap {
  padding-top: 32px;
  padding-bottom: 8px;
}

.logo {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-widget {
  display: flex;
  align-items: center;
}

.login-link {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.login-link:hover {
  color: var(--text);
}

.login-form {
  display: flex;
  gap: 6px;
}

.login-form[hidden] {
  display: none;
}

.login-form input {
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 140px;
}

.login-form button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  padding: 24px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 320px;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.modal-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.modal .login-form {
  margin-bottom: 12px;
}

.modal .login-form input {
  flex: 1;
}

.hero {
  padding: 24px 0 48px;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin: 0;
}

.apps {
  padding: 24px 0 64px;
}

.apps .wrap {
  max-width: 960px;
}

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px) scale(1.02);
  border-color: color-mix(in srgb, var(--text) 20%, var(--border));
}

.card:not(.card-unlocked):hover,
.card:not(.card-unlocked):focus-visible {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.card-unlocked:hover,
.card-unlocked:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(80, 200, 120, 0.5), 0 10px 24px rgba(80, 200, 120, 0.4);
}

.card:active {
  transform: translateY(-1px) scale(1.01);
}

.card h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .card h3 {
    font-size: 0.8rem;
  }

  .card-thumb {
    width: 44px;
    height: 44px;
  }

  .card-thumb-emoji {
    font-size: 2.1rem;
  }

  .lock-icon {
    top: 10px;
    right: 10px;
    font-size: 0.85rem;
  }
}

.lock-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.95rem;
  opacity: 0.5;
}

.card-unlocked .lock-icon {
  display: none;
}

.card-unlocked {
  box-shadow: inset 0 0 0 1px rgba(80, 200, 120, 0.5), 0 0 16px rgba(80, 200, 120, 0.35);
}

.card-thumb {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  margin: 0 0 12px;
  overflow: hidden;
}

.card-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-thumb-emoji {
  display: block;
  width: auto;
  height: auto;
  border: none;
  border-radius: 0;
  background: none;
  font-size: 2.75rem;
  line-height: 1;
}

.rev-counter {
  background: #14161b;
}

.rev-counter svg {
  display: block;
  width: 100%;
  height: 100%;
}

.rev-face {
  fill: #14161b;
}

.rev-redline {
  fill: none;
  stroke: #cfd3da;
  stroke-width: 3;
  opacity: 0.35;
}

.rev-redline-hot {
  stroke: #e5484d;
  opacity: 1;
}

.rev-ticks line {
  stroke: #cfd3da;
  stroke-width: 2;
}

.rev-tick-red {
  stroke: #ff6b6f;
}

.rev-needle {
  stroke: #ff6b6f;
  stroke-width: 2.5;
  stroke-linecap: round;
  transform-origin: 50px 50px;
  transform: rotate(-90deg);
  animation: rev-sweep 18s ease-in-out infinite;
}

.rev-hub {
  fill: #cfd3da;
}

@keyframes rev-sweep {
  /* gear 1: climb slowly from idle up to redline */
  0%    { transform: rotate(-90deg); }
  28%   { transform: rotate(120deg); }
  /* upshift: revs drop back to ~35% of the range, well clear of red */
  30%   { transform: rotate(-6deg); }
  /* gear 2: climb again to redline */
  62%   { transform: rotate(120deg); }
  64%   { transform: rotate(0deg); }
  /* gear 3: climb, hold at redline, then ease off back to idle to loop */
  92%   { transform: rotate(120deg); }
  96%   { transform: rotate(120deg); }
  100%  { transform: rotate(-90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rev-needle {
    animation: none;
    transform: rotate(20deg);
  }
}

.site-footer {
  padding: 32px 0 48px;
}

.site-footer p {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.site-footer a {
  border-bottom: 1px solid var(--muted);
}

.age-app {
  padding: 32px 0 64px;
}

.age-app h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 16px;
}

.age-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

#password-gate .login-form {
  margin-bottom: 12px;
}

.age-output {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.age-photo {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  margin: 0 0 24px;
}

.bell-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 12px 0 0;
}
