/* Jeufy handheld launcher. Colours match /styles.css. */
:root {
  --ink: #0a0a10;
  --ink-2: #13131d;
  --line: #24243a;
  --text: #f2f0ea;
  --muted: #9a98a8;
  --coral: #ff6a3d;
  --lime: #c8ff45;
  --sky: #5ad1ff;
  --radius: 18px;
  /* Hardware insets (notch, rounded corners, overscan); content keeps 8px clear of any inset. Kept in custom properties so they can be overridden and tested. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --pad-t: max(14px, calc(var(--safe-t) + 8px));
  --pad-r: max(18px, calc(var(--safe-r) + 8px));
  --pad-b: max(12px, calc(var(--safe-b) + 8px));
  --pad-l: max(18px, calc(var(--safe-l) + 8px));
  /* Room around the tile grid for the focus ring (4px + 4px offset) and the 1.02 focus scale. */
  --room: 14px;
  --gap: clamp(12px, 2vw, 26px);
  /* Tallest a tile may get, as height / width. Keeps 16:9 and 16:10 tiles from turning into thin strips. */
  --tile-ratio: 1.5; /* 6 games: 3 x 2 on 16:9, 16:10 and ~4:3 */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--ink); }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse at 15% 0%, rgba(255,106,61,.12), rgba(10,10,16,0) 55%), var(--ink);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
.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; }

.shell {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 2vh, 22px);
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
}

/* header */
.top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.wordmark { font-weight: 900; font-size: clamp(24px, 3.2vh, 34px); letter-spacing: -0.04em; text-decoration: none; }
.wordmark span { color: var(--coral); }
.mode-pill {
  font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: var(--lime); padding: 5px 11px; border-radius: 999px;
}
.status { flex: 1 1 320px; color: var(--muted); font-size: clamp(14px, 1.9vh, 17px); text-align: right; }

