@font-face {
  font-family: "CMB";
  src:
    local("CMB"),
    url("../cmb.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #264329;
  --card: #f9fbf7;
  --text: #1b201d;
  --muted: #4f6156;
  --border: #cfd8ce;
  --shadow: 0 22px 60px rgba(9, 25, 16, 0.24);
  --accent: #2f6d4f;
  --accent-strong: #285c43;
  --accent-soft: #dce8dc;
  --nav-text: #153322;
  --focus-ring: rgba(38, 89, 63, 0.42);

  --g: #9fd7b3;
  --r: #f2b3a8;
  --y: #f3dea0;
  --b: #9dc5e8;
  --p: #cbb6de;
  --o: #efbe8f;
  --t: #91cec7;
  --pk: #efbdd1;

  --brand-font: "CMB", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    url("../images/background.png") center center / cover fixed,
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vw, 16px);
  padding:
    calc(clamp(14px, 3vw, 32px) + env(safe-area-inset-top))
    calc(clamp(14px, 3vw, 32px) + env(safe-area-inset-right))
    calc(clamp(14px, 3vw, 32px) + env(safe-area-inset-bottom))
    calc(clamp(14px, 3vw, 32px) + env(safe-area-inset-left));
}

/* ── Header ── */
.header {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: clamp(8px, 1.2vw, 14px);
  flex-wrap: wrap;
  justify-content: flex-end;
  user-select: none;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  text-align: right;
}

.brand .main {
  font-family: var(--brand-font);
  font-weight: 400;
  letter-spacing: 0.2px;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1;
  color: #f0f7ec;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.brand .main .mainDe {
  font-size: 0.58em;
}

.brand .slogan {
  font-size: clamp(11px, 1.6vw, 15px);
  line-height: 1.1;
  color: rgba(230, 245, 225, 0.82);
  font-weight: 700;
  padding-bottom: 4px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Main content card ── */
.app {
  background: rgba(252, 254, 251, 0.97);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.8vw, 28px);
}

/* ── Intro text ── */
.intro {
  margin: 0 0 clamp(14px, 2vw, 20px);
  color: var(--muted);
  font-size: clamp(13px, 1.3vw, 15px);
  line-height: 1.5;
}

/* ── Games header row ── */
.gamesHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(14px, 2.2vw, 20px);
  flex-wrap: wrap;
}

.gamesTitle {
  margin: 0;
  font-size: clamp(18px, 2.4vw, 24px);
  letter-spacing: 0.2px;
  color: var(--text);
}

.headerControls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sortDropdown {
  position: relative;
}

.sortDropdownTrigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #e7f0df;
  color: var(--nav-text);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: clamp(12px, 1.3vw, 14px);
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 36, 25, 0.08);
  transition: filter 0.12s ease;
  white-space: nowrap;
  user-select: none;
}

.sortDropdownTrigger:hover {
  filter: brightness(1.03);
}

.sortArrow {
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.sortDropdownTrigger[aria-expanded="true"] .sortArrow {
  transform: rotate(180deg);
}

.sortDropdownList {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(9, 25, 16, 0.16);
  list-style: none;
  margin: 0;
  padding: 4px;
  z-index: 100;
}

.sortDropdownList.open {
  display: block;
}

.sortOption {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}

.sortOption:hover {
  background: var(--accent-soft);
}

.sortOption.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.randomBtn {
  border: 1px solid rgba(0,0,0,0.15);
  background: #2f6d4f;
  color: #f0f8f2;
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: clamp(12px, 1.3vw, 14px);
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 36, 25, 0.14);
  transition: transform 0.06s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  white-space: nowrap;
}

.randomBtn:hover {
  filter: brightness(1.1);
}

.randomBtn:active {
  transform: translateY(1px);
}

/* ── Game grid ── */
.gameGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(12px, 1.8vw, 18px);
}

/* ── Game card ── */
.gameCard {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(16, 36, 25, 0.12);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-rows: 190px auto;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gameCard:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(16, 36, 25, 0.18);
}

.gameCard:active {
  transform: translateY(-1px);
}

