/* Nono Cats — foundations: tokens, reset, app shell, navigation, loading.
   @font-face declarations are embedded in css/fonts.css for file:// use. */

:root {
  --font-body: 'Nunito', 'Trebuchet MS', sans-serif;
  --font-pixel: 'Pixelify Sans', 'Trebuchet MS', sans-serif;
  --cream: #f6efe5;
  --cream-deep: #efe5d7;
  --paper: #fffaf2;
  --card: #fffdf9;
  --ink: #41352e;
  --ink-soft: #77685d;
  --ink-faint: #a4978b;
  --line: rgba(79, 62, 49, 0.1);
  --line-strong: rgba(79, 62, 49, 0.16);
  --peach: #e7a48e;
  --peach-soft: #f4d7c9;
  --peach-deep: #b96f5b;
  --sage: #a8b99d;
  --sage-soft: #e6ecdf;
  --blue: #8ca9b9;
  --blue-soft: #e3ebef;
  --gold: #d8b568;
  --gold-soft: #f4eaca;
  --lavender: #b7a3c7;
  --lavender-soft: #eee7f3;
  --danger: #c67566;
  --danger-soft: #f7e3de;
  --paint: #809dad;
  --paint-deep: #5d7f91;
  --cross: #c7856f;
  --card-radius: 26px;
  --panel-radius: 20px;
  --btn-radius: 16px;
  --shadow-soft: 0 14px 34px rgba(96, 73, 53, 0.08);
  --shadow-card: 0 3px 0 rgba(103, 79, 58, 0.06), 0 14px 32px rgba(96, 73, 53, 0.07);
  --shadow-button: 0 4px 0 rgba(74, 52, 39, 0.22);
  --nav-h: 70px;
  --page-pad: clamp(14px, 3.2vw, 32px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

html {
  height: 100dvh;
}

body {
  height: 100dvh;
  min-height: 100%;
  position: relative;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(1100px 760px at 6% -10%, #f7e2d0 0, rgba(247, 226, 208, 0) 62%),
    radial-gradient(900px 700px at 104% 12%, #e6ede0 0, rgba(230, 237, 224, 0) 58%),
    radial-gradient(720px 560px at 50% 110%, #f2e4d5 0, rgba(242, 228, 213, 0) 60%),
    var(--cream);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: radial-gradient(rgba(116, 94, 74, 0.11) 0.75px, transparent 0.75px);
  background-size: 18px 18px;
  z-index: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

h1, h2, h3, h4, p {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

canvas {
  display: block;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

svg.icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

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

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.screen-host {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  z-index: 1;
}

.screen.active {
  display: flex;
  animation: screen-in 0.32s cubic-bezier(0.22, 0.8, 0.26, 1) both;
}

.screen-inner {
  width: 100%;
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + var(--page-pad))
    calc(var(--safe-bottom) + var(--nav-h) + 12px) calc(var(--safe-left) + var(--page-pad));
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.game-screen .screen-inner {
  padding-bottom: calc(var(--safe-bottom) + 8px);
}

.screen-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.screen-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.noscroll {
  overflow: hidden;
}

/* Top bars */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  flex: none;
  margin-bottom: clamp(10px, 1.8vh, 18px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar-left {
  min-width: 0;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.topbar-title h1 {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: clamp(23px, 3vw, 30px);
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title .eyebrow {
  margin-bottom: 1px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--ink);
  color: #ffe7c9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 rgba(74, 52, 39, 0.16);
  flex: none;
}

.brand-mark .icon {
  width: 31px;
  height: 31px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: clamp(24px, 3.1vw, 32px);
  line-height: 0.98;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.brand-name span {
  color: var(--peach-deep);
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Navigation */
.app-nav {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 10px);
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px - var(--safe-left) - var(--safe-right)));
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 7px;
  border-radius: 24px;
  background: rgba(255, 250, 242, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 14px 34px rgba(85, 64, 45, 0.14), inset 0 0 0 1px rgba(96, 74, 55, 0.04);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.app.nav-hidden .app-nav {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
}

.nav-btn {
  position: relative;
  border-radius: 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.nav-btn .icon {
  width: 23px;
  height: 23px;
}

.nav-btn:hover {
  color: var(--ink);
  background: rgba(239, 228, 214, 0.45);
}

.nav-btn:active {
  transform: scale(0.96);
}

.nav-btn.active {
  color: var(--ink);
  background: #f3e5d7;
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--peach-deep);
}

.nav-btn:focus-visible,
.icon-btn:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.wallet-pill:focus-visible,
.pill-btn:focus-visible,
.level-card:focus-visible,
.cat-card:focus-visible,
.pack-tab:focus-visible,
.seg-btn:focus-visible,
.tool-btn:focus-visible {
  outline: 3px solid rgba(185, 111, 91, 0.48);
  outline-offset: 2px;
}

/* Loading */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background:
    radial-gradient(800px 600px at 50% 38%, #fff8ed 0, rgba(255, 248, 237, 0.55) 50%, rgba(246, 239, 229, 0) 75%),
    var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loading-brand .brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 19px;
}

.loading-brand .brand-mark .icon {
  width: 42px;
  height: 42px;
}

.loading-title {
  font-family: var(--font-pixel);
  font-size: clamp(36px, 8vw, 54px);
  line-height: 1;
  color: var(--ink);
}

.loading-title span {
  color: var(--peach-deep);
}

.loading-cat {
  width: 84px;
  height: 72px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
  transform: translateY(3px);
  animation: cat-float 2.4s ease-in-out infinite;
}

.loading-cat span {
  border-radius: 5px;
  background: var(--ink);
  opacity: 0.9;
  animation: cat-cell 1.5s ease-in-out infinite alternate;
}

.loading-cat span:nth-child(1),
.loading-cat span:nth-child(3) {
  background: var(--peach-deep);
  border-radius: 10px 10px 3px 3px;
}

.loading-cat span:nth-child(2) {
  background: transparent;
}

.loading-cat span:nth-child(4),
.loading-cat span:nth-child(6) {
  background: transparent;
  position: relative;
}

.loading-cat span:nth-child(4)::before,
.loading-cat span:nth-child(6)::before {
  content: '';
  position: absolute;
  inset: 34% 25%;
  border-radius: 50%;
  background: var(--ink);
}

.loading-cat span:nth-child(5) {
  border-radius: 7px;
}

.loading-cat span:nth-child(7) {
  background: transparent;
}

.loading-cat span:nth-child(8) {
  border-radius: 50% 50% 6px 6px;
  background: var(--peach);
}

.loading-cat span:nth-child(9) {
  background: transparent;
}

.loading-dots {
  display: flex;
  gap: 5px;
  margin-top: 2px;
}

.loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: dot-bounce 1.2s infinite ease-in-out;
}

.loading-dots i:nth-child(2) { animation-delay: 0.15s; }
.loading-dots i:nth-child(3) { animation-delay: 0.3s; }

.loading-text {
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.01em;
}

body,
canvas {
  -webkit-touch-callout: none;
}

.noscript-note {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--cream);
  color: var(--ink);
  padding: 30px;
  text-align: center;
}

/* shared generic utilities */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  line-height: 1.2;
}
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Animations */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cat-float {
  0%, 100% { transform: translateY(3px) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
}
@keyframes cat-cell {
  from { transform: scale(0.94); opacity: 0.7; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes soft-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to { background-position: 200% 0; }
}
@keyframes hand-bob {
  0%, 100% { transform: translate(-50%, -20%) rotate(-8deg); }
  50% { transform: translate(-50%, -35%) rotate(-2deg); }
}
@keyframes guide-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 162, 94, 0.42); }
  50% { box-shadow: 0 0 0 6px rgba(214, 162, 94, 0.08); }
}

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

@media (max-width: 720px) {
  :root {
    --nav-h: 64px;
    --card-radius: 22px;
    --page-pad: 15px;
  }
  .screen-inner {
    padding-top: calc(var(--safe-top) + 9px);
  }
  .topbar {
    min-height: 44px;
    margin-bottom: 10px;
  }
  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }
  .brand-mark .icon {
    width: 28px;
    height: 28px;
  }
  .brand-sub {
    display: none;
  }
  .app-nav {
    bottom: calc(var(--safe-bottom) + 7px);
    border-radius: 22px;
    padding: 6px;
  }
  .nav-btn {
    font-size: 9.5px;
    border-radius: 15px;
  }
  .nav-btn .icon {
    width: 21px;
    height: 21px;
  }
}

@media (max-height: 570px) and (orientation: landscape) {
  :root {
    --nav-h: 56px;
    --page-pad: 16px;
  }
  .screen-inner {
    padding-top: calc(var(--safe-top) + 6px);
  }
  .topbar {
    min-height: 38px;
    margin-bottom: 7px;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }
  .brand-name {
    font-size: 23px;
  }
  .nav-btn {
    flex-direction: row;
    gap: 6px;
    font-size: 10px;
  }
  .nav-btn .icon {
    width: 19px;
    height: 19px;
  }
  .nav-btn.active::after {
    display: none;
  }
  .app-nav {
    bottom: calc(var(--safe-bottom) + 5px);
    height: var(--nav-h);
  }
}

/* lock scrolling when a modal is open */
body.modal-open .screen-host {
  filter: blur(1.5px) saturate(0.9);
}
body.poki-ad-active #app {
  pointer-events: none !important;
}
