:root {
  --ink: #1d2130;
  --ink-soft: #57596a;
  --paper: #f4efe4;
  --paper-deep: #e9e0d0;
  --card: #fffdf8;
  --line: rgba(29, 33, 48, 0.13);
  --purple: #7161d6;
  --mint: #72c9a6;
  --coral: #f07d68;
  --gold: #efb85a;
  --display: Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 5%, rgba(113, 97, 214, 0.08), transparent 30rem),
    linear-gradient(180deg, #f8f4ec 0, var(--paper) 32rem, #eee6da 100%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { color: inherit; font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  height: calc(76px + env(safe-area-inset-top));
  align-items: flex-end;
  justify-content: space-between;
  padding: env(safe-area-inset-top) clamp(18px, 4vw, 44px) 14px;
  border-bottom: 1px solid rgba(29, 33, 48, 0.07);
  background: rgba(248, 244, 236, 0.88);
  backdrop-filter: blur(20px) saturate(1.2);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0; background: none; text-align: left; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 13px; letter-spacing: 0.1em; }
.brand small { color: var(--ink-soft); font-size: 8px; font-weight: 700; letter-spacing: 0.21em; }
.brand-mark, .install-icon {
  display: grid;
  width: 36px;
  height: 36px;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-2deg);
}
.brand-mark i, .install-icon i { border-radius: 3px; background: var(--purple); }
.brand-mark i:nth-child(2), .install-icon i:nth-child(2) { background: var(--coral); }
.brand-mark i:nth-child(3), .install-icon i:nth-child(3) { background: var(--gold); }
.brand-mark i:nth-child(4), .install-icon i:nth-child(4) { background: var(--mint); }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.streak-pill { display: flex; min-height: 36px; align-items: center; gap: 6px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.54); color: var(--coral); font-size: 12px; }
.streak-pill b { color: var(--ink); }
.circle-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.58); font-size: 18px; }

main { position: relative; display: block; width: 100%; overflow-x: clip; }
.screen { display: none; width: min(1120px, 100%); margin: 0 auto; padding: 22px clamp(16px, 4vw, 44px) 50px; }
.screen.active { display: block; }

