/* ===========================================================
   One-Shot Arcade — Styles
   Minimalist, responsive, dark theme
   =========================================================== */

/* ---------- Reset & Variables ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #0f0f14;
  --color-surface: #1a1a24;
  --color-surface-hover: #242436;
  --color-primary: #6c5ce7;
  --color-primary-glow: rgba(108, 92, 231, 0.35);
  --color-accent: #fd79a8;
  --color-text: #e0e0ee;
  --color-text-muted: #8888a0;
  --color-border: #2a2a3a;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header__username {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
}

/* ---------- Catalog Grid ---------- */
.catalog {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  flex: 1;
}

/* ---------- Game Card ---------- */
.game-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-card:hover {
  background: var(--color-surface-hover);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.game-card__icon {
  font-size: 2.5rem;
  line-height: 1;
}

.game-card__title {
  font-size: 1.15rem;
  font-weight: 600;
}

.game-card__desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  flex: 1;
}

.game-card__play {
  align-self: flex-start;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}

.game-card__play:hover {
  background: #5a4bd1;
  box-shadow: 0 0 20px var(--color-primary-glow);
}

/* ---------- Modal Overlay ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  width: 95vw;
  max-width: 1100px;
  height: 90vh;
  max-height: 700px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color var(--transition);
}

.modal__close:hover {
  color: #fff;
}

.modal__body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.modal__game-area {
  flex: 1;
  display: flex;
  position: relative;
  background: #000;
}

.modal__iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ---------- Sidebar / Leaderboard ---------- */
.modal__sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border);
  padding: 1.25rem;
  overflow-y: auto;
  background: var(--color-bg);
}

.sidebar__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.leaderboard {
  list-style: none;
  counter-reset: lb;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard__item {
  counter-increment: lb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
}

.leaderboard__item::before {
  content: counter(lb);
  font-weight: 700;
  color: var(--color-primary);
  margin-right: 0.75rem;
  min-width: 1.2rem;
}

.leaderboard__item:first-child::before {
  color: #f1c40f;
}

.leaderboard__item:nth-child(2)::before {
  color: #bdc3c7;
}

.leaderboard__item:nth-child(3)::before {
  color: #e67e22;
}

.leaderboard__username {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard__score {
  font-weight: 700;
  color: var(--color-accent);
  margin-left: 0.5rem;
}

.leaderboard__empty {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem 0;
}

.leaderboard__error {
  color: #e74c3c;
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

/* ---------- Status Message ---------- */
.status-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  z-index: 200;
  animation: toastIn 0.3s ease;
  pointer-events: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .catalog {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    padding: 0 1rem;
    margin: 1.5rem auto;
  }

  .modal__content {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .modal__body {
    flex-direction: column;
  }

  .modal__game-area {
    flex: 1;
    min-height: 60%;
  }

  .modal__sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
    max-height: 40%;
    padding: 1rem;
  }
}
