:root {
  --cream: #f3eee4;
  --ink: #14141a;
  --blue: #0053db;
  --blue-deep: #003ea8;
  --yellow: #fed01b;
  --orange: #ff7a3d;
  --green: #22c55e;
  --purple: #a855f7;
  --border-w: 2px;
  --shadow-off: 4px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background-color: var(--blue);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  padding: clamp(12px, 3vw, 32px);
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.frame {
  max-width: 1640px;
  margin: 0 auto;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 40px;
  overflow: hidden;
  box-shadow: 0 0 0 8px rgba(0, 83, 219, 0.25);
  display: flex;
  flex-direction: column;
}

/* Ticker */
.ticker {
  background: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  border-bottom: 3px solid var(--ink);
}

.ticker__track {
  display: inline-flex;
  gap: 2.5rem;
  padding: 0.6rem 0;
  animation: marquee 32s linear infinite;
  color: var(--cream);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ticker__half {
  display: inline-flex;
  align-items: center;
  gap: 2.5rem;
  white-space: nowrap;
}

.ticker__item {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.ticker__item:hover,
.ticker__item:focus-visible {
  color: var(--yellow);
  text-decoration: underline;
}

.ticker__track .sep {
  color: var(--yellow);
}

.ticker:hover .ticker__track,
.ticker:focus-within .ticker__track {
  animation-play-state: paused;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem clamp(1.25rem, 3vw, 2.5rem);
  border-bottom: 3px solid var(--ink);
  gap: 1rem;
  flex-wrap: wrap;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Search field (shared look for header + browse overlay) */
.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
}

.search-field__icon {
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.6;
}

.search-field input {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
}

.search-field input::placeholder {
  color: rgba(20, 20, 26, 0.45);
  font-weight: 500;
}

/* Header search + live results dropdown */
.search {
  position: relative;
  flex: 1 1 220px;
  min-width: 160px;
  max-width: 360px;
}

.search__results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 4px 4px 0 0 var(--ink);
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
  padding: 0.4rem;
}

.search__results[hidden] {
  display: none;
}

.search__result {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  font-family: inherit;
}

.search__result:hover,
.search__result:focus-visible {
  background: rgba(20, 20, 26, 0.07);
}

.search__result-emoji {
  font-size: 1.2rem;
  line-height: 1.3;
  flex-shrink: 0;
}

.search__result-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.search__result-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.search__result-desc {
  font-size: 0.78rem;
  color: rgba(20, 20, 26, 0.6);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search__empty {
  margin: 0;
  padding: 0.6rem;
  font-size: 0.85rem;
  color: rgba(20, 20, 26, 0.6);
  text-align: center;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand__name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
}

.btn {
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn--pill {
  background: var(--yellow);
  color: var(--ink);
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
}

.btn--ghost {
  background: #fff;
}

.btn--pill:hover,
.btn--hero:hover,
.tile:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--ink);
}

/* Main layout */
.main {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  flex: 1;
}

.hero {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
}

.chip {
  display: inline-flex;
  align-self: flex-start;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero__title {
  font-size: clamp(2.1rem, 4.4vw, 3.6rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.hero__title .hl {
  color: var(--blue);
}

.hero__sub {
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 34rem;
  color: rgba(20, 20, 26, 0.75);
  margin: 0;
}

.btn--hero {
  background: var(--ink);
  color: var(--cream);
  padding: 1.1rem 1.75rem;
  border-radius: 999px;
  font-size: 1.15rem;
  width: fit-content;
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 rgba(0,0,0,0.6);
  margin-top: 0.25rem;
}

.btn--hero:hover {
  background: var(--blue);
}

.arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.btn--hero:hover .arrow,
.btn--pill:hover .arrow {
  transform: translate(2px, -2px);
}

.dice {
  display: inline-block;
  font-size: 1.15em;
  transition: transform 0.2s ease;
}

.btn--hero:hover .dice,
.btn--pill:hover .dice {
  transform: rotate(-14deg);
}

/* Category tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.tile {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem;
  box-shadow: 2px 2px 0 0 var(--ink);
  font-weight: 700;
}

.tile__emoji {
  font-size: 1.9rem;
  line-height: 1;
}

.tile__label {
  font-size: 0.85rem;
}

.tile--games { background: #b4c5ff; }
.tile--weird { background: var(--yellow); }
.tile--creative { background: var(--orange); color: var(--ink); }
.tile--explore { background: var(--green); }
.tile--useful { background: var(--purple); color: #fff; }

/* Recently viewed history panel */
.history {
  flex: 1 1 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--ink);
  border-radius: 32px;
  background: var(--ink);
  color: var(--cream);
  padding: 1.25rem;
  min-height: 380px;
}

.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.history__title {
  margin: 0;
  font-size: 1.1rem;
}

.history__clear {
  background: none;
  border: none;
  color: var(--cream);
  opacity: 0.6;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
  padding: 0.2rem;
}

.history__clear:hover {
  opacity: 1;
}

.history__list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  flex: 1;
}

.history__list:empty {
  display: none;
}

.history__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  color: var(--cream);
  transition: background 0.15s ease, transform 0.15s ease;
}

.history__item:hover,
.history__item:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  transform: translateX(2px);
}

.history__item-emoji {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.history__item-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.history__item-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.history__item-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.history__empty {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.7;
}

.history__empty[hidden] {
  display: none;
}

/* Footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem clamp(1.25rem, 3vw, 2.5rem);
  border-top: 3px solid var(--ink);
}

.footer__count {
  font-size: 0.85rem;
  font-weight: 700;
}

.footer__copy {
  font-size: 0.8rem;
  color: rgba(20, 20, 26, 0.6);
  margin: 0;
}

body.no-scroll {
  overflow: hidden;
}

/* Overlays (Browse + Preview) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 26, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 32px);
  z-index: 1000;
}

.overlay[hidden] {
  display: none;
}

.overlay__panel {
  position: relative;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 32px;
  box-shadow: 8px 8px 0 0 var(--ink);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.overlay__panel--browse {
  max-width: 960px;
}

.overlay__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.overlay__title {
  margin: 0;
  font-size: 1.5rem;
}

.overlay__close {
  flex-shrink: 0;
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 0 var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.overlay__close:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Preview overlay */
.overlay__panel--preview {
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.overlay__panel--preview .overlay__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.preview__emoji {
  font-size: 3rem;
  line-height: 1;
  margin-top: 0.5rem;
}

.preview__category {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--blue);
}

.preview__name {
  font-size: 1.75rem;
  margin: 0;
  line-height: 1.15;
}

.preview__desc {
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(20, 20, 26, 0.75);
  margin: 0;
}

.preview__actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.5rem;
}

.preview__actions .btn--hero,
.preview__actions .btn--pill {
  width: 100%;
  justify-content: center;
}

/* Browse overlay */
.browse__search {
  margin-bottom: 1.25rem;
}

.browse__section {
  margin-bottom: 0.75rem;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.browse__section[hidden] {
  display: none;
}

.browse__section:last-child {
  margin-bottom: 0;
}

.browse__heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  margin: 0;
  padding: 0.85rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.browse__heading::-webkit-details-marker {
  display: none;
}

.browse__heading::after {
  content: "\25BE";
  margin-left: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.browse__section[open] .browse__heading::after {
  transform: rotate(180deg);
}

.browse__heading-emoji {
  font-size: 1.3rem;
}

.browse__heading-label {
  flex: 1;
  min-width: 0;
}

.browse__count {
  font-size: 0.7rem;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-weight: 700;
}

.browse__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0 1rem 1rem;
}

.browse__card[hidden] {
  display: none;
}

.browse__card {
  text-align: left;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 2px 2px 0 0 var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.browse__card:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.browse__card-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.browse__card-desc {
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(20, 20, 26, 0.65);
}

/* Submit a site page */
.submit-page {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.25rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.submit-page__title {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0;
  font-weight: 700;
  line-height: 1.1;
}

.submit-page__sub {
  font-size: 1.05rem;
  line-height: 1.55;
  color: rgba(20, 20, 26, 0.75);
  margin: 0 0 0.5rem;
  max-width: 34rem;
}

.submit-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.submit-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.submit-form__field input,
.submit-form__field select,
.submit-form__field textarea {
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 500;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.submit-form__field input:focus,
.submit-form__field select:focus,
.submit-form__field textarea:focus {
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
}

.submit-form__note {
  font-size: 0.85rem;
  color: rgba(20, 20, 26, 0.6);
  line-height: 1.5;
  margin: 0.25rem 0 0;
}

.submit-form__note a {
  text-decoration: underline;
}

.submit-status {
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--green);
  color: #fff;
  padding: 1rem 1.25rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
}

.submit-status[hidden] {
  display: none;
}

/* Responsive */
@media (max-width: 900px) {
  .main {
    flex-direction: column;
  }

  .history {
    min-height: 220px;
  }

  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .frame {
    border-radius: 28px;
  }

  .header {
    padding: 1rem 1.25rem;
  }

  .search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .header__actions {
    width: 100%;
  }

  .header__actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

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

  .btn--hero {
    width: 100%;
    justify-content: space-between;
  }

  .footer {
    justify-content: center;
    text-align: center;
  }

  .browse__grid {
    grid-template-columns: 1fr;
  }

  .overlay__panel {
    border-radius: 24px;
  }
}