.welcome-line { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 16px; color: var(--ink-soft); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.today-hero {
  position: relative;
  display: grid;
  min-height: 390px;
  overflow: hidden;
  padding: 34px 28px 26px;
  border: 2px solid var(--ink);
  border-radius: 30px;
  background:
    radial-gradient(circle at 78% 17%, rgba(255,255,255,.26) 0 6%, transparent 6.5%),
    radial-gradient(circle at 84% 25%, rgba(255,255,255,.18) 0 3%, transparent 3.5%),
    linear-gradient(145deg, #8271df, #6557c4 58%, #5547aa);
  color: #fffdf8;
  box-shadow: 7px 8px 0 var(--ink);
  isolation: isolate;
}
.today-hero::before, .today-hero::after { position: absolute; z-index: -1; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; content: ""; }
.today-hero::before { width: 260px; height: 260px; top: -100px; right: -70px; box-shadow: 0 0 0 34px rgba(255,255,255,.04), 0 0 0 70px rgba(255,255,255,.035); }
.today-hero::after { width: 150px; height: 150px; right: 55px; bottom: -108px; box-shadow: 0 0 0 28px rgba(255,255,255,.04); }
.hero-orbit {
  position: absolute;
  top: 30px;
  right: 26px;
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#f6c363 var(--progress), rgba(255,255,255,.18) 0);
}
.hero-orbit::before { position: absolute; width: 52px; height: 52px; border-radius: 50%; background: #7161ce; content: ""; }
.hero-orbit span { position: relative; font-size: 12px; font-weight: 800; }
.hero-copy { align-self: end; max-width: 540px; padding-top: 90px; }
.hero-copy p { margin: 0 0 12px; color: #f6d99b; font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.hero-copy h1 { max-width: 480px; margin: 0; font-family: var(--display); font-size: clamp(39px, 10vw, 70px); line-height: .98; letter-spacing: -.04em; }
.hero-copy > span { display: block; margin-top: 16px; color: rgba(255,255,255,.76); font-size: 14px; }
.today-hero > button { display: flex; width: 100%; min-height: 52px; align-self: end; align-items: center; justify-content: space-between; margin-top: 28px; padding: 0 18px; border-radius: 15px; background: #fffdf8; color: var(--ink); font-weight: 800; box-shadow: 0 4px 0 rgba(29,33,48,.44); }
.today-hero > button b { font-size: 22px; }

.section-block, .library-section { margin-top: 44px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.section-heading small, .screen-heading small, .roadmap > small, .install-card small, .game-topbar small, .lab-banner small, .coming-row > span { color: var(--purple); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.section-heading h2, .install-card h2, .lab-banner h2 { margin: 5px 0 0; font-family: var(--display); font-size: 27px; letter-spacing: -.02em; }
.section-heading > button, .section-heading > span { padding: 7px 0; background: none; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.section-heading > button { min-width: 44px; min-height: 44px; }
.continue-card { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 16px; padding: 16px; border: 2px solid var(--ink); border-radius: 22px; background: var(--card); box-shadow: 5px 6px 0 var(--ink); }
.continue-art { display: grid; min-height: 84px; place-items: center; border-radius: 15px; background: var(--card-accent); color: #fff; font-family: var(--display); font-size: 38px; }
.continue-card small { color: var(--ink-soft); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.continue-card h3 { margin: 4px 0; font-family: var(--display); font-size: 24px; }
.continue-card p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.continue-card > button { grid-column: 1 / -1; display: flex; min-height: 46px; align-items: center; justify-content: space-between; padding: 0 16px; border-radius: 13px; background: var(--ink); color: white; font-weight: 800; }

.card-grid { display: grid; gap: 14px; }
.game-card { position: relative; min-width: 0; border: 2px solid var(--ink); border-radius: 22px; background: var(--card); box-shadow: 4px 5px 0 var(--ink); transition: transform 150ms ease, box-shadow 150ms ease; }
.game-card:has(.game-card-main:active) { transform: translate(2px, 2px); box-shadow: 2px 3px 0 var(--ink); }
.game-card-main { display: grid; width: 100%; grid-template-columns: 78px minmax(0, 1fr); gap: 15px; align-items: center; padding: 14px 46px 14px 14px; background: none; text-align: left; }
.game-card.planned { border-style: dashed; box-shadow: none; opacity: .74; }
.game-card.planned .game-card-main { cursor: default; }
.game-art { display: grid; width: 78px; height: 88px; place-items: center; border-radius: 16px; background: var(--card-accent); color: white; font-family: var(--display); font-size: 35px; font-weight: 700; box-shadow: inset 0 -6px 0 rgba(29,33,48,.11); }
.game-copy { display: grid; min-width: 0; }
.game-copy small { color: var(--ink-soft); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.game-copy strong { margin-top: 4px; font-family: var(--display); font-size: 22px; line-height: 1.1; }
.game-copy > span { margin-top: 6px; overflow: hidden; color: var(--ink-soft); font-size: 11px; line-height: 1.35; text-overflow: ellipsis; }
.game-copy em { width: max-content; margin-top: 9px; padding: 4px 7px; border-radius: 6px; background: color-mix(in srgb, var(--card-accent) 14%, transparent); color: var(--ink-soft); font-size: 9px; font-style: normal; font-weight: 800; }
.game-copy em.done { background: rgba(67,160,120,.15); color: #267a59; }
.favorite-button { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: transparent; color: #c9c3b7; font-size: 17px; }
.favorite-button.active { color: var(--coral); }

.lab-banner { display: grid; gap: 15px; margin-top: 44px; padding: 26px; border: 2px solid var(--ink); border-radius: 26px; background: #242838; color: white; box-shadow: 6px 7px 0 #7565cf; }
.lab-banner p { margin: 10px 0 0; color: rgba(255,255,255,.68); font-size: 13px; line-height: 1.55; }
.lab-banner button { min-height: 46px; padding: 0 15px; border-radius: 13px; background: #f5c15f; color: var(--ink); font-weight: 800; }
.lab-art { display: flex; height: 64px; align-items: end; gap: 10px; }
.lab-art span { display: block; width: 45px; border: 2px solid rgba(255,255,255,.55); border-radius: 50% 50% 9px 9px; background: #6d5dcc; }
.lab-art span:nth-child(1) { height: 40px; }
.lab-art span:nth-child(2) { height: 62px; background: var(--coral); }
.lab-art span:nth-child(3) { height: 48px; background: var(--mint); }

.screen-heading { max-width: 660px; margin: 12px 0 30px; }
.screen-heading h1 { margin: 7px 0 5px; font-family: var(--display); font-size: clamp(42px, 10vw, 72px); line-height: 1; letter-spacing: -.045em; }
.screen-heading p { max-width: 520px; margin: 10px 0 0; color: var(--ink-soft); line-height: 1.55; }
.daily-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 28px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.45); }
.daily-summary div { display: grid; gap: 2px; padding: 4px 9px; border-right: 1px solid var(--line); text-align: center; }
.daily-summary div:last-child { border-right: 0; }
.daily-summary strong { font-family: var(--display); font-size: 23px; }
.daily-summary span { color: var(--ink-soft); font-size: 8px; font-weight: 700; }
.coming-row { display: grid; gap: 12px; margin-top: 34px; }
.filter-pills { display: flex; gap: 8px; margin: -10px 0 24px; overflow-x: auto; padding: 2px 0 8px; }
.filter-pills button { min-width: max-content; min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.45); color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.filter-pills button.active { border-color: var(--ink); background: var(--ink); color: white; }
.planned-grid { display: grid; gap: 14px; margin-top: 14px; }

.roadmap { margin-top: 52px; padding: 28px 20px; border-radius: 26px; background: #242838; color: white; }
.roadmap > small { color: #f2c467; }
.roadmap > h2 { max-width: 600px; margin: 6px 0 26px; font-family: var(--display); font-size: 35px; }
.roadmap-columns { display: grid; gap: 18px; }
.roadmap-columns > div { padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); }
.roadmap-number { color: #f2c467; font-family: var(--display); font-size: 13px; }
.roadmap h3 { margin: 8px 0 6px; font-family: var(--display); font-size: 21px; }
.roadmap p { margin: 0; color: rgba(255,255,255,.66); font-size: 12px; line-height: 1.55; }
.big-game-card { margin-top: 26px; padding: 20px; border: 1px solid rgba(255,255,255,.18); border-radius: 20px; background: linear-gradient(135deg, rgba(113,97,214,.56), rgba(240,125,104,.25)); }
.big-game-badge { font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.big-game-card button { width: 100%; min-height: 44px; margin-top: 18px; border-radius: 12px; background: white; color: var(--ink); font-weight: 800; }
.install-card { display: grid; grid-template-columns: 52px 1fr; gap: 16px; align-items: start; margin-top: 34px; padding: 20px; border: 2px solid var(--ink); border-radius: 22px; background: var(--card); box-shadow: 4px 5px 0 var(--ink); }
.install-icon { width: 48px; height: 48px; }
.install-card h2 { font-size: 23px; }
.install-card p { margin: 8px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.install-card > button { grid-column: 1 / -1; min-height: 46px; border-radius: 12px; background: var(--purple); color: white; font-weight: 800; }

.tabbar {
  position: fixed;
  z-index: 80;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  max-width: 620px;
  height: 68px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 auto;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 21px;
  background: rgba(255,253,248,.94);
  box-shadow: 4px 5px 0 var(--ink);
  backdrop-filter: blur(20px);
  isolation: isolate;
  transition: transform 200ms ease;
}
.tabbar::before { position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 2); border-radius: 14px; background: var(--ink); content: ""; transform: translateX(0); transition: transform 340ms cubic-bezier(.2,.8,.2,1); }
.tabbar[data-active-tab="library"]::before { transform: translateX(100%); }
.tabbar.hidden { transform: translateY(calc(110% + env(safe-area-inset-bottom))); }
.tab { position: relative; z-index: 1; display: grid; place-items: center; align-content: center; gap: 4px; border-radius: 14px; background: transparent; color: #77766f; font-size: 9px; font-weight: 700; transition: color 220ms ease; }
.tab.active { background: transparent; color: white; }
.tab-icon { position: relative; display: block; width: 22px; height: 20px; font-size: 8px; }
.home-icon::before { position: absolute; inset: 5px 3px 1px; border: 2px solid currentColor; border-top: 0; border-radius: 2px; content: ""; }
.home-icon::after { position: absolute; width: 12px; height: 12px; top: 1px; left: 5px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; content: ""; transform: rotate(45deg); }
.calendar-icon { display: grid; place-items: center; border: 2px solid currentColor; border-radius: 4px; }
.arcade-icon::before { position: absolute; inset: 5px 0 0; border: 2px solid currentColor; border-radius: 8px 8px 5px 5px; content: ""; }
.arcade-icon::after { position: absolute; width: 4px; height: 4px; top: 9px; left: 5px; border-radius: 50%; background: currentColor; box-shadow: 8px 1px 0 currentColor; content: ""; }
.shelf-icon { border-right: 3px solid currentColor; border-bottom: 3px solid currentColor; border-left: 3px solid currentColor; }
.shelf-icon::before { position: absolute; inset: 0 2px 4px; border-right: 2px solid currentColor; border-left: 2px solid currentColor; content: ""; }

.game-screen { display: none; min-height: calc(100vh - 76px); }
.game-screen.active { display: block; }
.game-topbar { position: sticky; z-index: 45; top: calc(76px + env(safe-area-inset-top)); display: grid; height: 64px; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); background: rgba(244,239,228,.93); backdrop-filter: blur(18px); }
.game-topbar > button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); font-size: 20px; font-weight: 700; }
.game-topbar > div { display: grid; text-align: center; }
.game-topbar small { color: var(--game-accent); }
.game-topbar strong { margin-top: 2px; font-family: var(--display); font-size: 18px; }
.game-mount { width: min(760px, 100%); min-height: calc(100vh - 150px); margin: 0 auto; padding: 20px 16px calc(30px + env(safe-area-inset-bottom)); }

.modal-backdrop { position: fixed; z-index: 150; inset: 0; display: grid; align-items: end; padding: 12px; background: rgba(29,33,48,.55); backdrop-filter: blur(6px); animation: fade-in 180ms ease; }
@keyframes fade-in { from { opacity: 0; } }
.modal-sheet { position: relative; width: min(520px, 100%); max-height: 88vh; margin: 0 auto; overflow: auto; padding: 28px 22px max(22px, env(safe-area-inset-bottom)); border: 2px solid var(--ink); border-radius: 28px; background: var(--card); box-shadow: 7px 8px 0 var(--ink); }
.modal-sheet > small { color: var(--purple); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.modal-sheet h2 { max-width: 380px; margin: 8px 0 22px; font-family: var(--display); font-size: 31px; line-height: 1.05; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; background: var(--paper-deep); font-size: 21px; }
.install-steps { display: grid; gap: 15px; margin: 0; padding: 0; list-style: none; }
.install-steps li { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: center; }
.install-steps li > b { display: grid; width: 36px; height: 36px; place-items: center; border: 2px solid var(--ink); border-radius: 11px; background: #f4c463; box-shadow: 2px 2px 0 var(--ink); }
.install-steps div { display: grid; gap: 3px; }
.install-steps strong { font-size: 13px; }
.install-steps span { color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.primary-button { width: 100%; min-height: 50px; margin-top: 24px; border-radius: 14px; background: var(--ink); color: white; font-weight: 800; }
.toast { position: fixed; z-index: 300; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; max-width: calc(100% - 32px); padding: 11px 16px; border: 2px solid var(--ink); border-radius: 999px; background: var(--ink); color: white; font-size: 12px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 680px) {
  .screen { padding-top: 34px; }
  .today-hero { min-height: 440px; padding: 42px; }
  .hero-orbit { top: 42px; right: 42px; }
  .today-hero > button { width: 230px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card.compact:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .continue-card { grid-template-columns: 100px minmax(0, 1fr) 130px; align-items: center; }
  .continue-art { min-height: 100px; }
  .continue-card > button { grid-column: auto; }
  .lab-banner { grid-template-columns: 150px 1fr auto; align-items: center; }
  .lab-banner button { padding: 0 20px; }
  .roadmap-columns { grid-template-columns: repeat(3, 1fr); }
  .install-card { grid-template-columns: 52px 1fr auto; align-items: center; }
  .install-card > button { grid-column: auto; min-width: 110px; }
}

@media (min-width: 1040px) {
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .daily-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .planned-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-hero { min-height: 470px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: light; }
}
