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

:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #171c26;
  --muted: #647084;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent-grad: linear-gradient(135deg, #4f46e5, #8b5cf6);
  --border: #e2e6ee;
  --like: #e0426b;
  --shadow-sm: 0 1px 3px rgba(23,28,38,.06), 0 1px 2px rgba(23,28,38,.04);
  --shadow-md: 0 12px 28px rgba(23,28,38,.14);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
}

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

/* ---------- Top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo::before {
  content: 'N';
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
}
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 16px; }
.userbox .uname { color: var(--text); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: #f2f4f9; }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent-grad);
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.btn-primary:hover { background: linear-gradient(135deg, #4338ca, #7c3aed); }
.btn-like { border-color: #f3c2d0; color: var(--like); background: #fdf2f5; }
.btn-like:hover { background: #fbe7ee; }
.btn-like.liked { background: var(--like); border-color: var(--like); color: #fff; }
.btn-bell { white-space: nowrap; }
.btn-bell.bell-on { border-color: #c7d2fe; color: var(--primary); background: #eef0ff; }
.btn-bell.bell-on:hover { background: #e3e7ff; }
.btn-bell:disabled { opacity: .6; cursor: default; }

.container { max-width: 1500px; margin: 0 auto; padding: 28px 28px 80px; }

/* ---------- "Since your last visit" banner ---------- */
.whatsnew {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(120deg, #eef0ff, #f5eeff);
  border: 1px solid #d8d9fb;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.wn-emoji { font-size: 24px; line-height: 1.2; flex-shrink: 0; }
.wn-body { flex: 1; min-width: 0; }
.wn-title { font-weight: 700; font-size: 16px; color: #3730a3; margin-bottom: 6px; }
.wn-list { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 15px; }
.wn-list a { color: var(--primary); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.wn-list a:hover { text-decoration: underline; }
.wn-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: #b06a35; background: #fbeadd; border-radius: 5px; padding: 1px 5px;
}
.wn-more { color: var(--muted); font-size: 15px; }
.wn-close {
  background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 2px; flex-shrink: 0;
}
.wn-close:hover { color: var(--text); }

/* NEW / UPDATED badge on game cards */
.new-badge {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 2;
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  color: #fff; background: #1d9e56;
  border-radius: 6px; padding: 3px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.new-badge.upd { background: #d97706; }

/* ---------- Hero (featured game) ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 40px;
  background:
    radial-gradient(900px 400px at 85% -20%, rgba(139,92,246,.55), transparent 60%),
    linear-gradient(120deg, #312e81, #4f46e5 55%, #6d28d9);
  border-radius: 20px;
  padding: 38px 44px;
  margin-bottom: 36px;
  color: #fff;
  box-shadow: var(--shadow-md);
}
.hero-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #c7d2fe;
  background: rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 6px 14px;
  margin-bottom: 14px;
}
.hero-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.15;
  margin-bottom: 12px;
}
.hero-stats { display: flex; gap: 22px; font-size: 16px; color: #dfe3ff; margin-bottom: 12px; }
.hero-desc {
  color: #c9d0f5;
  font-size: 17px;
  max-width: 560px;
  margin-bottom: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.btn-hero {
  background: #fff;
  color: #3730a3;
  border: none;
  font-size: 17px;
  font-weight: 700;
  padding: 14px 30px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.btn-hero:hover { background: #eef0ff; }
.hero-info { flex: 1; min-width: 0; }
.hero-thumb {
  width: 460px;
  flex-shrink: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  transition: transform .2s;
}
.hero-thumb:hover { transform: scale(1.02); }
.hero-thumb img { width: 100%; height: 280px; object-fit: cover; display: block; }
@media (max-width: 1100px) {
  .hero { flex-direction: column; align-items: stretch; gap: 24px; padding: 30px; }
  .hero-thumb { width: 100%; }
}

/* ---------- Section headings ---------- */
.section-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.3px;
  margin: 32px 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title::before {
  content: '';
  width: 5px;
  height: 24px;
  border-radius: 3px;
  background: var(--accent-grad);
}
.section-title:first-child { margin-top: 0; }

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card .thumb {
  position: relative;
  height: 185px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  color: rgba(255,255,255,.92);
  font-weight: 800;
}
.card .thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.play-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(18,16,45,.5);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  transition: opacity .18s;
}
.play-overlay .icon { width: 20px; height: 20px; fill: currentColor; }
.card:hover .play-overlay { opacity: 1; }
.card .body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.card .title { font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.card .owner { font-size: 15px; color: var(--muted); }
.card .stats {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #f0f2f7;
  display: flex;
  gap: 18px;
  font-size: 15px;
  color: var(--muted);
}

.icon { width: 17px; height: 17px; flex-shrink: 0; }
.stat { display: inline-flex; align-items: center; gap: 6px; }
.btn-like .icon { width: 18px; height: 18px; }
.btn-like.liked .icon { fill: currentColor; }

.empty { color: var(--muted); font-size: 16px; padding: 12px 0; }

/* ---------- Home layout: middle = all games, right = rankings ---------- */
.home-layout { display: flex; gap: 30px; align-items: flex-start; }
.main-col { flex: 1; min-width: 0; }
.side-col {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 92px;
}
.count-badge {
  background: #e7e7fb;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  padding: 3px 12px;
}
.side-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.side-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.2px;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.top-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f0f2f7;
}
.top-item:last-child { border-bottom: none; padding-bottom: 2px; }
.top-item:hover .top-title { color: var(--primary); }
.rank {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
  background: #f1f3f9;
  flex-shrink: 0;
}
.rank-1 { background: #fff3d6; color: #c8860a; }
.rank-2 { background: #eef1f6; color: #6e7c8c; }
.rank-3 { background: #fbeadd; color: #b06a35; }
.top-thumb {
  position: relative;
  width: 76px;
  height: 50px;
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.92);
  font-weight: 700;
  font-size: 20px;
}
.top-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.top-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.top-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-stat { font-size: 14px; color: var(--muted); }
.top-stat .stat { gap: 5px; }
.top-stat .icon { width: 14px; height: 14px; }

@media (max-width: 1000px) {
  .home-layout { flex-direction: column; }
  .side-col { width: 100%; position: static; }
}

/* ---------- Forms ---------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  max-width: 560px;
  margin: 48px auto;
  box-shadow: var(--shadow-sm);
}
.form-card h2 { margin-bottom: 24px; font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input, .field textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field textarea:focus { outline: 2px solid rgba(79,70,229,.25); border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 100px; }
.form-msg { font-size: 15px; margin-top: 12px; min-height: 20px; }
.form-msg.error { color: #d43a3a; }
.form-msg.ok { color: #1d9e56; }
.form-switch { margin-top: 16px; font-size: 15px; color: var(--muted); }
.form-switch a { color: var(--primary); font-weight: 600; cursor: pointer; }

/* ---------- Game page ---------- */
.game-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.game-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -.4px; }
.game-meta { color: var(--muted); font-size: 16px; margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.game-actions { margin-left: auto; display: flex; gap: 12px; }
.player-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.player-wrap iframe {
  width: 100%;
  height: 75vh;
  min-height: 480px;
  border: 0;
  display: block;
  background: #fff;
}
.game-desc { margin: 20px 0; color: var(--text); font-size: 17px; white-space: pre-wrap; }

/* ---------- Comments ---------- */
.comments { margin-top: 36px; }
.comment-form { display: flex; gap: 12px; margin: 14px 0 24px; }
.comment-form textarea { flex: 1; min-height: 52px; }
.comment {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.comment .head { font-size: 15px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.comment .head .author { font-weight: 700; }
.comment .head .time { color: var(--muted); margin-left: 10px; }
.comment .content { font-size: 16px; white-space: pre-wrap; }

.badge-guest {
  background: #eef1f6;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  margin-left: 5px;
}
.badge-admin {
  background: #ffe6e6;
  color: #d23b3b;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  margin-left: 5px;
}
.btn-danger {
  background: #d23b3b;
  color: #fff;
  border-color: #d23b3b;
}
.btn-danger:hover { background: #b52f2f; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.admin-table .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Avatars ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  background: var(--accent-grad);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { width: 22px; height: 22px; font-size: 11px; }
.avatar-sm { width: 30px; height: 30px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 20px; }
.avatar-lg { width: 92px; height: 92px; font-size: 38px; }

/* User chip in the top bar (links to profile) */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s, border-color .15s;
}
.user-chip:hover { background: #f2f4f9; border-color: #d3d9e6; }

.card .owner { display: flex; align-items: center; gap: 7px; }

/* ---------- Profile page ---------- */
.profile-avatar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.profile-avatar-actions .form-switch { margin-top: 0; }
.profile-avatar label.btn { margin: 0; }

/* ============================================================
   Responsive — tablet & mobile
   ============================================================ */

/* Tablet / small laptop */
@media (max-width: 768px) {
  body { font-size: 15px; }

  .topbar-inner { padding: 12px 16px; gap: 12px; }
  .logo { font-size: 21px; }
  .btn { padding: 9px 15px; font-size: 15px; }

  .container { padding: 20px 16px 60px; }

  /* Hero */
  .hero { padding: 26px 22px; margin-bottom: 26px; border-radius: 16px; }
  .hero-title { font-size: 28px; }
  .hero-stats { font-size: 15px; gap: 18px; }
  .hero-desc { font-size: 15px; margin-bottom: 20px; }
  .hero-thumb img { height: 220px; }
  .btn-hero { padding: 12px 24px; font-size: 16px; }

  .section-title { font-size: 21px; margin: 26px 0 16px; }

  /* Game grid a touch smaller */
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }

  /* Game page */
  .game-head h1 { font-size: 26px; }
  .player-wrap iframe { height: 65vh; min-height: 360px; }
  .game-desc { font-size: 15px; }

  /* Forms */
  .form-card { padding: 26px 22px; margin: 28px auto; }
  .form-card h2 { font-size: 23px; }

  /* Admin tables scroll horizontally instead of squashing */
  .admin-table { font-size: 14px; min-width: 560px; }
}

/* Phones */
@media (max-width: 560px) {
  /* Top bar wraps to two rows: logo on top, actions below */
  .topbar-inner { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .topbar .spacer { flex-basis: 100%; height: 0; }
  .logo { font-size: 20px; }
  .logo::before { width: 30px; height: 30px; font-size: 16px; }
  .btn { padding: 8px 13px; font-size: 14px; }
  .userbox { gap: 8px; font-size: 14px; flex-wrap: wrap; }
  .user-chip .uname {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .container { padding: 16px 12px 50px; }

  /* Single column of cards */
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .card .thumb { height: 170px; }

  /* Hero compact */
  .hero { padding: 22px 18px; gap: 18px; margin-bottom: 22px; }
  .hero-title { font-size: 23px; }
  .hero-stats { gap: 14px; font-size: 14px; }
  .hero-desc { font-size: 14px; }
  .hero-thumb img { height: 180px; }
  .btn-hero { width: 100%; justify-content: center; }

  .section-title { font-size: 19px; margin: 22px 0 14px; }

  /* Game page: title + actions stack, buttons share the row */
  .game-head { gap: 12px; }
  .game-head h1 { font-size: 22px; }
  .game-actions { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
  .game-actions .btn { flex: 1 1 auto; justify-content: center; }
  .player-wrap iframe { height: 58vh; min-height: 300px; }

  /* Comment box stacks above the Post button */
  .comment-form { flex-direction: column; }
  .comment-form .btn { width: 100%; justify-content: center; }

  /* Forms */
  .form-card { padding: 22px 18px; margin: 18px auto; border-radius: 14px; }
  .form-card h2 { font-size: 21px; }

  /* Profile avatar row stacks */
  .profile-avatar { flex-direction: column; align-items: flex-start; gap: 16px; }
}
