:root {
  --void: #071018;
  --deep: #0c1a24;
  --panel: rgba(12, 28, 38, 0.72);
  --line: rgba(140, 196, 210, 0.18);
  --text: #e8f2f6;
  --muted: #8aa3b0;
  --gold: #e2b14a;
  --gold-soft: rgba(226, 177, 74, 0.18);
  --cyan: #5ec8d8;
  --cyan-soft: rgba(94, 200, 216, 0.14);
  --danger: #ff6b4a;
  --radius: 14px;
  --font-brand: "Oxanium", sans-serif;
  --font-body: "Sora", sans-serif;
  --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);
  --tap: 44px;
  --page-pad-x: clamp(12px, 4vw, 22px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(226, 177, 74, 0.16), transparent 55%),
    radial-gradient(900px 600px at -10% 20%, rgba(94, 200, 216, 0.12), transparent 50%),
    radial-gradient(700px 500px at 50% 110%, rgba(46, 110, 140, 0.22), transparent 60%),
    linear-gradient(180deg, #050d14 0%, #071018 45%, #0a1620 100%);
  animation: sky-drift 28s ease-in-out infinite alternate;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 20px 30px, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1px 1px at 80px 120px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.2px 1.2px at 160px 60px, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 240px 180px, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.4px 1.4px at 320px 90px, rgba(255, 255, 255, 0.3), transparent);
  background-size: 360px 220px;
  opacity: 0.55;
  animation: stars-twinkle 6s ease-in-out infinite;
}

@keyframes sky-drift {
  from {
    filter: hue-rotate(0deg) saturate(1);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(8deg) saturate(1.08);
    transform: scale(1.03);
  }
}

@keyframes stars-twinkle {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes brand-glow {
  0%,
  100% {
    text-shadow: 0 0 18px rgba(226, 177, 74, 0.25);
  }
  50% {
    text-shadow: 0 0 28px rgba(94, 200, 216, 0.35);
  }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding:
    calc(14px + var(--safe-top))
    calc(var(--page-pad-x) + var(--safe-right))
    calc(24px + var(--safe-bottom))
    calc(var(--page-pad-x) + var(--safe-left));
  min-height: 100vh;
  min-height: 100dvh;
}

.top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 18px;
  animation: rise-in 0.55s ease both;
}

.brand {
  margin: 0;
  grid-column: 2;
  text-align: center;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(1.85rem, 8.5vw, 2.75rem);
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: var(--gold);
  animation: brand-glow 5s ease-in-out infinite;
  white-space: nowrap;
}

.back {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.25rem;
  backdrop-filter: blur(10px);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.back:active {
  transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
  .back:hover {
    border-color: rgba(94, 200, 216, 0.55);
  }
}

.back:focus-visible {
  border-color: rgba(94, 200, 216, 0.55);
  outline: none;
}

.view {
  animation: rise-in 0.45s ease both;
}

.search-form {
  margin: 8px 0 12px;
}

.search-input {
  width: 100%;
  min-height: var(--tap);
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 34, 46, 0.92), rgba(10, 24, 34, 0.88));
  color: var(--text);
  /* >=16px avoids iOS focus zoom; still readable on Android */
  font: 500 16px/1.2 var(--font-body);
  padding: 14px 18px;
  box-shadow: inset 0 0 0 1px rgba(94, 200, 216, 0.05), 0 10px 40px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  outline: none;
  border-color: rgba(94, 200, 216, 0.55);
  box-shadow: 0 0 0 3px var(--cyan-soft), 0 12px 36px rgba(0, 0, 0, 0.28);
}

.hint {
  margin: 0 4px 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 12px 4px;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.15s ease;
  animation: rise-in 0.35s ease both;
}

@media (hover: hover) and (pointer: fine) {
  .result:hover {
    background: var(--cyan-soft);
  }
}

.result:focus-visible {
  background: var(--cyan-soft);
  outline: none;
}

.result:active {
  transform: scale(0.995);
}

.result-icon,
.item-icon,
.chip-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.result-icon.fallback,
.item-icon.fallback,
.chip-icon.fallback {
  display: grid;
  place-items: center;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 0.85rem;
  color: #061018;
}

.result-text {
  min-width: 0;
}

.result-name {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.result-kinds {
  color: var(--gold);
  font-size: 0.72rem;
  font-family: var(--font-brand);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.item-hero {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.item-icon {
  width: 72px;
  height: 72px;
}

.item-name {
  margin: 0 0 6px;
  font-family: var(--font-brand);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.item-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.item-desc {
  margin: 0 0 22px;
  color: #d5e4ea;
  line-height: 1.55;
  font-size: 0.98rem;
}

.section {
  margin: 0 0 22px;
}

.section-title {
  margin: 0 0 10px;
  font-family: var(--font-brand);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}

.recipe {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.recipe:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.recipe-kind {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: var(--font-brand);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recipe-op {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.recipe-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 36px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: 500 0.88rem/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.chip {
  appearance: none;
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover {
    border-color: rgba(94, 200, 216, 0.55);
    background: var(--cyan-soft);
  }
}

.chip:focus-visible {
  border-color: rgba(94, 200, 216, 0.55);
  background: var(--cyan-soft);
  outline: none;
}

.chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.chip-qty {
  color: var(--gold);
  font-family: var(--font-brand);
  font-weight: 700;
}

.arrow {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  margin: 18px 4px;
  color: var(--muted);
}

.status {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.status.error {
  color: var(--danger);
}

.install-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 0 4px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.install-text {
  margin: 0;
  flex: 1 1 180px;
}

.install-text strong {
  color: var(--gold);
  font-weight: 600;
}

.install-btn {
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid rgba(226, 177, 74, 0.45);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font: 700 0.82rem/1 var(--font-brand);
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}

.install-btn:active {
  transform: scale(0.98);
}

.view-item .ad-slot,
.ad-slot {
  margin: 22px 0 8px;
  min-height: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.site-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tip-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  margin-bottom: 12px;
  padding: 0 18px;
  border: 1px solid rgba(226, 177, 74, 0.45);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: var(--font-brand);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .tip-link:hover {
    text-decoration: underline;
  }
}

.tip-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.credit {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.credit a {
  color: var(--cyan);
}

.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;
}

@media (max-width: 380px) {
  .brand {
    font-size: clamp(1.55rem, 9vw, 1.9rem);
    letter-spacing: 0.04em;
  }

  .result {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .result-kinds {
    display: none;
  }

  .item-hero {
    grid-template-columns: 56px 1fr;
  }

  .item-icon {
    width: 56px;
    height: 56px;
  }
}

@media (min-width: 768px) {
  .app {
    max-width: 820px;
  }

  .search-input {
    font-size: 1.05rem;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .brand {
    font-size: 1.45rem;
    letter-spacing: 0.04em;
  }

  .top {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sky,
  .sky::after,
  .brand,
  .view,
  .result,
  .top {
    animation: none !important;
  }
}
