* { box-sizing: border-box; }
:root {
  --green: #2f5d50; --green-dark: #234840; --cream: #f4efe6; --ink: #2b2118;
  --muted: #7a6a58; --line: #e0d7c8; --gold: #f2b230; --red: #b3402e;
}
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--cream); color: var(--ink); line-height: 1.5; }
a { color: var(--green); }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 24px 0 12px; }

/* header / footer */
header.site { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 24px; background: var(--green); }
header.site .brand { color: #fff; font-weight: 700; font-size: 19px; text-decoration: none; margin-right: auto; }
header.site nav { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
header.site nav a { color: #fff; text-decoration: none; font-size: 15px; }
header.site .who { color: #d6e7e1; font-size: 14px; }
.adminbar { display: flex; gap: 18px; padding: 10px 24px; background: #5a3b22; }
.adminbar a { color: #f8e9cf; text-decoration: none; font-size: 14px; }
footer.site { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 16px; }
.wrap { max-width: 1150px; margin: 0 auto; padding: 24px 16px; }

/* buttons & flash */
.btn { display: inline-block; background: var(--green); color: #fff !important; border: 0; border-radius: 6px;
       padding: 10px 20px; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--green-dark); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.gold { background: var(--gold); color: #3a2600 !important; font-weight: 700; }
.btn.red { background: var(--red); }
.btn.light { background: #fff; color: var(--green) !important; border: 1px solid var(--line); }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash.ok { background: #dcefe7; color: #1d4b3d; }
.flash.err { background: #f8dcd6; color: #7a2617; }

/* forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.form-narrow { max-width: 440px; margin: 20px auto; }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfc5b4; border-radius: 6px; font-size: 15px; font-family: inherit; background: #fff;
}
textarea { min-height: 100px; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.errors { background: #f8dcd6; color: #7a2617; padding: 10px 14px; border-radius: 6px; }
.errors ul { margin: 0; padding-left: 18px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 20px; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* resource grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.res { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none;
       color: var(--ink); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.res:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.12); }
.res .cover { position: relative; height: 230px; background: #ddd; }
.res .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.res .info { padding: 10px 12px 14px; }
.res .info b { display: block; font-size: 15px; line-height: 1.3; }
.res .info span { font-size: 13px; color: var(--muted); }
.gen-cover { width: 100%; height: 100%; padding: 16px 14px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; }
.gen-cover .t { font-weight: 700; font-size: 16px; line-height: 1.25; }
.gen-cover .g { font-size: 12px; opacity: .9; }
.badge { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #fff; color: var(--green); }
.badge.premium { background: var(--gold); color: #3a2600; }
.tag { position: absolute; bottom: 8px; right: 8px; font-size: 11px; padding: 2px 7px; border-radius: 4px; background: rgba(0,0,0,.5); color: #fff; }
.pager { display: flex; gap: 6px; justify-content: center; margin: 28px 0 0; }
.pager a, .pager span { padding: 6px 12px; border-radius: 6px; background: #fff; border: 1px solid var(--line); text-decoration: none; }
.pager span { background: var(--green); color: #fff; border-color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* resource page */
.detail { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.detail .cover { position: relative; height: 330px; border-radius: 8px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.detail .cover img { width: 100%; height: 100%; object-fit: cover; }
.meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.video { position: relative; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; margin: 10px 0 20px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.locked { background: #fff6e0; border: 1px solid #f0d58e; padding: 14px 16px; border-radius: 8px; }
@media (max-width: 700px) { .detail { grid-template-columns: 1fr; } .detail .cover { max-width: 240px; } }

/* admin */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.list th, table.list td { padding: 9px 12px; border-bottom: 1px solid #eee5d7; text-align: left; font-size: 14px; vertical-align: middle; }
table.list th { background: #f8f3ea; font-size: 13px; color: var(--muted); }
table.list form { display: inline; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.stat .n { font-size: 28px; font-weight: 700; color: var(--green); }
.stat .l { font-size: 13px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .b i { display: block; width: 100%; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b small { font-size: 10px; color: var(--muted); padding: 4px 0; white-space: nowrap; }
.bars .b em { font-size: 11px; font-style: normal; color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eee5d7; }
.pill.premium { background: var(--gold); }
.pill.draft { background: #f8dcd6; }

/* ===== Home page bookshelf ===== */
.hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
        background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px; margin-bottom: 18px; }
.hero h1 { margin: 0 0 6px; font-size: 22px; }
.hero p { margin: 0; color: var(--muted); }
.home-search { display: flex; gap: 10px; margin-bottom: 14px; }
.home-search input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chips a { padding: 5px 14px; border-radius: 20px; text-decoration: none; font-size: 14px;
           background: #fff; color: var(--green); border: 1px solid #c9bfae; }
.chips a.on { background: var(--green); color: #fff; border-color: var(--green); }

.shelf-head { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 26px; }
.shelf-head h2 { margin: 0; padding: 8px 16px; background: #5a3b22; color: #f8e9cf; border-radius: 6px 6px 0 0; font-size: 17px; }
.shelf-head a { font-size: 14px; padding-bottom: 6px; }
.bookcase { display: flex; flex-wrap: wrap; padding: 0 10px;
            /* a wooden plank under every row (row = 208px: 22 gap + 170 book + 16 plank) */
            background:
              repeating-linear-gradient(to bottom, transparent 0 192px, #8a5a32 192px 204px, #5c3a1e 204px 208px),
              linear-gradient(#3d2716, #4a301b);
            border: 10px solid #6b4426; border-radius: 0 6px 6px 6px;
            box-shadow: inset 0 8px 18px rgba(0,0,0,.5); }
/* each slot carries a piece of plank; slots touch, so the planks join into a shelf */
.slot { width: 158px; height: 208px; padding: 22px 14px 16px;
        display: flex; align-items: flex-end; justify-content: center; }
.book { position: relative; display: block; width: 120px; height: 170px; text-decoration: none;
        border-radius: 2px 6px 6px 2px; overflow: hidden;
        box-shadow: -4px 0 0 rgba(0,0,0,.25) inset, 3px 4px 10px rgba(0,0,0,.5);
        transition: transform .2s ease, box-shadow .2s ease; }
.book:hover { transform: translateY(-10px) rotate(-1deg); box-shadow: 3px 14px 20px rgba(0,0,0,.6); }
.book img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book .gen-cover { position: relative; padding: 28px 8px 10px 16px; }
.book .gen-cover::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.35); }
.book .gen-cover .t { font-size: 13px; }
.book .gen-cover .g { font-size: 11px; }
.book .badge { top: 6px; right: 6px; font-size: 10px; padding: 2px 6px; }
.book .tag { bottom: 6px; right: 6px; font-size: 10px; }
@media (max-width: 600px) {
  .slot { width: 50%; height: 190px; padding: 18px 8px 16px; }
  .book { width: 110px; height: 156px; }
  .bookcase { background:
      repeating-linear-gradient(to bottom, transparent 0 174px, #8a5a32 174px 186px, #5c3a1e 186px 190px),
      linear-gradient(#3d2716, #4a301b); }
  .home-search { flex-direction: column; }
}

/* ===== Home page finder panel ===== */
.finder { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 12px; margin-bottom: 8px; }
.finder .home-search { margin-bottom: 14px; }
.filter-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; border-top: 1px solid #f0e9dd; }
.filter-label { flex: 0 0 70px; font-weight: 700; font-size: 14px; color: var(--muted); padding-top: 5px; }
.filter-row .chips { margin: 0; }
.showing { margin-top: 8px; padding: 8px 12px; background: #eef5f2; border-radius: 6px; font-size: 14px; }
.showing a { margin-left: 10px; }
@media (max-width: 600px) {
  .filter-row { flex-direction: column; gap: 6px; }
  .filter-label { flex: none; padding-top: 0; }
}

header.site .btn.small { background: var(--gold); color: #3a2600 !important; font-weight: 700; }

/* ===== Games showcase ===== */
header.site nav a.nav-games { color: var(--gold); font-weight: 700; }
.games-spot { position: relative; margin: 22px 0 6px; padding: 24px 24px 26px; border-radius: 14px; color: #eef3ff;
  background:
    radial-gradient(circle at 85% 10%, rgba(242,178,48,.25), transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(80,200,170,.22), transparent 45%),
    linear-gradient(135deg, #142338, #1d2f4d 55%, #1a3b3a);
  box-shadow: 0 10px 30px rgba(20,35,56,.35); overflow: hidden; }
.games-spot::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px);
  background-size: 28px 28px; }
.games-spot > * { position: relative; z-index: 1; }
.gs-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.gs-head h1, .gs-head h2 { margin: 4px 0 6px; font-size: 26px; color: #fff; }
.gs-head p { margin: 0; max-width: 620px; color: #c6d3ea; }
.gs-kicker { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold); }
.gs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.gcard { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; text-decoration: none; color: #fff;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14);
  transition: transform .18s, box-shadow .18s, border-color .18s; }
.gcard:hover { transform: translateY(-5px); border-color: var(--gold); box-shadow: 0 12px 24px rgba(0,0,0,.4); }
.gthumb { position: relative; aspect-ratio: 16 / 9; background: #0c1626; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gfallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; }
.gfallback span { font-weight: 800; font-size: 20px; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.gthumb .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px;
  border-radius: 50%; background: rgba(0,0,0,.55); border: 2px solid #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; padding-left: 4px; transition: background .18s; }
.gcard:hover .play { background: var(--gold); color: #3a2600; border-color: var(--gold); }
.gnew, .gprem { position: absolute; top: 8px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 10px; }
.gnew { left: 8px; background: #e2453c; color: #fff; }
.gprem { right: 8px; background: var(--gold); color: #3a2600; }
.ginfo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.ginfo b { font-size: 16px; line-height: 1.25; }
.ginfo span { font-size: 13px; color: #a9b9d6; }
.ginfo em { font-style: normal; font-size: 13px; color: var(--gold); margin-top: 6px; }
.gfeatured { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: center; margin-bottom: 22px;
  background: rgba(0,0,0,.2); border-radius: 12px; padding: 16px; }
.gfeatured .video { margin: 0; }
.gf-info h2 { margin: 4px 0; font-size: 24px; color: #fff; }
.gf-meta { color: #a9b9d6; margin: 0 0 8px; }
.gf-info p { color: #d6e0f2; }
.gs-chips { margin-bottom: 16px; }
.gs-chips a { background: rgba(255,255,255,.08); color: #e6edfa; border-color: rgba(255,255,255,.25); }
.gs-chips a.on { background: var(--gold); color: #3a2600; border-color: var(--gold); }
.gs-empty { color: #c6d3ea; text-align: center; padding: 30px 0; }
@media (max-width: 800px) { .gfeatured { grid-template-columns: 1fr; } }
.book .tag.game { background: var(--gold); color: #3a2600; font-weight: 700; top: 6px; left: 12px; bottom: auto; right: auto; }

/* ===== Past papers ===== */
.papers-strip { display: flex; align-items: center; gap: 14px; margin: 14px 0 0; padding: 14px 18px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--green); text-decoration: none; color: var(--ink);
  transition: box-shadow .15s, transform .15s; }
.papers-strip:hover { box-shadow: 0 6px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.ps-icon { font-size: 28px; }
.ps-text { flex: 1; color: var(--muted); font-size: 14px; }
.ps-text b { display: block; color: var(--ink); font-size: 17px; }
.ps-go { color: var(--green); font-weight: 700; white-space: nowrap; }
.papers-head h1 { margin: 6px 0 4px; }
.papers-head p { margin: 0 0 14px; color: var(--muted); }
.free-pill { display: inline-block; background: #dcefe7; color: #1d4b3d; font-weight: 800; font-size: 12px; padding: 2px 10px; border-radius: 10px; letter-spacing: .05em; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.pf-grid label { margin-top: 0; }
.paper-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.paper { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.p-icon { flex: 0 0 48px; height: 56px; border-radius: 6px; background: var(--green); color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.1; }
.p-icon span { font-size: 20px; font-weight: 800; }
.p-icon small { font-size: 11px; opacity: .85; }
.p-info { flex: 1; min-width: 0; }
.p-info b { display: block; font-size: 15px; }
.p-info span { font-size: 13px; color: var(--muted); }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 600px) {
  .paper { flex-wrap: wrap; }
  .p-actions { width: 100%; justify-content: flex-start; }
  .papers-strip { flex-wrap: wrap; }
}

/* ===== Logo in header ===== */
header.site .brand { display: flex; align-items: center; gap: 10px; }
header.site .brand img { width: 40px; height: 40px; border-radius: 9px; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
header.site .brand span { display: flex; flex-direction: column; line-height: 1.1; }
header.site .brand small { font-size: 12px; font-weight: 400; color: #cfe3dc; letter-spacing: .02em; }

/* ===== Premium / subscriptions ===== */
header.site .who { color: #d6e7e1; }
.adminbar .count { background: #e2453c; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.premium-hero { border-radius: 14px; padding: 24px 26px; margin-bottom: 18px; color: #fff;
  background: radial-gradient(circle at 90% 0, rgba(242,178,48,.35), transparent 45%), linear-gradient(135deg, #2f5d50, #1f4038); }
.premium-hero h1 { color: #fff; margin: 6px 0 10px; }
.perks { margin: 0; padding-left: 20px; color: #e3efea; }
.perks li { margin: 4px 0; }
.subscribe h2 { margin-top: 26px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.plan input { position: absolute; opacity: 0; }
.plan-box { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 16px 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.plan-box b { font-size: 18px; }
.plan-box .price { font-size: 26px; font-weight: 800; color: var(--green); }
.plan-box .per { font-size: 13px; color: var(--muted); }
.plan-box .pdesc { font-size: 14px; margin-top: 6px; }
.plan input:checked + .plan-box { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,178,48,.35); }
.plan input:focus-visible + .plan-box { outline: 2px solid var(--green); }
.bank pre { margin: 0 0 8px; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 1.6; white-space: pre-wrap; }
.status-on { font-size: 17px; }
.pill.pay-pending { background: #fff0c2; }
.pill.pay-approved { background: #dcefe7; }
.pill.pay-rejected { background: #f8dcd6; }
details.reject { display: inline-block; margin-left: 6px; }
details.reject summary { list-style: none; }
details.reject summary::-webkit-details-marker { display: none; }
details.reject form { display: flex !important; gap: 6px; margin-top: 6px; }
details.reject input { min-width: 200px; }
