/* ─────────────────────────────────────────────────────────────
   lieber.games: cartridges on a shelf, and a console to play them in
   ───────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  src: url(fonts/inter-latin-wght-normal.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #eeece6;
  --ink: #1a1916;
  --muted: #5b574f;
  --faint: #8a857a;
  --rule: #d9d5cb;
  --console: #d9d4c7;
  --console-ink: #5b5953;
  --dark: #26252b;
  --cw: 168px;  /* cartridge width  */
  --ch: 190px;  /* cartridge height */
  --ck: 1;      /* cartridge scale  */
  --gap: 26px;
  --cons: 1;    /* console scale    */
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 60% 55% at 50% 0%, rgba(255,255,255,.75), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 400 16px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── header / footer ─────────────────────────── */
.top, .foot {
  width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.top { border-bottom: 1px solid var(--rule); }
.logo { font-size: 18px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.x { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--ink); }
.x:hover, .logo:hover { color: #6a665e; }
.foot { padding-top: 0; padding-bottom: 32px; font-size: 13px; color: var(--faint); flex-wrap: wrap; }

/* ── the room: shelves + desk ─────────────────────────── */
.room {
  flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 64px 40px 72px;
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: center; gap: 48px;
}
.shelves-wrap { min-width: 0; align-self: center; }
.shelves { display: flex; flex-direction: column; gap: 56px; }
.desk { display: flex; flex-direction: column; align-items: center; gap: 18px; position: sticky; top: 24px; align-self: start; padding-top: 8px; }
.hint { margin: 0; min-height: 22px; font-size: 14px; color: var(--muted); text-align: center; max-width: 320px; }

/* one shelf level */
.shelf .row { display: flex; align-items: flex-end; gap: var(--gap); padding: 0 14px; min-height: calc(var(--ch) + 18px); }
.plank {
  height: 16px; border-radius: 2px;
  background-color: #c9a77c;
  background-image:
    repeating-linear-gradient(90deg, rgba(110,72,36,.10) 0 1px, transparent 1px 29px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 5px),
    linear-gradient(#d8b98e, #b48d5b);
  box-shadow: 0 2px 0 #8d6a3f, 0 18px 24px -6px rgba(40,34,20,.35);
}

/* ── cartridge ─────────────────────────── */
.slot-holder { position: relative; flex: none; width: var(--cw); height: var(--ch); }
.cart {
  position: absolute; left: 0; top: 0; width: 168px; height: 190px; padding: 0; border: 0; background: none; cursor: pointer;
  transform-origin: 0 0; transform: scale(var(--ck));
}
.cart .lift {
  position: absolute; inset: 0; display: block;
  transition: transform .3s cubic-bezier(.3,1.5,.5,1), filter .25s;
  filter: drop-shadow(0 10px 10px rgba(40,34,20,.18));
}
.cart:hover .lift, .cart:focus-visible .lift { transform: translateY(-14px); filter: drop-shadow(0 22px 16px rgba(40,34,20,.22)); }
.cart:focus-visible { outline: none; }
.cart:focus-visible .lift::after { content: ''; position: absolute; inset: -7px; border: 2px solid var(--ink); border-radius: 12px; }
.cart.leaving .lift { transform: translateY(-60px); opacity: 0; transition: transform .28s ease-in, opacity .28s ease-in; }
.cart.nudge .lift { animation: nudge 1.4s ease-in-out 2; }
@keyframes nudge { 0%, 40%, 100% { transform: none; } 15% { transform: translateY(-12px); } 28% { transform: translateY(-4px); } }
.cart.arrive .lift { animation: arrive .45s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes arrive { from { transform: translateY(-50px); opacity: 0; } to { transform: none; opacity: 1; } }
.cart svg.shell { position: absolute; left: 0; top: 0; width: 168px; height: 190px; overflow: visible; }
.label {
  position: absolute; left: 19px; top: 40px; width: 130px; height: 125px; border-radius: 5px; overflow: hidden;
  display: flex; text-align: left; box-shadow: 0 1px 0 rgba(255,255,255,.25), inset 0 0 0 1px rgba(0,0,0,.25);
}
.label .band { width: 15px; flex: none; display: flex; align-items: center; justify-content: center; }
.label .band span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 6.5px; font-weight: 700; letter-spacing: .16em; color: #fff; }
.label .face { flex: 1; min-width: 0; padding: 5px 6px 6px; display: flex; flex-direction: column; gap: 3px; }
.label .copy { font-size: 5.5px; font-weight: 600; letter-spacing: .04em; }
.label img { display: block; width: 103px; height: 56px; }
.label .t { font-size: 12.5px; line-height: 1; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .t.long { font-size: 11px; }
.label .s { font-size: 7px; line-height: 1.15; font-weight: 500; }
.label .chip { margin-top: auto; align-self: flex-start; padding: 1px 5px; border-radius: 3px; font-size: 6px; font-weight: 700; letter-spacing: .08em; line-height: 1.6; }

.ghost {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 1.5px dashed #b4afa3; border-radius: 10px;
  background: rgba(255,255,255,.35); color: #7d786d; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px;
  font: 600 11px/1.3 'Inter', sans-serif; letter-spacing: .06em; text-align: center;
  transition: border-color .2s, color .2s;
  animation: fadein .3s ease both;
}
.ghost:hover { border-color: var(--ink); color: var(--ink); }
.ghost small { font-weight: 500; font-size: 10px; letter-spacing: .02em; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ── console ─────────────────────────── */
.console-wrap { width: calc(320px * var(--cons)); height: calc(520px * var(--cons)); }
.console { position: relative; width: 320px; height: 520px; transform: scale(var(--cons)); transform-origin: 0 0; }
.slot-cart {
  position: absolute; left: 72px; top: 0; width: 176px; height: 72px; border-radius: 10px 10px 0 0;
  background: var(--cart, #999); box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 0 0 1.5px var(--cart-dark, #666);
  visibility: hidden;
}
.console[data-phase]:not([data-phase="idle"]) .slot-cart { visibility: visible; }
.slot-cart.slotin { animation: slotin .7s cubic-bezier(.3,1.25,.5,1) both; }
@keyframes slotin { from { transform: translateY(-110px); } to { transform: none; } }
.slot-cart .pill { position: absolute; left: 36px; top: 10px; width: 104px; height: 19px; border-radius: 10px; box-shadow: inset 0 0 0 1.4px var(--cart-dark); display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; letter-spacing: 1px; color: var(--cart-dark); }
.slot-cart .grip { position: absolute; top: 36px; width: 10px; height: 2px; background: var(--cart-dark); box-shadow: 0 6px 0 var(--cart-dark), 0 12px 0 var(--cart-dark); }
.slot-cart .grip.l { left: 8px; } .slot-cart .grip.r { right: 8px; }

.body {
  position: absolute; left: 0; top: 40px; width: 320px; height: 480px; border-radius: 30px 30px 40px 40px; background: var(--console);
  box-shadow: inset 0 -9px 0 rgba(0,0,0,.14), inset 0 3px 0 rgba(255,255,255,.45), inset 0 0 0 1px rgba(0,0,0,.08), 0 30px 50px rgba(40,34,20,.28), 0 6px 14px rgba(40,34,20,.18);
}
.slot { position: absolute; left: 60px; top: -3px; width: 200px; height: 12px; border-radius: 6px; background: rgba(0,0,0,.32); }
.bezel { position: absolute; left: 24px; top: 30px; width: 272px; height: 238px; border-radius: 14px 14px 30px 14px; background: var(--dark); box-shadow: inset 0 2px 6px rgba(0,0,0,.6); }
.led { position: absolute; left: 12px; top: 112px; width: 7px; height: 7px; border-radius: 50%; background: #3a3940; transition: background .3s, box-shadow .3s; }
.console:not([data-phase="idle"]) .led { background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }
.screen {
  position: absolute; left: 26px; top: 22px; width: 220px; height: 194px; border-radius: 4px; overflow: hidden;
  background-color: #1e2026; box-shadow: inset 0 0 0 2px rgba(0,0,0,.35); transition: background-color .4s;
}
.console[data-phase="inserting"] .screen { background-color: #0d0f12; }
.console[data-phase="booting"] .screen { background-color: #dfe9c3; }
.console[data-phase="title"] .screen { background-color: var(--scr-bg); }
.scr { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; text-align: center; }
.console[data-phase="idle"] .scr-idle,
.console[data-phase="booting"] .scr-boot,
.console[data-phase="title"] .scr-title { display: flex; }
.scr-idle { color: #9aa3b2; gap: 12px; font-size: 12px; font-weight: 700; letter-spacing: .16em; line-height: 1.5; }
.scr-boot { color: #2f3b26; }
.boot-logo { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: boot 1.3s cubic-bezier(.2,.8,.3,1) both; }
.boot-logo .name { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.boot-logo .c { font-size: 8px; font-weight: 700; letter-spacing: .24em; }
.sparkle { margin-top: 4px; animation: twinkle 1.4s ease-in-out infinite; }
@keyframes boot { from { transform: translateY(-90px); } to { transform: none; } }
@keyframes twinkle { 50% { opacity: .2; } }
.scr-title { animation: pop .45s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
.title-art { width: 120px; height: 65px; }
.title-name { font-size: 18px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; color: var(--scr-ink); }
.title-status { font-size: 10px; line-height: 1.35; font-weight: 500; color: var(--scr-sub); }
.title-prompt { margin-top: 4px; font-size: 10px; font-weight: 700; letter-spacing: .18em; color: var(--scr-ink); }
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.dpad { position: absolute; left: 34px; top: 318px; width: 88px; height: 88px; }
.dpad i { position: absolute; border-radius: 6px; background: var(--dark); box-shadow: inset 0 -3px 0 rgba(0,0,0,.4); }
.dpad .v { left: 30px; top: 0; width: 28px; height: 88px; }
.dpad .h { left: 0; top: 30px; width: 88px; height: 28px; }
.dpad .c { left: 37px; top: 37px; width: 14px; height: 14px; border-radius: 50%; background: #393842; box-shadow: none; }
.ab { position: absolute; left: 192px; top: 300px; width: 112px; height: 80px; transform: rotate(-24deg); }
.btn-round { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: var(--dark); box-shadow: inset 0 -4px 0 rgba(0,0,0,.35); }
.btn-round.b { left: 0; top: 20px; }
.btn-round.a { left: 60px; top: 0; }
.lbl { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--console-ink); }
.ab .lbl { position: absolute; letter-spacing: 0; }
.ab .lb { left: 18px; top: 70px; } .ab .la { left: 79px; top: 50px; }
.pills { position: absolute; left: 70px; top: 412px; display: flex; gap: 26px; }
.pill-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pill-btn { display: block; width: 62px; height: 20px; border-radius: 10px; background: var(--dark); box-shadow: inset 0 -3px 0 rgba(0,0,0,.4); transform: rotate(-24deg); }
.speaker { position: absolute; right: 24px; bottom: 24px; display: flex; gap: 6px; transform: rotate(-24deg); }
.speaker i { width: 5px; height: 36px; border-radius: 3px; background: rgba(0,0,0,.22); }

/* playable: START and A light up and press */
.play { pointer-events: none; transition: transform .08s, box-shadow .2s; }
.console.can-play .play { pointer-events: auto; cursor: pointer; }
.console.can-play .pill-btn.start { box-shadow: inset 0 -3px 0 rgba(0,0,0,.4), 0 0 0 3px rgba(61,220,132,.6); animation: ready 1.8s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: inset 0 -3px 0 rgba(0,0,0,.4), 0 0 0 5px rgba(61,220,132,.3); } }
.console.can-play .play:active { transform: rotate(-24deg) translateY(2px); }
.console.can-play .btn-round.a:active { transform: translateY(2px); }

/* ── responsive ─────────────────────────── */
@media (max-width: 1000px) {
  .room { grid-template-columns: minmax(0, 1fr); gap: 36px; padding: 36px 24px 56px; }
  .desk { position: static; order: -1; padding-top: 0; }
  .top, .foot { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 560px) {
  :root { --cw: 131px; --ch: 148px; --ck: .78; --gap: 18px; --cons: .78; }
  .room { padding: 28px 16px 48px; gap: 28px; }
  .shelves { gap: 44px; }
  .shelf .row { padding: 0 6px; justify-content: center; }
  .top, .foot { padding-left: 18px; padding-right: 18px; }
  .top { padding-top: 14px; padding-bottom: 12px; }
}
@media (max-width: 360px) {
  :root { --cons: .7; --gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
