/* ========================================
   AK Games – portal styles
   Dark, card-first layout (sidebar + top bar + content)
======================================== */

:root {
  --bg: #0c0d14;
  --panel: #13141f;
  --panel-2: #1b1c2b;
  --panel-3: #25263a;
  --line: #2a2b40;
  --text: #f1f1f7;
  --muted: #9a9cb8;
  --accent: #8b5cff;
  --accent-2: #ff4d8d;
  --accent-grad: linear-gradient(135deg, #8b5cff, #ff4d8d);
  --gold: #f9c74f;
  --green: #4ecca3;
  --radius: 12px;
  --topbar-h: 64px;
  --sidebar-w: 232px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

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

html { scroll-padding-top: calc(var(--topbar-h) + 12px); }

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
code { background: var(--panel-3); padding: 1px 6px; border-radius: 5px; font-size: 0.88em; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 500;
  background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border: none; border-radius: 999px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: var(--panel-3); }
.btn-ghost:hover { background: #30314a; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 1.05rem; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-3); }

.count-badge {
  position: absolute; top: 2px; right: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent-2); color: #fff; font-size: 0.7rem; font-weight: 800;
  display: grid; place-items: center;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(12, 13, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; }
.brand-name { font-size: 1.3rem; font-weight: 900; letter-spacing: 0.5px; }
.brand-name span {
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-left: 2px;
}

.search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); color: var(--text); }
.search input { flex: 1; min-width: 0; border: none; background: none; outline: none; color: var(--text); }
.search input::-webkit-search-cancel-button { filter: invert(1); }
.search-kbd {
  font: 700 0.75rem/1 inherit; padding: 3px 7px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--muted);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 90;
  width: var(--sidebar-w);
  padding: 12px 10px 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.nav-list { list-style: none; display: grid; gap: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600;
}
.nav-list a:hover { background: var(--panel-2); color: var(--text); }
.nav-list a[aria-current="page"] { background: var(--panel-3); color: var(--text); }
.nav-list a[aria-current="page"] .nav-icon { filter: none; }
.nav-icon { width: 24px; text-align: center; font-size: 1.1rem; }
.nav-count { margin-left: auto; font-size: 0.75rem; color: var(--muted); }

.nav-heading {
  margin: 16px 12px 6px; font-size: 0.72rem; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}

.sidebar-footer {
  margin-top: auto; padding: 18px 12px 0;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 0.8rem; color: var(--muted);
}
.sidebar-footer a:hover { color: var(--text); }
.sidebar-footer p { width: 100%; margin-top: 6px; }

.scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 80;
  background: rgba(0, 0, 0, 0.55);
}

/* ---------- Main view ---------- */
.view {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 20px) 24px 48px;
  min-height: 100vh;
  outline: none;
}

.page-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--muted); margin-bottom: 20px; }

/* ---------- Hero banner ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center;
  min-height: 300px; margin-bottom: 32px;
  border-radius: 18px; background: var(--panel-2);
  box-shadow: var(--shadow);
}
.hero-bg {
  position: absolute; inset: -20px;
  background-size: cover; background-position: center;
  filter: blur(28px) saturate(1.3); opacity: 0.35;
}
.hero-text { position: relative; padding: 32px; }
.hero-kicker {
  display: inline-block; margin-bottom: 10px; padding: 4px 12px; border-radius: 999px;
  background: rgba(249, 199, 79, 0.15); color: var(--gold);
  font-size: 0.75rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
}
.hero-title { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; line-height: 1.1; margin-bottom: 10px; }
.hero-desc { color: #c9cadb; margin-bottom: 20px; max-width: 46ch; }
.hero-art { position: relative; padding: 20px 20px 20px 0; }
.hero-art img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); transition: transform 0.3s ease; }
.hero:hover .hero-art img { transform: scale(1.02) rotate(-0.5deg); }

/* ---------- Rows (horizontal carousels) ---------- */
.row { margin-bottom: 30px; }
.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.row-title { font-size: 1.2rem; font-weight: 800; }
.row-link { margin-left: auto; color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.row-link:hover { color: var(--text); }
.row-arrows { display: flex; gap: 6px; }
.row-arrows .icon-btn { width: 34px; height: 34px; background: var(--panel-2); }
.row-arrows .icon-btn:disabled { opacity: 0.35; cursor: default; }

.row-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr);
  gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; padding: 4px 2px 10px;
}
.row-track::-webkit-scrollbar { display: none; }
.row-track > * { scroll-snap-align: start; }

