@import url('../fonts/fonts.css');

/* Paper and graphite: a warm paper-beige page, graphite grays, no accent
   colour. The only colour on screen is the emulated panel itself. */
:root {
  --paper: #e7e2d6;
  --paper-deep: #ddd7c8;
  --card: #f5f2ea;
  --ink: #17181a;
  --ink-soft: #6c6a62;
  --rule: #cfc9ba;
  --rule-strong: #b6ae9c;
  --graphite: #33363a;
  --graphite-soft: #4a4d52;
  --graphite-light: #6f7278;
  --bezel: #1e2022;
  --shell: #d4cec0;
  --radius: 10px;

  --font-text: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* Small uppercase labels: buttons, tags, keys. */
.label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wrap { width: min(1080px, 100% - 48px); margin: 0 auto; }

/* ---------- Library ---------- */

.masthead { padding: 76px 0 44px; text-align: center; }

.wordmark {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}

.rule {
  width: 52px;
  height: 2px;
  background: var(--rule-strong);
  margin: 20px auto 22px;
}

.tagline { color: var(--ink-soft); margin: 0 auto; max-width: 48ch; font-size: 15px; }

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 24px;
  padding-bottom: 60px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.card:hover, .card:focus-within {
  transform: translateY(-3px);
  border-color: var(--rule-strong);
  box-shadow: 0 12px 26px rgba(40, 36, 26, 0.16);
}

.card-main { display: flex; flex-direction: column; flex: 1; }
.card-main:focus-visible { outline: 2px solid var(--graphite); outline-offset: -2px; }

.card-art {
  aspect-ratio: 168 / 152;
  background: var(--bezel);
  display: block;
  width: 100%;
  object-fit: cover;
  border-bottom: 1px solid var(--rule);
}
.card-art--empty { display: grid; place-items: center; color: #767a72; }

.card-body { padding: 18px 20px 4px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.card-text { color: var(--ink-soft); font-size: 14.5px; margin: 0; flex: 1; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 18px;
}

.card-play {
  color: var(--card);
  background: var(--graphite);
  border-radius: 6px;
  padding: 9px 16px;
  transition: background 150ms ease;
}
.card:hover .card-play { background: var(--ink); }

.ext {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px;
  transition: color 150ms ease, border-color 150ms ease;
}
.ext:hover { color: var(--ink); border-color: var(--ink); }

.colophon {
  border-top: 1px solid var(--rule);
  padding: 30px 0 64px;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.colophon a { border-bottom: 1px solid var(--rule-strong); }
.colophon a:hover { color: var(--ink); }

/* ---------- Player ---------- */

.player {
  /* One column width shared by the screen surround and everything under it,
     so the controls line up with the screen edges. */
  --stage-width: min(652px, 92vw);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 20px 16px 56px;
}

.topbar {
  width: min(1080px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  padding: 9px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  transition: color 150ms ease, border-color 150ms ease;
}
.back svg { width: 9px; height: 9px; }
.back:hover { color: var(--ink); border-color: var(--rule-strong); }

.actions { display: flex; gap: 10px; }
.actions button {
  font: inherit;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 9px 15px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.actions button:hover { color: var(--ink); border-color: var(--rule-strong); }

/* The near-black surround stands in for the DMG's screen bezel. */
.screen-stage {
  position: relative;
  width: var(--stage-width);
  border-radius: 12px;
  background: var(--bezel);
  padding: 16px;
  box-shadow: 0 14px 34px rgba(40, 36, 26, 0.22);
}

#screen {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 168 / 152;
  border-radius: 4px;
  background: #000;
}

#nativeCanvas { display: none; }

.curtain {
  position: absolute;
  inset: 16px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bezel);
  color: #8e918c;
  text-align: center;
  padding: 24px;
}
.curtain[hidden] { display: none; }
#curtainTitle { font-size: 20px; font-weight: 600; color: #d7d2c4; letter-spacing: -0.01em; }
.curtain button {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: #ddd7c8;
  border: none;
  border-radius: 6px;
  padding: 14px 24px;
  cursor: pointer;
  transition: background 150ms ease;
}
.curtain button:hover { background: #f0ebdd; }

/* ---------- On-screen gamepad ---------- */

.gamepad {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  width: var(--stage-width);
  padding: 24px 26px 20px;
  background: var(--shell);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  touch-action: none;
}

.dpad { position: relative; width: 130px; height: 130px; }

/* Four overlapping arms rather than one clipped shape, so a held direction
   can light up on its own. */
.dpad-hit {
  position: absolute;
  background: linear-gradient(160deg, var(--graphite-soft), var(--graphite));
  box-shadow: 0 2px 3px rgba(30, 28, 22, 0.35);
  cursor: pointer;
}
.dpad-hit.up    { left: 33%; top: 0;    width: 34%; height: 67%; border-radius: 6px 6px 0 0; }
.dpad-hit.down  { left: 33%; bottom: 0; width: 34%; height: 67%; border-radius: 0 0 6px 6px; }
.dpad-hit.left  { top: 33%; left: 0;    height: 34%; width: 67%;  border-radius: 6px 0 0 6px; }
.dpad-hit.right { top: 33%; right: 0;   height: 34%; width: 67%;  border-radius: 0 6px 6px 0; }

/* Only the outer half lights up, so the highlight stops at the pivot instead
   of bleeding through the middle of the cross. */
.dpad-hit.active::after {
  content: '';
  position: absolute;
  background: var(--graphite-light);
  border-radius: inherit;
}
.dpad-hit.up.active::after    { left: 0; right: 0; top: 0; height: 50%; }
.dpad-hit.down.active::after  { left: 0; right: 0; bottom: 0; height: 50%; }
.dpad-hit.left.active::after  { top: 0; bottom: 0; left: 0; width: 50%; }
.dpad-hit.right.active::after { top: 0; bottom: 0; right: 0; width: 50%; }

.dpad-pivot {
  position: absolute;
  left: 50%; top: 50%;
  width: 30%; height: 30%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #52565c, #2b2e32 72%);
  pointer-events: none;
}

.face-buttons { display: flex; align-items: center; gap: 20px; transform: rotate(-16deg); }

.face-button { display: grid; justify-items: center; gap: 7px; }

.round {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--graphite-soft), #2c2f33);
  box-shadow: 0 3px 4px rgba(30, 28, 22, 0.35);
  cursor: pointer;
  user-select: none;
}
.round.active { background: linear-gradient(160deg, #7b7e84, var(--graphite-light)); transform: translateY(2px); }

/* Letters are printed on the shell, as on the console itself. */
/* The cluster is angled like the console's, but the printed letters stay
   upright so they are readable at this size. */
.face-button .label { font-size: 11px; color: #6b6558; transform: rotate(16deg); }

.pill-row { grid-column: 1 / -1; display: flex; justify-content: center; gap: 34px; padding-top: 8px; }

.pill-holder { display: grid; justify-items: center; gap: 7px; }

.pill {
  transform: rotate(-16deg);
  min-width: 84px;
  height: 17px;
  border-radius: 999px;
  background: linear-gradient(#7a7d83, #55585d);
  box-shadow: 0 2px 3px rgba(30, 28, 22, 0.3);
  cursor: pointer;
  user-select: none;
}
.pill.active { background: linear-gradient(#9a9da2, #74777c); }
.pill-holder .label { font-size: 10px; color: #6b6558; }

/* ---------- Keyboard help + game note ---------- */

.panel {
  width: var(--stage-width);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.panel > summary {
  cursor: pointer;
  padding: 14px 18px;
  color: var(--ink-soft);
  list-style: none;
  display: flex;
  align-items: center;
}
.panel > summary::-webkit-details-marker { display: none; }
.marker {
  display: inline-block;
  width: 0; height: 0;
  margin-right: 11px;
  border-left: 6px solid var(--rule-strong);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 160ms ease;
  transform-origin: 30% 50%;
}
.panel[open] .marker { transform: rotate(90deg); }

.keys-body { padding: 2px 18px 20px; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px 26px; }
.keys-grid div {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px dashed var(--rule); font-size: 14.5px;
}
.keys-grid span:first-child { color: var(--ink-soft); }

kbd {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  background: var(--paper-deep);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--ink);
}

.keys-note { color: var(--ink-soft); font-size: 13.5px; margin: 18px 0 0; }

.game-note {
  width: var(--stage-width);
  color: var(--ink-soft);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}
.game-note strong { color: var(--ink); font-weight: 600; }

@media (max-width: 620px) {
  .gamepad { gap: 12px; padding: 18px 14px 16px; }
  .dpad { width: 112px; height: 112px; }
  .round { width: 52px; height: 52px; }
  .wrap { width: calc(100% - 32px); }
}
