:root {
  --navy: #08102d;
  --panel: #111b48;
  --panel-light: #18275c;
  --text: #f7fbff;
  --muted: #aebce4;
  --yellow: #ffcc5c;
  --blue: #8dd9ff;
  --green: #29d3a2;
  --border: #ffffff22;
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
  color: var(--text);
  background: var(--navy);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 10% 10%, #28469580, transparent 32%), radial-gradient(circle at 92% 90%, #522b8770, transparent 30%), var(--navy); }
a { color: inherit; }
button, input { font: inherit; }
.portal-header { width: min(1240px, calc(100% - 40px)); min-height: 78px; margin: auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px; border-bottom: 1px solid var(--border); }
.portal-brand, .guest-brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.portal-brand span, .guest-brand span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--yellow); box-shadow: 0 10px 28px #ffcc5c35; }
.portal-nav { display: flex; gap: 26px; }
.portal-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 800; }
.portal-nav a:hover { color: white; }
.account-menu { justify-self: end; display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: .85rem; }
.account-menu form { margin: 0; }
.link-button { padding: 0; border: 0; color: var(--blue); background: none; cursor: pointer; font-weight: 800; }
.portal-main { width: min(1180px, calc(100% - 40px)); margin: auto; padding: 62px 0 90px; }
.library-heading, .results-heading, .boards-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 42px; }
.page-kicker, .auth-kicker { color: var(--blue); font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
.library-heading h1, .results-heading h1, .boards-heading h1 { margin: 10px 0 10px; font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1; letter-spacing: -.05em; }
.library-heading p, .results-heading p, .boards-heading p { margin: 0; color: var(--muted); font-size: 1rem; }
.homepage-install { margin-top: 18px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 13px; color: #17204c; background: var(--yellow); box-shadow: 0 12px 30px #ffcc5c25; cursor: pointer; font-weight: 900; }
.homepage-install[hidden] { display: none; }
.homepage-install:hover, .homepage-install:focus-visible { transform: translateY(-1px); box-shadow: 0 15px 36px #ffcc5c38; outline: 2px solid var(--blue); outline-offset: 3px; }
.summary-strip { flex: 0 0 auto; padding: 18px 22px; border: 1px solid var(--border); border-radius: 22px; display: flex; gap: 28px; background: #ffffff0a; box-shadow: 0 18px 50px #02061755; }
.summary-strip div { min-width: 78px; display: grid; gap: 3px; }
.summary-strip strong { color: var(--yellow); font-size: 1.55rem; }
.summary-strip span { color: #8292c3; font-size: .72rem; font-weight: 800; }
.category-filter-shell { position: relative; margin: -12px 0 28px; padding-right: 50px; }
.category-filter { --category-row-height: 39px; --category-expanded-height: 39px; max-height: var(--category-row-height); display: flex; flex-wrap: wrap; gap: 9px; overflow: hidden; transition: max-height .3s ease; }
.category-filter-shell.is-expanded .category-filter { max-height: var(--category-expanded-height); }
.category-filter-toggle { position: absolute; top: 0; right: 0; z-index: 2; width: 39px; height: 39px; padding: 0; border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; color: var(--text); background: var(--panel); box-shadow: -12px 0 22px var(--navy); cursor: pointer; }
.category-filter-toggle[hidden] { display: none; }
.category-filter-toggle span { font-size: 1.25rem; line-height: 1; transform: translateY(-2px); transition: transform .25s ease; }
.category-filter-shell.is-expanded .category-filter-toggle span { transform: translateY(2px) rotate(180deg); }
.category-filter-toggle:hover, .category-filter-toggle:focus-visible { border-color: var(--blue); outline: 2px solid color-mix(in srgb, var(--blue), transparent 55%); outline-offset: 2px; }
.category-button { min-height: 39px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: #ffffff08; cursor: pointer; font-weight: 900; }
.category-button span { margin-left: 5px; color: #8292c3; font-size: .7rem; }
.category-button:hover, .category-button:focus-visible { color: white; border-color: #8dd9ff66; outline: none; }
.category-button.is-active { color: #17204c; border-color: var(--yellow); background: var(--yellow); }
.category-button.is-active span { color: #5d4a18; }
.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.game-grid [hidden] { display: none !important; }
.library-card { --game-colour: var(--green); min-height: 350px; padding: 22px; border: 1px solid var(--border); border-radius: 24px; display: flex; flex-direction: column; background: linear-gradient(155deg, #17275ee6, #0d173dea); box-shadow: 0 28px 70px #02061760, inset 0 1px #ffffff20; position: relative; overflow: hidden; transition:opacity .28s ease,transform .28s ease; }
.library-card.is-loading-in{opacity:0;transform:translateY(18px)}
.library-card::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 55%; height: 3px; background: linear-gradient(90deg, var(--game-colour), transparent); }
.game-card-top { min-height: 52px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.game-icon { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--game-colour), transparent 82%); font-size: 1.55rem; }
.game-card-copy { flex: 1; }
.card-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.age-chip, .category-chip { padding: 5px 9px; border-radius: 999px; font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.category-chip { color: var(--game-colour); background: color-mix(in srgb, var(--game-colour), transparent 87%); }
.age-chip { color: var(--muted); background: #ffffff0a; }
.game-card-copy h2 { margin: 18px 0 9px; font-size: 1.35rem; line-height:1.1; }
.game-card-copy p { margin: 0; max-width: 540px; color: var(--muted); font-size:.86rem; line-height: 1.55; }
.game-card-footer { margin-top: 22px; padding-top: 15px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #8292c3; font-size: .7rem; }
.play-link { flex:0 0 auto; padding: 9px 11px; border-radius: 11px; color: #17204c; background: var(--game-colour); text-decoration: none; font-weight: 900; }
.game-load-sentinel{min-height:90px;margin-top:20px;display:flex;align-items:center;justify-content:center;gap:11px;color:var(--muted);font-size:.78rem;font-weight:900}.game-load-sentinel[hidden]{display:none}.game-load-sentinel i{width:22px;height:22px;border:3px solid #8dd9ff33;border-top-color:var(--blue);border-radius:50%;animation:game-load-spin .8s linear infinite}.game-load-sentinel:not(.is-loading) i{animation-play-state:paused;opacity:.5}@keyframes game-load-spin{to{transform:rotate(360deg)}}
.coming-soon { --game-colour: #7786b8; border-style: dashed; opacity: .78; }
.results-summary { width: fit-content; margin-bottom: 28px; }
.results-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 24px; background: #ffffff08; }
.results-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.results-table th, .results-table td { padding: 17px 20px; border-bottom: 1px solid var(--border); text-align: left; }
.results-table th { color: #8292c3; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.results-table td { color: var(--muted); font-size: .88rem; }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table td:first-child { color: white; }
.table-game-icon { margin-right: 9px; }
.audit-table td { vertical-align: top; }
.audit-table td small { display: block; margin-top: 3px; color: #7384b9; }
.audit-table code { display: block; max-width: 420px; overflow-wrap: anywhere; color: #9cdfff; white-space: normal; }
.primary-button, .secondary-button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; color: #17204c; background: var(--yellow); text-decoration: none; font-weight: 900; cursor: pointer; }
.secondary-button { color: white; border: 1px solid var(--border); background: #ffffff0b; }
.empty-state { min-height: 360px; padding: 45px; border: 1px solid var(--border); border-radius: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #ffffff08; }
.empty-state > span { font-size: 3rem; }
.empty-state h1, .empty-state h2 { margin: 18px 0 8px; }
.empty-state p { margin: 0 0 24px; color: var(--muted); }

.period-boards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:22px; }
.board-panel { overflow:hidden; border:1px solid var(--border); border-radius:26px; background:linear-gradient(155deg,#17275ee6,#0d173dea); box-shadow:0 24px 60px #02061755; }
.board-title { min-height:86px; padding:18px 22px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:13px; background:#ffffff06; }
.board-title>span { width:46px; height:46px; border-radius:14px; display:grid; place-items:center; background:#ffcc5c18; font-size:1.45rem; }
.board-title small,.leader-name small,.leader-score small { color:#8292c3; font-size:.65rem; font-weight:800; }
.board-title h2 { margin:2px 0 0; font-size:1.45rem; }
.leader-list { margin:0; padding:8px; list-style:none; }
.leader-list li { min-height:64px; padding:9px 12px; border-radius:15px; display:grid; grid-template-columns:38px 1fr auto; gap:10px; align-items:center; }
.leader-list li+li { border-top:1px solid #ffffff0d; }
.leader-list li.is-current-user { border:1px solid #8dd9ff55; background:#8dd9ff10; }
.rank { text-align:center; color:var(--blue); font-weight:900; }
.leader-name,.leader-score { display:grid; gap:2px; }
.leader-name strong { color:white; }
.leader-score { color:var(--yellow); text-align:right; }
.leader-score small { font-weight:700; }
.board-empty { min-height:160px; padding:35px; display:grid; place-items:center; color:var(--muted); text-align:center; }
.badge-section { margin-top:54px; }
.section-heading h2 { margin:7px 0; font-size:2rem; }
.section-heading p { margin:0 0 26px; color:var(--muted); }
.badge-section>h3 { margin:30px 0 12px; color:var(--blue); }
.badge-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.period-badge { position:relative; min-height:176px; padding:19px; border:1px solid var(--border); border-radius:20px; display:grid; grid-template-columns:46px 1fr; gap:12px; background:#ffffff07; opacity:.62; overflow:hidden; }
.period-badge.is-earned { border-color:#ffcc5c66; background:linear-gradient(145deg,#ffcc5c13,#ffffff07); opacity:1; box-shadow:0 18px 45px #02061745; }
.badge-icon { width:46px; height:46px; border-radius:14px; display:grid; place-items:center; background:#ffffff0b; font-size:1.45rem; filter:grayscale(1); }
.is-earned .badge-icon { background:#ffcc5c22; filter:none; }
.period-badge small { color:var(--yellow); font-size:.66rem; font-weight:900; text-transform:uppercase; }
.period-badge h4 { margin:4px 0 7px; font-size:1.05rem; }
.period-badge p { margin:0; color:var(--muted); font-size:.78rem; line-height:1.45; }
.badge-progress { position:absolute; left:19px; right:19px; bottom:15px; height:5px; border-radius:99px; background:#ffffff12; overflow:hidden; }
.badge-progress i { display:block; width:var(--progress); height:100%; border-radius:inherit; background:var(--blue); }
.is-earned .badge-progress i { background:var(--yellow); }

.guest-body { display: grid; place-items: center; padding: 28px 16px; }
.guest-shell { width: min(470px, 100%); }
.guest-brand { width: fit-content; margin: 0 auto 24px; }
.auth-card { padding: clamp(28px, 7vw, 48px); border: 1px solid var(--border); border-radius: 30px; background: linear-gradient(155deg, #17275ef0, #0d173df0); box-shadow: 0 35px 90px #02061790, inset 0 1px #ffffff22; }
.auth-card h1 { margin: 12px 0 10px; font-size: clamp(2rem, 7vw, 3rem); line-height: 1; letter-spacing: -.045em; }
.auth-card > p { color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 16px; margin-top: 28px; }
.auth-form label { display: grid; gap: 7px; color: #c6d1ee; font-size: .82rem; font-weight: 800; }
.auth-form input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #ffffff2a; border-radius: 13px; outline: none; color: white; background: #07102d99; }
.auth-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #8dd9ff1e; }
.auth-form small { color: #7384b9; font-weight: 400; }
.auth-switch { margin: 24px 0 0 !important; text-align: center; font-size: .88rem; }
.auth-switch a { color: var(--yellow); font-weight: 900; }
.alert { margin-top: 18px; padding: 12px 14px; border-radius: 12px; font-size: .85rem; }
.alert.error { color: #ffd9de; border: 1px solid #ff75894a; background: #ff758916; }
.alert.success { color:#cffff0; border:1px solid #29d3a255; background:#29d3a214; }
.alert ul { margin: 0; padding-left: 18px; }

.library-heading-actions{margin-top:16px;display:flex;flex-wrap:wrap;gap:9px}.today-board-button,.homepage-install{min-height:42px;padding:0 15px;border:1px solid #ffcc5c66;border-radius:12px;display:inline-flex;align-items:center;color:#17204c;background:var(--yellow);text-decoration:none;font-weight:900}.homepage-install{color:white;border-color:var(--border);background:#ffffff0b}.today-heading{align-items:center}.daily-board-progress{min-width:210px;padding:17px 20px;border:1px solid #ffcc5c55;border-radius:19px;display:grid;grid-template-columns:1fr auto;gap:2px 12px;background:#ffcc5c0b}.daily-board-progress strong{color:var(--yellow);font-size:1.5rem}.daily-board-progress span{align-self:center;color:var(--muted);font-size:.72rem}.daily-board-progress i{grid-column:1/-1;height:7px;margin-top:7px;border-radius:99px;background:#ffffff12;overflow:hidden}.daily-board-progress b{display:block;width:var(--progress);height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--blue),var(--yellow))}.today-badge-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.today-badge{position:relative;min-height:265px;padding:22px;border:1px solid var(--border);border-radius:23px;display:flex;flex-direction:column;align-items:flex-start;background:linear-gradient(150deg,#17275e,#0c153b);overflow:hidden}.today-badge-number{position:absolute;right:17px;top:15px;color:#7788bb;font-weight:900}.today-badge-icon{width:62px;height:62px;border-radius:18px;display:grid;place-items:center;background:#ffffff10;font-size:2rem;filter:grayscale(1) brightness(.4);opacity:.65}.today-badge.is-earned{border-color:#ffcc5c77;background:linear-gradient(150deg,#27356b,#173f4d)}.today-badge.is-earned .today-badge-icon{background:#ffcc5c20;filter:none;opacity:1}.task-state{margin-top:15px;color:#7f90be;font-size:.62rem;font-weight:900;letter-spacing:.08em;text-transform:uppercase}.is-earned .task-state{color:var(--green)}.today-badge h2{margin:6px 0 4px}.today-badge p{margin:0 0 18px;color:var(--muted);font-size:.78rem}.today-badge p strong{color:var(--yellow)}.today-badge>a{margin-top:auto;color:var(--blue);font-weight:900;text-decoration:none}.today-badge>a span{color:var(--yellow)}.adaptive-note{margin:24px 0 0;padding:14px 17px;border-left:3px solid var(--blue);color:var(--muted);background:#8dd9ff0a}.badge-settings-form{display:grid;gap:18px}.settings-panel{padding:24px;border:1px solid var(--border);border-radius:23px;background:linear-gradient(150deg,#17275e,#0d173d)}.settings-panel h2{margin:5px 0}.settings-panel>p{color:var(--muted)}.game-checkboxes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.game-checkboxes label{min-height:52px;padding:9px 11px;border:1px solid #ffffff1d;border-radius:12px;display:flex;align-items:center;gap:9px;background:#07102d77}.game-checkboxes input{accent-color:var(--yellow)}.game-checkboxes span{font-size:1.2rem}.game-checkboxes b{font-size:.76rem}.settings-numbers{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}.settings-numbers label{display:grid;grid-template-columns:1fr 76px;gap:6px 12px}.settings-numbers label>span{font-weight:900}.settings-numbers input{height:42px;padding:0 10px;border:1px solid #ffffff2a;border-radius:10px;color:white;background:#07102d}.settings-numbers small{grid-column:1/-1;color:var(--muted);line-height:1.4}

@media (max-width: 850px) {
  .portal-header { grid-template-columns: 1fr auto; }
  .portal-nav { order: 3; grid-column: 1 / -1; padding-bottom: 14px; }
  .library-heading, .results-heading, .boards-heading { align-items: stretch; flex-direction: column; }
  .summary-strip { width: 100%; justify-content: space-between; }
  .game-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .period-boards { grid-template-columns:1fr; }
  .badge-grid { grid-template-columns:1fr; }
  .today-badge-grid,.game-checkboxes,.settings-numbers{grid-template-columns:1fr}
}
@media (max-width: 560px) {
  .portal-header, .portal-main { width: calc(100% - 24px); }
  .portal-header { min-height: 68px; }
  .portal-brand strong, .account-menu > span { display: none; }
  .portal-main { padding-top: 38px; }
  .summary-strip { gap: 14px; padding: 15px; overflow-x: auto; }
  .summary-strip div { min-width: 70px; }
  .game-grid{grid-template-columns:1fr}.library-card { min-height: 300px; padding: 22px; }
}
