:root {
  --bg: #fdf7ec;
  --ink: #2a2016;
  --muted: #7d6b56;
  --card: #ffffff;
  --edge: rgba(42, 32, 22, 0.1);
  --honey: #f7b32b;
  --honey-deep: #d9930f;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130e;
    --ink: #f3e9db;
    --muted: #a4917a;
    --card: #221c15;
    --edge: rgba(255, 255, 255, 0.1);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 clamp(16px, 4vw, 40px) 64px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Avenir Next",
    "Nunito",
    -apple-system,
    BlinkMacSystemFont,
    system-ui,
    sans-serif;
  /* A faint honeycomb wash, drawn with gradients so there's no image to load. */
  background-image:
    radial-gradient(
      circle at 15% 10%,
      rgba(247, 179, 43, 0.16),
      transparent 45%
    ),
    radial-gradient(circle at 85% 0%, rgba(247, 179, 43, 0.1), transparent 40%);
  background-repeat: no-repeat;
}

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(48px, 9vw, 96px) 0 clamp(28px, 5vw, 48px);
  text-align: center;
}

/*
 * Mark and title on one line. It wraps rather than shrinking the title on a
 * narrow phone — a 38px heading next to a 44px mark is already tight.
 */
.hero-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 18px);
  flex-wrap: wrap;
}

/*
 * The logo carries the word "Chofter", so the heading beside it is only
 * "Games" — and its alt text is the word, not empty, or the page announces
 * itself as just "Games".
 */
.hero-logo {
  width: clamp(160px, 28vw, 300px);
  height: auto;
  /*
   * The wordmark is near-black on transparency, which vanishes against the
   * dark theme. A cream plate in dark mode keeps the brand colours honest
   * rather than recolouring someone's logo; light mode is already this cream,
   * so the plate is invisible there and costs nothing.
   */
  border-radius: 14px;
}

@media (prefers-color-scheme: dark) {
  .hero-logo {
    background: #fdf7ec;
    padding: 10px 14px;
  }
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 8vw, 68px);
  letter-spacing: -1.5px;
  line-height: 1.05;
}

.hero p {
  margin: 12px 0 0;
  font-size: clamp(15px, 2.4vw, 19px);
  color: var(--muted);
}

main {
  max-width: 1100px;
  margin: 0 auto;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(16px, 3vw, 28px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(42, 32, 22, 0.08);
  transition:
    transform 180ms cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 180ms ease-out;
}

.card:hover,
.card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(42, 32, 22, 0.16);
}

.card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.card-art {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid var(--edge);
}

/* Stand-in when a game has no card.png yet. */
.card-art-blank {
  display: grid;
  place-items: center;
  background: linear-gradient(
    150deg,
    hsl(var(--hue) 70% 62%),
    hsl(calc(var(--hue) + 40) 72% 48%)
  );
}

.card-art-blank span {
  font-size: 74px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}

.card-body {
  padding: 18px 20px 4px;
  flex: 1 1 auto;
}

.card-body h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.3px;
}

.card-body p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.card-play {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 14px 20px 18px;
  padding: 8px 16px;
  align-self: flex-start;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd75e, var(--honey));
  color: #4a3208;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--honey-deep);
}

.card-play svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.card a:active .card-play {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--honey-deep);
}

.empty {
  grid-column: 1 / -1;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--edge);
  border-radius: 22px;
}

footer {
  max-width: 1100px;
  margin: 56px auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }
  .card:hover,
  .card:focus-within {
    transform: none;
  }
}

/* ---- "a new version is ready" ------------------------------------------- */

/*
 * The gallery polls version.json the same way a game does; see
 * "Telling a running app it's out of date" in the README. Fixed to the bottom
 * of the viewport so it's found whether or not the page has been scrolled, and
 * inset for the home indicator on an installed copy.
 */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd75e, var(--honey));
  color: #4a2f07;
  font: inherit;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  animation: update-rise 320ms ease-out;
}

.update-banner[hidden] {
  display: none;
}

.update-banner b {
  font-size: 15px;
}

.update-banner span {
  font-size: 12px;
  opacity: 0.75;
}

.update-banner:active {
  transform: translateX(-50%) scale(0.97);
}

.update-banner.taken {
  pointer-events: none;
  opacity: 0.75;
}

@keyframes update-rise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
  }
}

/* ---- App Store section --------------------------------------------------- */

.section-title {
  margin: 56px 0 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.section-note {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 15px;
}

/* The warning under the In Development heading: read it as a caution, not a
 * caption. A left rule and a warmer colour so it doesn't blend into the notes. */
.section-note.section-warn {
  color: #b06a1b;
  font-weight: 600;
  border-left: 3px solid #e0902f;
  padding-left: 10px;
}

/*
 * Narrower cards than the web games get, and laid out around a square icon
 * rather than a screenshot — these are links out, not things you can play
 * here, and they shouldn't compete with the games above for attention.
 */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.app-card a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--edge);
  color: inherit;
  text-decoration: none;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.app-card a:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(42, 32, 22, 0.12);
}

.app-card img {
  width: 64px;
  height: 64px;
  border-radius: 15px;
  flex: none;
}

.app-card h3 {
  margin: 0;
  font-size: 17px;
}

.app-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
