@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0b0d14;
  --bg-rail: #10131e;
  --bg-card: #161a29;
  --bg-elev: #1e2438;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --ink: #f6f7fb;
  --muted: #98a1b8;
  --violet: #7c5cff;
  --violet-hover: #6946ff;
  --gold: #ffbe3b;
  --gold-soft: rgba(255, 190, 59, 0.16);
  --emerald: #10b981;
  --crimson: #e52e14;
  --rail-w: 220px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== TOP ARCADE NAVBAR (CrazyGames / Poki style) ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: 60px;
  background: rgba(16, 19, 30, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-elev); border-color: var(--border-strong); }

.arcade-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.arcade-logo-badge {
  background: linear-gradient(135deg, var(--violet), #ff4ecd);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 17px;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.45);
}
.arcade-logo span em {
  font-style: normal;
  color: var(--gold);
}

/* Search Bar */
.search-box {
  flex: 1;
  max-width: 440px;
  position: relative;
}
.search-box input {
  width: 100%;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--ink);
  padding: 0 38px 0 38px;
  font: 500 14px/1 inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search-box input:focus {
  border-color: var(--violet);
  background: var(--bg-elev);
}
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

/* Top Right Wallet + Daily + Lang */
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.daily-pill {
  appearance: none;
  border: 1px solid rgba(255, 190, 59, 0.45);
  background: var(--gold-soft);
  color: var(--gold);
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  font: 700 13px/1 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.daily-pill:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--gold);
  color: #141108;
}
.daily-pill.claimed {
  opacity: 0.55;
  border-color: var(--border);
  background: var(--bg-card);
  color: var(--muted);
  cursor: default;
}

.wallet-pill {
  appearance: none;
  border: 1px solid rgba(255, 190, 59, 0.4);
  background: linear-gradient(135deg, #241f14, #181b2a);
  color: var(--ink);
  height: 38px;
  padding: 0 6px 0 13px;
  border-radius: 999px;
  font: 700 14.5px/1 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.wallet-pill:hover { border-color: var(--gold); }
.coin-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffe680, #f59e0b);
  color: #291800;
  font-size: 11.5px;
  font-weight: 900;
}
.wallet-plus {
  background: var(--violet);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
}

.vip-tag {
  display: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1c1200;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.vip-tag.on { display: inline-flex; align-items: center; gap: 4px; }

.rank-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.16);
  border: 1px solid rgba(124, 92, 255, 0.4);
  color: #d6ccff;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* Language Dropdown */
.lang-wrap { position: relative; }
.lang-btn {
  appearance: none;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  font: 600 12.5px/1 inherit;
  cursor: pointer;
}
.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 290px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.65);
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  z-index: 120;
}
.lang-wrap.open .lang-menu { display: grid; }
.lang-menu a {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
.lang-menu a:hover { background: var(--bg-elev); color: var(--ink); }
.lang-menu a.current { background: var(--violet); color: #fff; font-weight: 700; }

/* ===== SHELL: LEFT CATEGORY RAIL + MAIN STAGE ===== */
.arcade-shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: calc(100vh - 60px);
}
body.rail-collapsed .arcade-shell {
  grid-template-columns: 0px 1fr;
}
body.rail-collapsed .left-rail {
  overflow: hidden;
  padding: 0;
  border: 0;
}

.left-rail {
  background: var(--bg-rail);
  border-inline-end: 1px solid var(--border);
  padding: 16px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.rail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 12px 12px 6px;
}
.rail-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #cfd6ea;
  padding: 10px 12px;
  border-radius: 10px;
  font: 600 14px/1.2 inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: start;
  width: 100%;
  transition: background 0.14s ease, color 0.14s ease;
}
.rail-btn:hover { background: var(--bg-card); color: #fff; }
.rail-btn.active {
  background: rgba(124, 92, 255, 0.18);
  color: #b5a3ff;
}
.rail-count {
  margin-inline-start: auto;
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  color: var(--muted);
}

.arcade-main {
  padding: 22px 26px 56px;
  min-width: 0;
}

/* Shelf Rows (Recently Played / Favorites) */
.shelf {
  margin-bottom: 28px;
}
.shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.shelf-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.shelf-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

/* ===== BENTO MASONRY GAME WALL (CrazyGames / Poki Signature!) ===== */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: 155px;
  grid-auto-flow: dense;
  gap: 16px;
}

.bento-tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: block;
  transition: transform 0.18s cubic-bezier(.2,.8,.2,1), border-color 0.18s ease, box-shadow 0.18s ease;
}
.bento-tile.size-hero {
  grid-column: span 2;
  grid-row: span 2;
}
.bento-tile.size-wide {
  grid-column: span 2;
  grid-row: span 1;
}
.bento-tile:hover {
  transform: translateY(-4px) scale(1.015);
  border-color: var(--violet);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  z-index: 4;
}
.bento-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.bento-tile:hover img { transform: scale(1.04); }
.bento-tile video.hover-vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.bento-tile.playing video.hover-vid { opacity: 1; }

