/* ==========================================================================
   Daily Crosswords — web
   Design system mirrored from the iOS app's asset catalog and SwiftUI styling.
   ========================================================================== */

:root {
  /* Asset-catalog colors (Assets.xcassets/*.colorset) */
  --my-blue: #508CA4;
  --my-green: #3BB273;
  --my-yellow: #F7B32B;
  --my-red: #8C271E;
  --my-gray: #636363;
  --my-hot-pink: #F4AFB4;
  --my-dark-green: #283618;

  /* iOS system colors */
  --sys-blue: #007AFF;
  --sys-green: #34C759;
  --sys-red: #FF3B30;
  --sys-orange: #FF9500;
  --sys-yellow: #FFCC00;
  --sys-purple: #AF52DE;
  --sys-teal: #30B0C7;
  --sys-gray: #8E8E93;

  /* Semantic surfaces */
  --bg: #F2F2F7;
  --bg-grouped: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --cell-bg: #FFFFFF;
  --cell-blank: #000000;
  --cell-border: #000000;
  --label: #000000;
  --label-secondary: rgba(60, 60, 67, 0.6);
  --label-tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --fill-quaternary: rgba(116, 116, 128, 0.08);
  --nav-bg: rgba(249, 249, 251, 0.82);
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --tile-tint: 10%;
  --nav-h: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --sys-blue: #0A84FF;
    --sys-green: #30D158;
    --sys-red: #FF453A;
    --sys-orange: #FF9F0A;
    --sys-yellow: #FFD60A;
    --sys-purple: #BF5AF2;
    --sys-teal: #40C8E0;

    --bg: #000000;
    --bg-grouped: #1C1C1E;
    --bg-elevated: #1C1C1E;
    --cell-bg: #2C2C2E;
    --cell-blank: #000000;
    --cell-border: #6A6A6E;
    --label: #FFFFFF;
    --label-secondary: rgba(235, 235, 245, 0.6);
    --label-tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --fill-quaternary: rgba(118, 118, 128, 0.18);
    --tile-tint: 30%;
    --nav-bg: rgba(28, 28, 30, 0.82);
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }
}

/* --- base ---------------------------------------------------------------- */

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

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100%; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a { color: var(--my-blue); }

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

/* --- screens + nav-push transition --------------------------------------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--screen-bg, var(--bg));
}

@keyframes push-in {
  from { transform: translateX(18px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes pop-in {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.screen[data-anim="push"] { animation: push-in 0.26s cubic-bezier(0.32, 0.72, 0, 1); }
.screen[data-anim="pop"]  { animation: pop-in  0.26s cubic-bezier(0.32, 0.72, 0, 1); }

@media (prefers-reduced-motion: reduce) {
  .screen[data-anim] { animation: none; }
}

/* --- navigation bar ------------------------------------------------------ */

.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  height: calc(var(--nav-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.navbar__left  { display: flex; align-items: center; gap: 8px; justify-self: start; }
.navbar__right { display: flex; align-items: center; gap: 4px; justify-self: end; }

.navbar__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}
.navbar__title img { width: 20px; height: 20px; border-radius: 4px; }

.navbar__back {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--my-blue);
  font-size: 17px;
  padding: 6px 6px 6px 2px;
}
.navbar__back svg { width: 12px; height: 20px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  color: var(--my-blue);
}
.icon-btn:active { background: var(--fill-quaternary); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[disabled] { opacity: 0.35; cursor: default; }

.nav-timer {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  padding-left: 4px;
}

/* --- ⋯ menu -------------------------------------------------------------- */

.menu {
  position: absolute;
  z-index: 60;
  min-width: 232px;
  padding: 4px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22);
  transform-origin: top right;
  animation: menu-in 0.16s ease-out;
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 16px;
  text-align: left;
}
.menu__item:active { background: var(--fill-quaternary); }
.menu__item[disabled] { opacity: 0.35; cursor: default; }
.menu__item svg { width: 18px; height: 18px; flex: none; }
.menu__item .menu__check { color: var(--my-blue); }
.menu__sep { height: 0.5px; margin: 4px 10px; background: var(--separator); }

.menu-scrim { position: fixed; inset: 0; z-index: 55; }

/* --- iOS-style alert ----------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.28);
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.alert {
  width: 100%;
  max-width: 272px;
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: alert-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes alert-in {
  from { opacity: 0; transform: scale(1.12); }
  to   { opacity: 1; transform: scale(1); }
}
.alert__body { padding: 19px 16px 16px; }
.alert__title { font-size: 17px; font-weight: 600; }
.alert__msg { margin-top: 4px; font-size: 13px; color: var(--label); }
.alert__actions { display: flex; border-top: 0.5px solid var(--separator); }
.alert__actions button {
  flex: 1;
  padding: 11px 8px;
  font-size: 17px;
  color: var(--sys-blue);
}
.alert__actions button + button { border-left: 0.5px solid var(--separator); }
.alert__actions button.is-default { font-weight: 600; }
.alert__actions button.is-destructive { color: var(--sys-red); }

/* --- toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 64px);
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--label);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast.is-leaving { opacity: 0; transition: opacity 0.25s ease; }

/* --- completion + pause cards (shared by every game) --------------------- */