/* tiles */
main { min-height: 0; container-type: size; }
.tiles {
  list-style: none; height: 100%;
  display: grid; gap: var(--gap);
  padding: var(--room);
  /* 16:9 and 16:10 (one row of --cols): each column is as wide as the row allows, but never so narrow that the tile
     would exceed --tile-ratio for the available height. Leftover space is split evenly around the row. */
  --cols: 3;
  grid-template-columns: repeat(var(--cols), min(calc((100cqw - 2 * var(--room) - (var(--cols) - 1) * var(--gap)) / var(--cols)), calc((100cqh - 2 * var(--room)) / var(--tile-ratio))));
  --rows: 2;
  grid-template-rows: repeat(var(--rows), min(calc((100cqh - 2 * var(--room) - (var(--rows) - 1) * var(--gap)) / var(--rows)), calc((100cqw - 2 * var(--room) - (var(--cols) - 1) * var(--gap)) / var(--cols) * var(--tile-ratio))));
  justify-content: center; align-content: center;
}
.tiles > li { min-height: 0; display: flex; }
.tile {
  position: relative; flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tile .art { position: relative; flex: 1 1 auto; min-height: 90px; overflow: hidden; background: #000; }
.tile .art picture { display: block; width: 100%; height: 100%; }
.tile .art img { width: 100%; height: 100%; object-fit: cover; }
.tile .art img.tall { object-position: 50% 35%; }
.tile .meta { display: flex; flex-direction: column; gap: 6px; padding: clamp(12px, 1.8vh, 20px) clamp(12px, 1.4vw, 20px); }
.t-title { font-weight: 900; font-size: clamp(20px, 3vh, 32px); letter-spacing: -0.02em; line-height: 1.1; }
.t-hook { color: var(--muted); font-size: clamp(14px, 1.9vh, 18px); }
.t-flag { color: var(--coral); font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.badge {
  align-self: flex-start; margin-top: 4px;
  font-size: clamp(13px, 1.6vh, 15px); font-weight: 700; line-height: 1.3;
  padding: 5px 10px; border-radius: 10px;
  color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--line);
}
.badge.ready { color: var(--ink); background: var(--lime); border-color: var(--lime); }

.tile:hover { border-color: #3a3a58; }
.tile:focus { outline: none; }
.tile:focus-visible,
html:not([data-input="pointer"]) .tile:focus {
  outline: 4px solid var(--lime); outline-offset: 4px;
  border-color: var(--lime);
  box-shadow: 0 0 0 1px var(--lime), 0 18px 50px rgba(200,255,69,.18);
  transform: translateY(-3px) scale(1.02);
}
a:focus-visible, button:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; border-radius: 8px; }
.tile:focus-visible { border-radius: var(--radius); }

/* bottom bar */
.bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(19,19,29,.9); border: 1px solid var(--line);
  font-size: clamp(14px, 1.9vh, 17px);
}
.pad-state { color: var(--muted); flex: 1 1 220px; }
.hints { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.hint { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.fs-btn {
  font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
}
.fs-btn:hover { border-color: var(--muted); }

/* glyphs: drawn with CSS and text, no image files */
.g {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 1.75em; height: 1.75em; border-radius: 50%;
  font-size: .9em; font-weight: 900; line-height: 1; color: var(--ink);
}
.g-xa { background: #6cc24a; }
.g-xb { background: #e5484d; color: #fff; }
.g-menu { background: #3a3a50; color: var(--text); font-size: .8em; }
.g-ps { background: #23232f; border: 1px solid #3a3a50; }
.g-cross::before, .g-cross::after {
  content: ""; position: absolute; width: 58%; height: 2.5px; border-radius: 2px; background: #7aa7ff;
  transform: rotate(45deg);
}
.g-cross::after { transform: rotate(-45deg); }
.g-circle::before {
  content: ""; width: 46%; height: 46%; border-radius: 50%; border: 2.5px solid #ff6b81;
}
.g-options::before {
  content: ""; width: 44%; height: 10px;
  background: linear-gradient(var(--text), var(--text)) 0 0 / 100% 2px no-repeat,
              linear-gradient(var(--text), var(--text)) 0 50% / 100% 2px no-repeat,
              linear-gradient(var(--text), var(--text)) 0 100% / 100% 2px no-repeat;
}
/* Nintendo layout: a face-button diamond with the pressed position lit, plus its printed letter */
.g-pos { width: 1.75em; height: 1.75em; border-radius: 0; background: none; }
.g-pos i { position: absolute; width: 34%; height: 34%; border-radius: 50%; background: #3a3a50; }
.g-pos i:nth-child(1) { top: 0; left: 33%; }
.g-pos i:nth-child(2) { top: 33%; right: 0; }
.g-pos i:nth-child(3) { bottom: 0; left: 33%; }
.g-pos i:nth-child(4) { top: 33%; left: 0; }
.g-pos i.on { background: var(--lime); }
.g-plus { background: #3a3a50; color: var(--text); font-size: 1em; }
kbd {
  display: inline-block; min-width: 1.9em; padding: 3px 8px; border-radius: 7px;
  font: 800 .82em/1.2 ui-monospace, "SF Mono", Menlo, monospace; text-align: center;
  color: var(--ink); background: var(--text); box-shadow: 0 2px 0 #8d8b99;
}
.dpad { position: relative; display: inline-block; width: 1.5em; height: 1.5em; }
.dpad::before, .dpad::after { content: ""; position: absolute; background: var(--text); border-radius: 2px; }
.dpad::before { left: 34%; top: 0; width: 32%; height: 100%; }
.dpad::after { top: 34%; left: 0; height: 32%; width: 100%; }
.note { color: var(--muted); font-weight: 500; font-size: .9em; white-space: normal; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--pad-b) + 70px); transform: translateX(-50%);
  background: var(--ink-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 10;
}

/* ~4:3 and squarer: 2 by 2 grid, art beside text */
@media (max-aspect-ratio: 14/10) and (min-width: 700px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    justify-content: stretch; align-content: stretch;
  }
}

/* phones and narrow windows: one column, page scrolls */
@media (max-width: 699px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100dvh; }
  .status { text-align: left; flex-basis: 100%; }
  main { container-type: normal; }
  .tiles { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; height: auto; }
  .tile .art { flex: none; aspect-ratio: 16 / 9; }
  .tile .art img.tall { object-position: 50% 72%; }
  .bar { background: var(--ink-2); }
  .fs-btn { display: none; }
}

/* short landscape screens (phones on their side) */
@media (max-height: 520px) and (min-width: 700px) {
  .status { display: none; }
  .tile .meta { padding: 8px 12px; gap: 3px; }
  .t-hook { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile:focus-visible, html:not([data-input="pointer"]) .tile:focus { transform: none; }
}
