/* =========================================================
   GRAYMAX — retro block-world styles
   Night mode is the default look; day mode swaps the palette.
   ========================================================= */

:root {
  --sky-top: #0b1026;
  --sky-bot: #2a3170;
  --bg: #15151b;
  --check: #1c1c25;
  --panel: #2b2b36;
  --panel-hi: #4a4a5a;
  --panel-sh: #1c1c24;
  --panel-lo: #08080b;
  --slot: #1a1a22;
  --slot-hi: #3c3c4a;
  --slot-lo: #0b0b0f;
  --text: #ecebf3;
  --muted: #a9a7bb;
  --heading: #ffffff;
  --accent: #7ed957;
  --gold: #f5c542;
  --link: #5ee8de;
  --active: #ffffff;
  --xp-1: #b6ff6a;
  --xp-2: #4fae22;
  --board-lt: #e9dab6;
  --board-dk: #8b6a48;
  --orb: #ecebf5;
  --orb-detail: #b9b8c8;
  color-scheme: dark;
}

:root[data-theme="day"] {
  --sky-top: #4f9cff;
  --sky-bot: #b9ddff;
  --bg: #d9d3c3;
  --check: #cec7b4;
  --panel: #c6c6c6;
  --panel-hi: #ffffff;
  --panel-sh: #8b8b8b;
  --panel-lo: #373737;
  --slot: #8b8b8b;
  --slot-hi: #ffffff;
  --slot-lo: #373737;
  --text: #1f1f24;
  --muted: #45454e;
  --heading: #1a1a1f;
  --accent: #23720f;
  --gold: #7a5200;
  --link: #075f59;
  --active: #ffffff;
  --orb: #ffd84a;
  --orb-detail: #ffb92e;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --sky-top: #4f9cff;
    --sky-bot: #b9ddff;
    --bg: #d9d3c3;
    --check: #cec7b4;
    --panel: #c6c6c6;
    --panel-hi: #ffffff;
    --panel-sh: #8b8b8b;
    --panel-lo: #373737;
    --slot: #8b8b8b;
    --slot-hi: #ffffff;
    --slot-lo: #373737;
    --text: #1f1f24;
    --muted: #45454e;
    --heading: #1a1a1f;
    --accent: #23720f;
    --gold: #7a5200;
    --link: #075f59;
    --active: #ffffff;
    --orb: #ffd84a;
    --orb-detail: #ffb92e;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: "VT323", ui-monospace, monospace;
  font-size: 22px;
  line-height: 1.25;
  background-color: var(--bg);
  /* chessboard floor */
  background-image: conic-gradient(var(--check) 90deg, transparent 90deg 180deg, var(--check) 180deg 270deg, transparent 270deg);
  background-size: 96px 96px;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 3px; }