.bento-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8,10,16,0.05) 35%, rgba(8,10,16,0.92) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
  pointer-events: none;
}
.bento-title {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.bento-tile.size-hero .bento-title { font-size: 22px; }
.bento-sub {
  font-size: 12.5px;
  color: rgba(255,255,255,0.75);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bento-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--emerald);
  color: #042318;
  z-index: 3;
}
.bento-badge.app {
  background: rgba(16, 19, 30, 0.84);
  color: #cfd6ea;
  border: 1px solid var(--border-strong);
}

.fav-btn {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(11, 13, 20, 0.72);
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, color 0.14s ease;
}
.fav-btn:hover { transform: scale(1.12); color: #ff5c8a; }
.fav-btn.fav-on { color: #ff477e; background: rgba(255, 71, 126, 0.18); }

/* ===== THEATER PLAYER VIEW (/g/<slug>) ===== */
.theater-grid {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  align-items: start;
}
.stage-card {
  background: #07080d;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.stage-canvas {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #040508;
  min-height: 540px;
}
.stage-frame {
  width: 100%;
  height: min(74vh, 720px);
}
.stage-frame.portrait {
  max-width: 430px;
  height: min(78vh, 760px);
  margin: 12px auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}
.stage-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.stage-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stage-game-id {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stage-game-id img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: cover;
}
.stage-game-id h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.stage-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.act-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--ink);
  height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  font: 600 13px/1 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.act-btn:hover { border-color: var(--violet); background: rgba(124, 92, 255, 0.2); }
.act-btn.boost {
  border-color: rgba(255, 190, 59, 0.5);
  background: linear-gradient(135deg, rgba(255,190,59,0.18), rgba(124,92,255,0.18));
  color: var(--gold);
}
.act-btn.boost:hover { background: var(--gold); color: #1b1300; }

/* Right "Play Next" Rail */
.next-rail {
  background: var(--bg-rail);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.next-rail h3 {
  margin: 0 0 2px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.next-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.next-item:hover {
  transform: translateX(3px);
  border-color: var(--violet);
}
.next-item img {
  width: 52px;
  height: 52px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
}
.next-item strong { display: block; font-size: 14px; line-height: 1.2; }
.next-item span { font-size: 12px; color: var(--emerald); font-weight: 600; }

/* ===== STRIPE COIN SHOP MODAL ===== */
.shop-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 7, 13, 0.82);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.shop-backdrop.open { display: flex; }

.shop-modal {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  background: #141827;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 26px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.75);
}
.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.shop-head h2 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.shop-bal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 190, 59, 0.08);
  border: 1px solid rgba(255, 190, 59, 0.25);
  margin-bottom: 20px;
}
.packs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.pack-card {
  position: relative;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.pack-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.pack-card.featured {
  border-color: var(--violet);
  background: linear-gradient(160deg, rgba(124,92,255,0.16), var(--bg-card) 60%);
}
.pack-badge {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--violet);
  color: #fff;
}
.pack-coins {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
}
.pack-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.pack-sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; flex: 1; }
.pack-buy, .armory-buy {
  appearance: none;
  border: 0;
  border-radius: 11px;
  height: 40px;
  background: var(--violet);
  color: #fff;
  font: 700 14px/1 inherit;
  cursor: pointer;
  margin-top: 6px;
}
.armory-buy {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1c1100;
}
.pack-buy:hover { background: var(--violet-hover); }
.armory-buy:hover { filter: brightness(1.08); }

.quest-banner {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #d1fae5;
  font-size: 13px;
  margin-bottom: 14px;
}
.shop-tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.04);
  padding: 5px;
  border-radius: 12px;
}
.shop-tab-btn {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font: 700 13.5px/1.2 inherit;
  cursor: pointer;
}
.shop-tab-btn.active {
  background: var(--violet);
  color: #fff;
}

.shop-tabs {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  font-size: 13px;
  color: var(--muted);
}
.ledger-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.ledger-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  font-size: 13px;
}
.ledger-pos { color: var(--emerald); font-weight: 700; }
.ledger-neg { color: #ff7b7b; font-weight: 700; }

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  background: #192034;
  border: 1px solid var(--gold);
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 14px 35px rgba(0,0,0,0.6);
  display: none;
}
.toast.show { display: block; }

@media (max-width: 980px) {
  .arcade-shell { grid-template-columns: 1fr; }
  .left-rail { display: none; }
  body.rail-mobile-open .left-rail {
    display: flex;
    position: fixed;
    top: 60px;
    left: 0;
    width: 240px;
    z-index: 100;
  }
  .theater-grid { grid-template-columns: 1fr; }
  .bento-tile.size-hero, .bento-tile.size-wide { grid-column: span 1; grid-row: span 1; }
  .packs-grid { grid-template-columns: 1fr; }
  .daily-pill span.lbl { display: none; }
  .rank-chip { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .search-box { display: none; }
  .arcade-logo span { font-size: 16px; }
  .shop-backdrop { padding: 0; align-items: flex-end; }
  .shop-modal {
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    padding: 18px 16px 26px;
  }
  .shop-head h2 { font-size: 19px; }
  .shop-tab-btn { font-size: 12.5px; padding: 9px 8px; }
  .toast { left: 12px; right: 12px; bottom: 14px; text-align: center; }
}
