/* playrush — light, tile-based game portal */

:root {
  --bg: #f0f4f9;
  --panel: #ffffff;
  --text: #073a7a;
  --heading: #052c5e;
  --dim: #7c8aa8;
  --brand: #0a8cff;
  --brand-dark: #0673d6;
  --tile-radius: 14px;
  --shadow-sm: 0 1px 4px rgba(9, 39, 84, .10);
  --shadow-md: 0 4px 14px rgba(9, 39, 84, .14);
  --shadow-lg: 0 10px 28px rgba(9, 39, 84, .20);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 26px;
  background: rgba(240, 244, 249, .9);
  backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.logo-mark { width: 36px; height: 36px; display: block; }
.logo-mark.small { width: 22px; height: 22px; }
.logo-text {
  font-weight: 900;
  font-size: 1.55rem;
  letter-spacing: -.6px;
  color: var(--heading);
}
.logo:hover .logo-text { color: var(--brand); }

.search-wrap {
  flex: 1;
  max-width: 440px;
  position: relative;
  margin-left: auto;
}
.search-icon {
  position: absolute;
  left: 15px; top: 50%;
  translate: 0 -50%;
  width: 16px; height: 16px;
  color: var(--dim);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 11px 18px 11px 42px;
  border-radius: 99px;
  border: 2px solid transparent;
  background: var(--panel);
  color: var(--heading);
  font: 700 .93rem "Nunito", sans-serif;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
#searchInput::placeholder { color: var(--dim); font-weight: 600; }
#searchInput:focus { border-color: var(--brand); box-shadow: var(--shadow-md); }

.random-btn {
  padding: 11px 22px;
  border: none;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
  font: 800 .9rem "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s, box-shadow .15s, transform .15s;
  white-space: nowrap;
}
.random-btn:hover { background: var(--brand-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.random-btn:active { transform: none; }

/* ---- category chips ---- */
.cats {
  position: sticky;
  top: 64px;
  z-index: 40;
  display: flex;
  gap: 8px;
  padding: 8px 26px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(rgba(240, 244, 249, .96), rgba(240, 244, 249, .82) 75%, transparent);
}
.cats::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 17px;
  border-radius: 99px;
  border: none;
  background: var(--panel);
  color: var(--text);
  font: 800 .86rem "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .13s, background .13s, box-shadow .13s;
}
.chip:hover { color: var(--brand); box-shadow: var(--shadow-md); }
.chip.active { background: var(--brand); color: #fff; }

/* ---- main ---- */
#main { position: relative; padding: 8px 26px 40px; max-width: 1500px; margin: 0 auto; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 4px 14px;
}
.section-head h2 {
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: -.3px;
  color: var(--heading);
}
.count { color: var(--dim); font-weight: 700; font-size: .86rem; }

/* ---- mosaic game grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

.card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--tile-radius);
  overflow: hidden;
  cursor: pointer;
  background: #dde6f2;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover {
  transform: scale(1.035);
  box-shadow: var(--shadow-lg);
  z-index: 2;
}
.card.big { grid-column: span 2; grid-row: span 2; }

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #dde6f2 40%, #e9eff8 50%, #dde6f2 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
/* stop the placeholder animation once the thumb is in — dozens of
   endlessly animating tiles grind slow machines to a halt */
.card.loaded::before { animation: none; content: none; }

.card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .3s ease;
}
.card-thumb.ok { opacity: 1; }

/* title banner appears on hover */
.card-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(4, 22, 48, .85));
  color: #fff;
  font-weight: 800;
  font-size: .86rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .15s, transform .15s;
}
.card.big .card-name { font-size: 1.02rem; padding-bottom: 11px; }
.card:hover .card-name { opacity: 1; transform: translateY(0); }

#sentinel { height: 2px; }

.empty { text-align: center; color: var(--dim); font-weight: 700; font-size: 1.05rem; padding: 60px 0; }