p { margin: 0 0 0.6em; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.muted { color: var(--muted); }
.small { font-size: 18px; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: #000;
  color: #fff;
  padding: 8px 12px;
}
.skip:focus { left: 8px; }

:focus-visible {
  outline: 3px dashed var(--gold);
  outline-offset: 3px;
}

/* ---------- Pixel headings ---------- */
.h, .h3, .logo, .btn, .hotbar a, .tag, .lvl, .stat-num, .toast-title, .filter {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-weight: normal;
  letter-spacing: 0;
}

.h {
  font-size: 16px;
  line-height: 1.5;
  color: var(--heading);
  margin: 0 0 14px;
  text-transform: uppercase;
}

.h3 {
  font-size: 12px;
  line-height: 1.5;
  color: var(--heading);
  margin: 18px 0 10px;
  text-transform: uppercase;
}

/* ---------- Header / sky ---------- */
.sky {
  position: relative;
  overflow: hidden;
  background: linear-gradient(var(--sky-top), var(--sky-bot));
}

.sky-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* pixel stars */
  background-image:
    linear-gradient(#fff 0 0), linear-gradient(#fff 0 0), linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0), linear-gradient(#fff 0 0), linear-gradient(#fff 0 0),
    linear-gradient(#cfd6ff 0 0), linear-gradient(#cfd6ff 0 0), linear-gradient(#cfd6ff 0 0);
  background-size: 4px 4px;
  background-repeat: no-repeat;
  background-position:
    6% 18%, 19% 52%, 33% 12%, 47% 40%, 58% 16%, 71% 58%,
    84% 22%, 92% 48%, 40% 70%;
}

.orb {
  position: absolute;
  right: 9%;
  top: 22px;
  width: 48px;
  height: 48px;
  background: var(--orb);
  box-shadow: inset -8px -8px 0 var(--orb-detail), 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.cloud {
  position: absolute;
  width: 96px;
  height: 20px;
  background: #fff;
  box-shadow: 16px -16px 0 #fff, 48px -16px 0 #fff, 32px -16px 0 #fff;
  opacity: 0;
  animation: drift 60s linear infinite;
}
.cloud::after {
  content: "";
  position: absolute;
  left: 24px;
  top: -16px;
  width: 48px;
  height: 16px;
  background: #fff;
}
.c1 { top: 52px; left: -10%; }
.c2 { top: 92px; left: -30%; animation-duration: 85s; animation-delay: -30s; transform: scale(0.7); }
.c3 { top: 36px; left: -50%; animation-duration: 110s; animation-delay: -70s; }

@keyframes drift {
  from { translate: 0 0; }
  to { translate: 140vw 0; }
}

:root[data-theme="day"] .sky-deco { background-image: none; }
:root[data-theme="day"] .cloud { opacity: 0.95; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .sky-deco { background-image: none; }
  :root:not([data-theme]) .cloud { opacity: 0.95; }
}

.header-inner {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-top: 40px;
  padding-bottom: 28px;
}

.logo {
  display: inline-block;
  text-decoration: none;
  font-size: clamp(30px, 8.5vw, 72px);
  line-height: 1.1;
  white-space: nowrap;
}
.logo .gray {
  color: #e6e6ee;
  text-shadow: 4px 4px 0 #4b4b58, 6px 6px 0 #111;
}
.logo .max {
  color: #8be35f;
  text-shadow: 4px 4px 0 #2f6d16, 6px 6px 0 #111;
}

.tagline {
  margin: 14px 0 0;
  color: #fff;
  font-size: 24px;
  text-shadow: -2px 0 #1b2140, 2px 0 #1b2140, 0 -2px #1b2140, 0 2px #1b2140, 3px 3px 0 #1b2140;
}

.terrain {
  height: 48px;
  background-size: 48px 48px;
  background-repeat: repeat-x;
  image-rendering: pixelated;
  border-bottom: 4px solid #2b1a0c;
}

/* ---------- Buttons ---------- */
.btn {
  flex: none;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.4;
  padding: 10px 12px;
  color: #fff;
  background: #6f6f6f;
  border: 3px solid #111;
  box-shadow: inset 3px 3px 0 #a9a9a9, inset -3px -3px 0 #4a4a4a;
  text-shadow: 2px 2px 0 #333;
}
.btn:hover { background: #7f8fd0; box-shadow: inset 3px 3px 0 #b8c4f5, inset -3px -3px 0 #4c5a99; }
.btn:active { box-shadow: inset -3px -3px 0 #a9a9a9, inset 3px 3px 0 #4a4a4a; }

/* ---------- Panels & slots ---------- */
.panel {
  background: var(--panel);
  border: 3px solid var(--panel-lo);
  box-shadow: inset 4px 4px 0 var(--panel-hi), inset -4px -4px 0 var(--panel-sh);
  padding: 20px;
}

.slot {
  display: inline-grid;
  place-items: center;
  flex: none;
  background: var(--slot);
  box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi);
  padding: 8px;
}

.sprite { display: block; image-rendering: pixelated; }

/* ---------- Hotbar navigation ---------- */
nav.wrap { margin-top: -20px; position: relative; z-index: 2; }

.hotbar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 3px solid var(--panel-lo);
  box-shadow: inset 4px 4px 0 var(--panel-hi), inset -4px -4px 0 var(--panel-sh), 0 6px 0 rgba(0, 0, 0, 0.35);
}

.hotbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 9px;
  line-height: 1.3;
  text-align: center;
  background: var(--slot);
  box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi);
  transition: transform 0.08s;
}
.hotbar a:hover { transform: translateY(-2px); }
.hotbar a .key {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 8px;
  color: var(--muted);
}
.hotbar a[aria-current="page"] {
  outline: 4px solid var(--active);
  outline-offset: -1px;
  box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi), 0 0 0 7px #111;
  z-index: 1;
}

/* ---------- Main ---------- */
main { padding-top: 28px; padding-bottom: 48px; outline: none; }

.view { animation: pop 0.18s steps(3); }
@keyframes pop { from { translate: 0 8px; } to { translate: 0 0; } }

.view > * + * { margin-top: 20px; }