@media (min-width: 1400px) {
  .row-track { grid-auto-columns: calc((100% - 5 * 14px) / 6); }
}
@media (min-width: 1100px) and (max-width: 1399px) {
  .row-track { grid-auto-columns: calc((100% - 4 * 14px) / 5); }
}

/* ---------- Grid ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ---------- Game card ---------- */
.card {
  position: relative; display: block;
  border-radius: var(--radius); overflow: hidden;
  background: var(--panel-2);
  aspect-ratio: 16 / 9;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  isolation: isolate;
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease, filter 0.2s ease; }
.card::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0) 55%);
  opacity: 0; transition: opacity 0.2s ease;
}
.card-title {
  position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 2;
  font-weight: 800; font-size: 0.98rem; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  transform: translateY(8px); opacity: 0; transition: transform 0.2s ease, opacity 0.2s ease;
}
.card-play {
  position: absolute; top: 50%; left: 50%; z-index: 2;
  width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; box-shadow: 0 6px 20px rgba(139, 92, 255, 0.55);
  transform: scale(0.6); opacity: 0; transition: transform 0.2s ease, opacity 0.2s ease;
}
.card-play svg { fill: currentColor; stroke: none; margin-left: 3px; }

@media (hover: hover) {
  .card:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--accent); z-index: 3; }
  .card:hover img { transform: scale(1.06); }
  .card:hover::after, .card:hover .card-title { opacity: 1; transform: none; }
  .card:hover .card-play { opacity: 1; transform: scale(1); }
}
.card:focus-visible { outline-offset: 3px; }
.card:focus-visible::after, .card:focus-visible .card-title { opacity: 1; transform: none; }

/* Touch screens: always show the title */
@media (hover: none) {
  .card::after, .card-title { opacity: 1; transform: none; }
}