/* ---- footer ---- */
.footer { padding: 30px 26px 46px; }
.footer-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid #dbe3ef;
  color: var(--dim);
  font-size: .88rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 900;
  font-size: 1rem;
  color: var(--heading);
}
.footer-dim { font-size: .78rem; }

/* ---- player overlay ---- */
.player {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
}

.player-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 22px;
  background: rgba(240, 244, 249, .93);
  backdrop-filter: blur(12px);
}
.back-btn, .fs-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 99px;
  border: none;
  background: var(--panel);
  color: var(--heading);
  font: 800 .87rem "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .13s, box-shadow .13s;
  white-space: nowrap;
}
.back-btn:hover, .fs-btn:hover { color: var(--brand); box-shadow: var(--shadow-md); }
.back-arrow { font-size: 1.05rem; }
.player-title {
  flex: 1;
  font-weight: 900;
  font-size: 1.12rem;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stage { padding: 14px 22px 0; max-width: 1280px; margin: 0 auto; }
.iframe-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #04162e;
  box-shadow: var(--shadow-lg);
}
/* fullscreen: CSS fallback mode + floating exit button */
.iframe-wrap.fake-fs {
  position: fixed;
  inset: 0;
  z-index: 300;
  aspect-ratio: auto;
  border-radius: 0;
}
.fs-exit {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 5;
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(4, 22, 48, .65);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: none;
  place-items: center;
}
.fs-exit:hover { background: rgba(4, 22, 48, .9); }
.iframe-wrap.fake-fs .fs-exit,
.iframe-wrap:fullscreen .fs-exit { display: grid; }

.iframe-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.player-info { max-width: 1280px; margin: 0 auto; padding: 18px 22px 40px; }
.info-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
/* ---- rating ---- */
.rating {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e4ebf5;
}
.rate-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--dim);
  cursor: pointer;
  transition: color .13s, background .13s, transform .1s;
}
.rate-btn svg { width: 20px; height: 20px; }
.rate-btn:hover:not(:disabled) { color: var(--brand); background: #e2eefc; transform: scale(1.08); }
.rate-btn.down:hover:not(:disabled) { color: #e0485a; background: #fdeaed; }
.rate-btn:disabled { cursor: default; opacity: .55; }
.rate-btn.voted { opacity: 1; color: #fff; background: var(--brand); }
.rate-btn.down.voted { background: #e0485a; }
.rate-result { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.rate-pct { font-weight: 900; font-size: 1.05rem; color: var(--heading); min-width: 46px; }
.rate-pct:empty { min-width: 0; }
.rate-bar {
  flex: 1;
  max-width: 220px;
  height: 8px;
  border-radius: 99px;
  background: #e4ebf5;
  overflow: hidden;
}
.rate-fill { height: 100%; border-radius: 99px; background: var(--brand); width: 0; transition: width .4s ease; }
.rate-count { color: var(--dim); font-size: .85rem; font-weight: 700; white-space: nowrap; }

.player-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meta-tag {
  font: 800 .72rem "Nunito", sans-serif;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--dim);
}
.meta-tag.cat { background: var(--brand); color: #fff; }
.player-desc { line-height: 1.65; max-width: 900px; margin-bottom: 10px; font-weight: 600; }
.player-controls { color: var(--dim); font-size: .9rem; line-height: 1.6; max-width: 900px; font-weight: 600; }
.player-controls strong { color: var(--brand-dark); }

.similar-head {
  font-weight: 900;
  font-size: 1.12rem;
  color: var(--heading);
  margin: 26px 0 14px;
}
.similar-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.similar-row .card.big { grid-column: auto; grid-row: auto; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  .cats { top: 110px; padding: 6px 14px 12px; }
  #main { padding: 6px 14px 30px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 10px; }
  .player-stage, .player-info { padding-left: 12px; padding-right: 12px; }
  .fs-btn { display: none; }
  .card-name { opacity: 1; transform: none; font-size: .72rem; padding: 16px 6px 6px; }
}