.view-head {
  display: flex;
  align-items: center;
  gap: 16px;
}
.view-head .h { margin: 0 0 6px; font-size: 18px; }
.view-head p { margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.tag {
  display: inline-block;
  font-size: 8px;
  line-height: 1;
  padding: 6px 8px;
  color: #fff;
  background: #3a3a46;
  border: 2px solid #111;
  text-transform: uppercase;
  vertical-align: middle;
}
.tag.reading { background: #1e7a3c; }
.tag.finished { background: #2b5fb8; }
.tag.next { background: #7a4bb0; }

/* ---------- Home ---------- */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 20px;
}

.player-top { display: flex; gap: 16px; align-items: center; }
.player-name {
  font-family: "Press Start 2P", monospace;
  font-weight: normal;
  font-size: 20px;
  margin: 0 0 6px;
  color: var(--heading);
}
.player-top p { margin: 0 0 8px; }

.hearts { display: flex; gap: 2px; flex-wrap: wrap; }

.level {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 20px;
  margin-bottom: 6px;
}
.lvl { font-size: 14px; color: var(--accent); }

.xp {
  height: 18px;
  background: var(--slot-lo);
  border: 3px solid #111;
  position: relative;
}
.xp > span {
  display: block;
  height: 100%;
  background: linear-gradient(var(--xp-1), var(--xp-2));
  transition: width 0.6s steps(12);
}
.xp::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 3px), #111 calc(10% - 3px) 10%);
}
.xp-hint { margin-top: 8px; font-size: 18px; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0 0;
}
.stats div {
  background: var(--slot);
  box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi);
  padding: 12px;
}
.stats dt { color: var(--muted); font-size: 18px; }
.stats dd { margin: 4px 0 0; }
.stat-num { font-size: 18px; color: #fff; text-shadow: 2px 2px 0 #111; }

.inventory {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}
.inventory li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 19px;
}

.favs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 24px; margin: 0; }
.favs dt { color: var(--muted); font-size: 18px; }
.favs dd { margin: 0; color: var(--heading); }

.card-link { display: block; color: inherit; text-decoration: none; transition: transform 0.08s; }
.card-link:hover { transform: translate(-2px, -2px); }

.card-row { display: flex; gap: 14px; align-items: flex-start; }
.card-row > div { min-width: 0; }
.card-label {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.card-title { font-size: 26px; line-height: 1.1; margin: 0 0 6px; color: var(--heading); font-weight: normal; }

/* ---------- Thoughts ---------- */
.entry header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.entry time { color: var(--muted); }
.entry h3 { font-size: 30px; line-height: 1.1; margin: 0 0 10px; color: var(--heading); font-weight: normal; }
.entry p:last-child { margin-bottom: 0; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter {
  cursor: pointer;
  font-size: 9px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--slot);
  border: 0;
  box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi);
}
.filter[aria-pressed="true"] { outline: 3px solid var(--active); outline-offset: -1px; color: var(--heading); box-shadow: inset 3px 3px 0 var(--slot-lo), inset -3px -3px 0 var(--slot-hi), 0 0 0 5px #111; }

/* ---------- Books & trophies ---------- */
.book h3, .trophy h3, .sport h3 { font-size: 26px; line-height: 1.1; margin: 0 0 4px; color: var(--heading); font-weight: normal; }
.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.rating { display: flex; gap: 2px; }
.trophy .card-row { margin-bottom: 4px; }

/* ---------- Chess ---------- */
.board-card figure { margin: 0; }
.board {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  max-width: 400px;
  border: 4px solid #111;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.35);
}
.sq { display: grid; place-items: center; line-height: 1; font-size: 9cqw; overflow: hidden; }
.sq.lt { background: var(--board-lt); }
.sq.dk { background: var(--board-dk); }
.pc {
  font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", "Noto Sans Symbols 2", serif;
  font-variant-emoji: text;
}
.pc.w { color: #fff; text-shadow: -1.5px 0 #111, 1.5px 0 #111, 0 -1.5px #111, 0 1.5px #111, 2px 3px 0 rgba(0, 0, 0, 0.35); }
.pc.b { color: #15151a; text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35); }
figcaption { margin-top: 14px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); }

/* ---------- Footer ---------- */
.footer {
  background: #3b3b42;
  background-image:
    linear-gradient(90deg, rgba(0,0,0,.25) 0 2px, transparent 2px),
    linear-gradient(rgba(0,0,0,.25) 0 2px, transparent 2px);
  background-size: 48px 48px, 48px 24px;
  border-top: 4px solid #111;
  color: #e6e6ee;
}
.footer .muted { color: #c2c2cc; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-top: 18px;
  padding-bottom: 18px;
}
.footer p { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 50;
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  background: #212121;
  color: #fff;
  border: 3px solid #000;
  box-shadow: inset 3px 3px 0 #5a5a5a, inset -3px -3px 0 #111;
  translate: 0 -160%;
  transition: translate 0.35s steps(6);
  pointer-events: none;
}
.toast.show { translate: 0 0; }
.toast-title { font-size: 9px; color: var(--xp-1); margin-bottom: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .home-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 21px; }
  .hotbar { grid-template-columns: repeat(3, 1fr); }
  .header-inner { flex-direction: column; padding-top: 28px; }
  .orb { top: 16px; width: 36px; height: 36px; }
  .panel { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .view-head .h { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud { animation: none; translate: 30vw 0; }
  .view { animation: none; }
  .toast, .xp > span { transition: none; }
}