.card-badges { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; gap: 6px; }
.badge {
  padding: 2px 8px; border-radius: 6px; font-size: 0.68rem; font-weight: 900; letter-spacing: 0.5px;
  text-transform: uppercase; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.badge-new { background: var(--green); color: #07261c; }
.badge-hot { background: var(--accent-2); color: #fff; }
.badge-local { background: var(--gold); color: #3a2300; }
.badge-soon { background: rgba(0, 0, 0, 0.6); color: #fff; }

.card.is-soon { cursor: default; }
.card.is-soon img { filter: grayscale(0.4) brightness(0.75); }

.card-fav {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); color: #fff;
}
.card-fav svg { width: 17px; height: 17px; fill: var(--accent-2); stroke: var(--accent-2); }

/* ---------- Toolbar (category / search pages) ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.sort { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; }
.sort select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

/* ---------- Empty state ---------- */
.empty {
  display: grid; place-items: center; text-align: center; gap: 10px;
  padding: 60px 20px; border: 2px dashed var(--line); border-radius: 16px; color: var(--muted);
}
.empty-icon { font-size: 2.6rem; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.game-layout.theater { grid-template-columns: minmax(0, 1fr); }
.game-layout.theater .aside { display: none; }

.player {
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 9; max-height: calc(100vh - var(--topbar-h) - 150px);
  width: 100%; border-radius: 16px; background: #000; box-shadow: var(--shadow);
}
.player.portrait { aspect-ratio: 3 / 4; max-width: 560px; margin: 0 auto; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0f0f1a; }

.player-cover {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  cursor: pointer;
}
.player-cover .bg {
  position: absolute; inset: -30px; background-size: cover; background-position: center;
  filter: blur(22px) brightness(0.5);
}
.player-cover-inner { position: relative; display: grid; justify-items: center; gap: 14px; padding: 20px; }
.player-cover-inner img { width: min(360px, 60vw); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); }
.player-cover h1 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 900; }
.player-soon { color: var(--muted); font-weight: 700; }

.game-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 18px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.game-bar img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.game-bar-title { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.game-bar-sub { color: var(--muted); font-size: 0.8rem; }
.game-bar-actions { margin-left: auto; display: flex; gap: 4px; }
.game-bar .icon-btn.active { color: var(--accent-2); }
.game-bar .icon-btn.active svg { fill: var(--accent-2); }

.info { display: grid; gap: 18px; }
.info-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.info-card h2 { font-size: 1.05rem; margin-bottom: 10px; }
.info-card ul { padding-left: 20px; display: grid; gap: 4px; color: #c9cadb; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.meta dt { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.meta dd { font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--panel-3); font-size: 0.8rem; color: #c9cadb; }
.tag:hover { background: #33344f; color: var(--text); }

.aside h2 { font-size: 1.05rem; margin-bottom: 12px; }
.aside .grid { grid-template-columns: 1fr; gap: 12px; }

/* ---------- Mobile full-screen player ---------- */
.mobile-player { position: fixed; inset: 0; z-index: 300; background: #000; }
.mobile-frame-host, .mobile-frame-host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mobile-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; z-index: 2;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.65);
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 26px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); animation: rise 0.2s ease;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.modal-card > .muted { margin-bottom: 18px; font-size: 0.92rem; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: none; border-radius: 50%; background: none; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.modal-x:hover { background: var(--panel-3); color: var(--text); }

.register-form { display: grid; gap: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 5px; font-size: 0.85rem; font-weight: 700; }
.field small { font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); font-weight: 500;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--accent-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: #ff8fb2; font-weight: 700; font-size: 0.9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.register-done { display: grid; gap: 12px; }
.success { color: var(--green); }
.snippet {
  max-height: 260px; overflow: auto; padding: 14px; border-radius: 10px;
  background: #0a0b12; border: 1px solid var(--line);
  font: 0.8rem/1.5 Consolas, "Courier New", monospace; color: #cfd1e6; white-space: pre;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 500; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-weight: 700; box-shadow: var(--shadow); animation: rise 0.2s ease;
}

/* ---------- Text pages ---------- */
.prose { max-width: 760px; }
.prose h1 { font-size: 1.8rem; margin-bottom: 12px; }
.prose h2 { font-size: 1.15rem; margin: 22px 0 8px; }
.prose p, .prose li { color: #c9cadb; margin-bottom: 10px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose a { color: var(--accent); text-decoration: underline; }
.prose pre { margin: 10px 0 16px; }

/* ---------- Responsive ---------- */
/* Tablet: icon rail */
@media (max-width: 1100px) and (min-width: 769px) {
  :root { --sidebar-w: 76px; }
  .sidebar { padding: 12px 8px; }
  .nav-list a { flex-direction: column; gap: 2px; padding: 10px 4px; font-size: 0.68rem; text-align: center; }
  .nav-icon { font-size: 1.25rem; }
  .nav-count, .nav-heading, .sidebar-footer { display: none; }
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .aside .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* Phone: drawer sidebar */
@media (max-width: 768px) {
  :root { --topbar-h: 58px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-name { display: none; }
  .search { height: 40px; }
  .search-kbd { display: none; }
  #register-btn span { display: none; }
  #register-btn { width: 42px; padding: 0; }

  .sidebar {
    transform: translateX(-100%); transition: transform 0.22s ease;
    width: min(280px, 82vw); box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .view { margin-left: 0; padding: calc(var(--topbar-h) + 14px) 14px 40px; }

  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-art { order: -1; padding: 14px 14px 0; }
  .hero-text { padding: 16px 18px 22px; }

  .row-track { grid-auto-columns: 62%; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-title { font-size: 0.85rem; }

  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .aside .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-bar-actions .hide-mobile { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .modal-card { padding: 20px; }
}

@media (min-width: 769px) {
  #menu-btn { display: none; }
  .scrim { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
