:root {
  --bg: #faf7f0;
  --sidebar-bg: #ffffff;
  --border: #e5ddcc;
  --ink: #1a1a1a;
  --ink-soft: #6b6459;
  --hover-bg: #f3ede0;
  --top-bar-height: 56px;
  --sidebar-width: 312px;
  --icon-bg: #ffffff;
  --star: #e0a92b;
  --thumb: #2f8f52;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

#shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* Top bar: menu toggle + title + ad slot, all in one slim strip so games
   get the rest of the viewport. */
#top-bar {
  flex: 0 0 auto;
  height: var(--top-bar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#menu-btn,
#home-top-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}

#menu-btn:hover,
#home-top-btn:hover {
  background: var(--hover-bg);
}

/* Shown only while a game is open (see openGame/goHome in app.js). */
#home-top-btn.hidden {
  display: none;
}

#top-bar-title {
  flex: 1;
  min-width: 0;
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar: an overlay drawer that slides in from the left. */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 50;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.12);
}

#sidebar.open {
  transform: translateX(0);
}

#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}

#backdrop.hidden {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 18px 20px;
  border-bottom: 1px solid var(--border);
}

#home-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  padding: 4px;
  margin: -4px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}

#home-btn:hover {
  background: var(--hover-bg);
}

.brand-name {
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#close-menu-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
}

#close-menu-btn:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

#game-list {
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 4px;
}

.game-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.game-item {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.game-item:hover {
  background: var(--hover-bg);
}

.game-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent, #888);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-icon svg {
  width: 24px;
  height: 24px;
}

.game-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.game-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.game-tagline {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-soft);
  /* Wrap instead of truncating — the ratings controls narrowed this column
     enough that one line was cutting most taglines off. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.game-presence {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: #2f8f52;
  line-height: 1.3;
}

.game-presence .live-dot {
  position: relative;
  top: 1px;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2fae5f;
  animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 174, 95, 0.45); }
  70% { box-shadow: 0 0 0 5px rgba(47, 174, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 174, 95, 0); }
}

.game-item.is-soon {
  cursor: default;
}

.game-item.is-soon .game-icon {
  opacity: 0.55;
}

.game-item.is-soon .game-title {
  color: var(--ink-soft);
}

.hint-badge {
  display: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: #a9a196;
  padding: 3px 8px;
  border-radius: 999px;
}

.game-item.showing-hint .hint-badge {
  display: inline-block;
}

/* The star + thumbs-up + count cluster that sits at the right edge of each
   sidebar row. */
.game-aside {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1px;
}

.rating-controls {
  display: flex;
  align-items: center;
  gap: 1px;
}

.fav-btn,
.vote-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.fav-btn svg,
.vote-btn svg {
  width: 15px;
  height: 15px;
}

.fav-btn:hover,
.vote-btn:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

.fav-btn[aria-pressed="true"] {
  color: var(--star);
  --star-fill: var(--star);
}

.vote-btn[aria-pressed="true"] {
  color: var(--thumb);
  --thumb-fill: var(--thumb);
}

.vote-count {
  min-width: 14px;
  margin-right: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  text-align: left;
}

/* Rule between the pinned favorites and the popularity-ranked rest. */
.list-divider {
  height: 1px;
  margin: 7px 12px;
  background: var(--border);
}

/* Content area */
#content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
}

.screen.hidden {
  display: none;
}

#picker-screen {
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 24px 56px;
}

#picker-screen.hidden,
#game-screen.hidden {
  /* ID selectors above beat .screen.hidden on specificity alone, so
     without this override both screens stayed visible at once. */
  display: none;
}

.picker-content {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.picker-title {
  margin: 0;
  text-align: center;
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.section-heading {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.about-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.cards-group + .cards-group {
  margin-top: 26px;
}

.cards-group.hidden {
  display: none;
}

.cards-group-label {
  margin: 0 0 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--sidebar-bg);
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.game-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent, #888);
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  border-color: var(--accent, var(--border));
  outline: none;
}

.game-card.is-soon {
  cursor: default;
}

.game-card.is-soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.game-card.is-soon .game-icon {
  opacity: 0.55;
}

.card-title {
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.card-tagline {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  /* Always show the whole tagline — wrap onto as many lines as it needs,
     never truncate. (flex: 1 keeps the ratings row pinned to the card
     bottom so cards still line up.) */
  white-space: normal;
  overflow: visible;
  overflow-wrap: break-word;
}

.card-badge {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: #a9a196;
  padding: 2px 7px;
  border-radius: 999px;
}

.game-card .rating-controls {
  margin-top: 4px;
}

.game-card .fav-btn,
.game-card .vote-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
}

.game-card .vote-count {
  font-size: 12.5px;
  margin-left: 1px;
}

#game-screen {
  display: flex;
}

#game-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
}

/* Ad slot: lives in the top-right corner of the top bar, out of the way of
   the game itself. */
#ad-slot {
  flex: 0 0 auto;
  width: 234px;
  height: 40px;
  background: #efe9db;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-placeholder {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  #sidebar {
    width: 85%;
  }

  #ad-slot {
    width: 120px;
  }

  #top-bar-title {
    font-size: 13px;
  }

  /* Bigger star / thumbs-up tap targets on phones. */
  .fav-btn,
  .vote-btn,
  .game-card .fav-btn,
  .game-card .vote-btn {
    width: 38px;
    height: 38px;
  }

  .fav-btn svg,
  .vote-btn svg {
    width: 22px;
    height: 22px;
  }

  .vote-count {
    font-size: 13.5px;
  }
}