.gameCard:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Card thumbnail ── */
.thumb {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.thumb::before {
  content: "";
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(800px 320px at 12% 10%, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 60%),
    radial-gradient(700px 340px at 84% 86%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0) 66%),
    linear-gradient(145deg, #1e4333, #173628);
}

.thumb.bg-sky::before        { background: linear-gradient(145deg, #79b9e9, #4c8fc4); }
.thumb.bg-green-dark::before  { background: linear-gradient(145deg, #2f5b43, #1e3f2f); }
.thumb.bg-green-light::before { background: linear-gradient(145deg, #95cd85, #67a95a); }
.thumb.bg-blue-dark::before   { background: linear-gradient(145deg, #3c5c92, #2a426a); }
.thumb.bg-red::before         { background: linear-gradient(145deg, #d96862, #aa403e); }
.thumb.bg-yellow::before      { background: linear-gradient(145deg, #e8cf67, #c7a83a); }
.thumb.bg-orange::before      { background: linear-gradient(145deg, #df9654, #b86b2b); }
.thumb.bg-purple::before      { background: linear-gradient(145deg, #8772b4, #634d90); }
.thumb.bg-brown::before       { background: linear-gradient(145deg, #8a644d, #614634); }
.thumb.bg-pink::before        { background: linear-gradient(145deg, #d889ac, #b45f86); }
.thumb.bg-coral::before       { background: linear-gradient(145deg, #f08a70, #c85a47); }
.thumb.bg-teal::before        { background: linear-gradient(145deg, #5ea89e, #3f7d75); }
.thumb.bg-sand::before        { background: linear-gradient(145deg, #c6ad85, #9d835e); }
.thumb.bg-blue::before        { background: linear-gradient(145deg, #4f7ed4, #1e3f8a); }

.thumbMore::before { background: linear-gradient(145deg, #4a6355, #2d4a3a); }
.gameCard.gameCardMore .cardBody { background: linear-gradient(180deg, #2d4a3a 0%, #264230 25%, #1e3828 50%, #264230 75%, #2d4a3a 100%); }

.thumbLabel {
  position: relative;
  z-index: 1;
  font-family: var(--brand-font);
  font-weight: 400;
  font-size: clamp(24px, 3.2vw, 38px);
  letter-spacing: 0.35px;
  color: #f7f9f2;
  text-align: center;
  max-width: 90%;
  padding: 2px 8px;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 7px rgba(255, 255, 255, 0.14),
    1px 1px 0 rgba(8, 20, 14, 0.62);
}

/* ── Card body ── */
.cardBody {
  padding: clamp(10px, 1.6vw, 14px);
  background: #2a3d34;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cardBody p {
  margin: 0;
  color: #ffffff;
  font-size: clamp(12px, 1.2vw, 14px);
  line-height: 1.45;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Per-color card bodies — smooth bell-curve gradient, barely darker in the middle */
.gameCard.bg-sky         .cardBody { background: linear-gradient(180deg, #2e5a82 0%, #29527a 25%, #244c72 50%, #29527a 75%, #2e5a82 100%); }
.gameCard.bg-purple      .cardBody { background: linear-gradient(180deg, #4a3480 0%, #432e76 25%, #3c286c 50%, #432e76 75%, #4a3480 100%); }
.gameCard.bg-pink        .cardBody { background: linear-gradient(180deg, #7a3864 0%, #70305c 25%, #662854 50%, #70305c 75%, #7a3864 100%); }
.gameCard.bg-coral       .cardBody { background: linear-gradient(180deg, #8c4436 0%, #813c30 25%, #763428 50%, #813c30 75%, #8c4436 100%); }
.gameCard.bg-teal        .cardBody { background: linear-gradient(180deg, #2e7a70 0%, #287068 25%, #226660 50%, #287068 75%, #2e7a70 100%); }
.gameCard.bg-green-light .cardBody { background: linear-gradient(180deg, #3a7830 0%, #346e2a 25%, #2e6424 50%, #346e2a 75%, #3a7830 100%); }
.gameCard.bg-red         .cardBody { background: linear-gradient(180deg, #8a2e2c 0%, #7e2826 25%, #722220 50%, #7e2826 75%, #8a2e2c 100%); }
.gameCard.bg-orange      .cardBody { background: linear-gradient(180deg, #8c4e1a 0%, #804616 25%, #743e12 50%, #804616 75%, #8c4e1a 100%); }
.gameCard.bg-green-dark  .cardBody { background: linear-gradient(180deg, #285c40 0%, #225438 25%, #1c4c30 50%, #225438 75%, #285c40 100%); }
.gameCard.bg-brown       .cardBody { background: linear-gradient(180deg, #664028 0%, #5c3822 25%, #52301c 50%, #5c3822 75%, #664028 100%); }
.gameCard.bg-yellow      .cardBody { background: linear-gradient(180deg, #7a6010 0%, #6e560e 25%, #624c0c 50%, #6e560e 75%, #7a6010 100%); }
.gameCard.bg-sand        .cardBody { background: linear-gradient(180deg, #6e4e26 0%, #634622 25%, #583e1e 50%, #634622 75%, #6e4e26 100%); }
.gameCard.bg-blue        .cardBody { background: linear-gradient(180deg, #1e3a80 0%, #1a3478 25%, #162e70 50%, #1a3478 75%, #1e3a80 100%); }

/* All card body text is white */
.cardBody p { color: #ffffff; }

/* ── Responsive breakpoints ── */
@media (max-width: 860px) {
  .gameGrid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gameCard {
    grid-template-rows: 160px auto;
  }
}

@media (max-width: 520px) {
  .brand {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .gameGrid {
    grid-template-columns: 1fr;
  }

  .gameCard {
    grid-template-rows: 140px auto;
  }

  .cardBody p {
    -webkit-line-clamp: 4;
  }

  .gamesHeader {
    flex-direction: column;
    align-items: flex-start;
  }

  .headerControls {
    width: 100%;
  }

  .sortDropdown,
  .randomBtn {
    flex: 1;
  }

  .sortDropdownTrigger {
    width: 100%;
    justify-content: space-between;
  }

  .sortDropdownList {
    left: 0;
    right: 0;
    min-width: unset;
  }
}

/* ── Pagination ── */
.paginationRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pageLabel {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.pagination {
  display: flex;
  gap: 8px;
}

.pageBtn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pageBtn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.pageBtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ── Footer legal bar ── */
.legalBar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0;
  flex: 0 0 auto;
}

.legalBar a {
  text-decoration: none;
  color: rgba(230, 245, 225, 0.85);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  transition: opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.legalBar a + a::before {
  content: "|";
  color: rgba(230, 245, 225, 0.45);
  margin: 0 8px;
}

.legalBar a:hover {
  opacity: 0.82;
}

.legalBar a:active {
  opacity: 0.68;
}