.card-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.result-card {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  border-radius: 16px;
  background: var(--my-blue);
  color: #fff;
  text-align: center;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  animation: alert-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.result-card h2 { margin: 0; font-size: 22px; font-weight: 600; }
.result-card .result-card__time { margin-top: 4px; font-size: 14px; font-weight: 600; }
.result-card .result-card__note { margin-top: 4px; font-size: 12px; font-weight: 600; opacity: 0.95; }
.result-card .result-card__best { margin-top: 8px; font-size: 14px; font-weight: 600; }

.result-card__stars { display: flex; justify-content: center; gap: 8px; padding: 12px 0 4px; }
.result-card__stars svg { width: 30px; height: 30px; color: var(--sys-yellow); }
.result-card__stars svg {
  animation: star-pop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.4) backwards,
             star-pulse 1s ease-in-out 1s infinite alternate;
}
@keyframes star-pop {
  from { transform: scale(0.1) rotate(0deg); }
  to   { transform: scale(1) rotate(360deg); }
}
@keyframes star-pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.1); }
}

.btn-outline {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 20px;
  padding: 10px 16px;
  border: 2px solid #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.btn-outline:active { background: rgba(255, 255, 255, 0.16); }
.btn-outline + .btn-outline { margin-top: 10px; }

.btn-solid-light {
  display: block;
  text-align: center;
  text-decoration: none;
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--my-blue);
  background: #fff;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.share-btn svg { width: 14px; height: 14px; }

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(60, 60, 67, 0.45);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  color: #fff;
}
.pause-overlay svg { width: 50px; height: 50px; }
.pause-overlay h2 { margin: 0; font-size: 28px; font-weight: 700; }
.pause-overlay .btn-outline { width: auto; margin-top: 0; padding: 10px 40px; }

/* --- home page ----------------------------------------------------------- */

.home { padding: 0 0 40px; }
.home__inner { max-width: 720px; margin: 0 auto; padding: 16px; }

.cta-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-elevated);
  box-shadow: var(--card-shadow);
}
.cta-banner img { width: 40px; height: 40px; border-radius: 9px; flex: none; }
.cta-banner__text { flex: 1; min-width: 0; }
.cta-banner__title { font-size: 15px; font-weight: 600; }
.cta-banner__sub { font-size: 13px; color: var(--label-secondary); }
.cta-banner__get {
  flex: none;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--my-blue);
}
.cta-banner__close {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 14px;
  color: var(--label-secondary);
  display: flex; align-items: center; justify-content: center;
}
.cta-banner__close svg { width: 13px; height: 13px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}
.section-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.section-head__spacer { flex: 1; }

.progress-dots { display: flex; gap: 6px; }
.progress-dots i {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--label-tertiary);
  transition: background 0.3s ease;
}

.progress-pill {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
  background: var(--fill-quaternary);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.tile {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 120px;
  padding: 16px;
  border-radius: 16px;
  text-align: left;
  background: var(--tile-bg);
  animation: tile-in 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.15) backwards;
}
@keyframes tile-in {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.tile:active { transform: scale(0.975); transition: transform 0.1s; }

.tile__top { display: flex; align-items: center; gap: 8px; }
.tile__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--tile-color);
  flex: none;
}
.tile__icon svg { width: 21px; height: 21px; }
.tile__top-spacer { flex: 1; }
.tile__check svg { width: 21px; height: 21px; color: var(--tile-color); display: block; }
.tile__streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 600;
}
.tile__streak svg { width: 15px; height: 17px; color: var(--sys-orange); }
.tile__title { margin-top: 8px; font-size: 17px; font-weight: 600; }
.tile__status { margin-top: 2px; font-size: 12px; color: var(--label-secondary); }
.tile__badge {
  align-self: flex-start;
  margin-top: 2px;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tile-color);
  background: color-mix(in srgb, var(--tile-color) 18%, transparent);
}

.get-app {
  margin-top: 28px;
  padding: 22px;
  border-radius: 18px;
  background: var(--bg-elevated);
  box-shadow: var(--card-shadow);
  text-align: center;
}
.get-app img { width: 72px; height: 72px; border-radius: 16px; box-shadow: var(--card-shadow); }
.get-app h3 { margin: 12px 0 4px; font-size: 20px; font-weight: 700; }
.get-app p { margin: 0 auto; max-width: 42ch; font-size: 14px; color: var(--label-secondary); }
.get-app__list {
  display: grid;
  gap: 8px;
  margin: 18px auto;
  padding: 0;
  max-width: 320px;
  text-align: left;
}
.get-app__list li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  list-style: none;
}
.get-app__list svg { width: 16px; height: 16px; color: var(--my-green); flex: none; }

.app-store-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: #000;
  text-decoration: none;
}
@media (prefers-color-scheme: dark) {
  .app-store-badge { background: #fff; color: #000; }
}
.app-store-badge svg { width: 20px; height: 24px; }
.app-store-badge small { display: block; font-size: 10px; font-weight: 400; opacity: 0.85; }

.home__footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--label-secondary);
}
.home__footer a { color: var(--label-secondary); }

/* --- generic page furniture used by game screens ------------------------- */

.game-body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 4px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.page-head__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  border-radius: 12px;
  color: #fff;
  flex: none;
}
.page-head__icon svg { width: 34px; height: 34px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 700; }
.page-head p { margin: 2px 0 0; font-size: 15px; color: var(--label-secondary); }

.loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--label-secondary);
  font-size: 15px;
}
