:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color-scheme: light;
  --page: #f7f7f1;
  --panel: #fffefa;
  --ink: #192d24;
  --subtle: #4f6359;
  --line: #d6dfd4;
  --accent: #246449;
  --on-accent: #fff;
  --play-bg: #e4efe2;
  --chill: #e0efde;
  --sort: #f7e9ce;
  --match: #f1e4ec;
  --puzzle: #e1ebf4;
  --chill-ink: #315c3b;
  --sort-ink: #76501d;
  --match-ink: #764b65;
  --puzzle-ink: #335876;
  background: var(--page);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
.library {
  --library-edge: 14px;
  --library-top: 12px;
  max-width: 1050px;
  margin-inline: auto;
  padding: var(--library-top) var(--library-edge) 24px;
  padding: max(var(--library-top), env(safe-area-inset-top))
    max(var(--library-edge), env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(var(--library-edge), env(safe-area-inset-left));
}
.library-header, .brand, .locale, .search, .heading, .heading-text { display: flex; align-items: center; }
.library-header, .heading { justify-content: space-between; gap: 8px; }
.library-header { min-height: 44px; }
.brand { min-width: 0; gap: 9px; }
h1 { margin: 0; font-size: clamp(20px, 5.5vw, 32px); line-height: 1.1; font-weight: 800; overflow-wrap: anywhere; }
.logo {
  display: grid;
  direction: ltr;
  grid-template-columns: 7px 7px;
  place-content: center;
  gap: 3px;
  width: 33px;
  height: 33px;
  border-radius: 10px;
  background: #234838;
  flex: none;
}
.logo i { width: 7px; height: 7px; background: #e2aa71; border-radius: 2px; }
.logo i:nth-child(2) { background: #b5dfc4; border-radius: 50%; }
.logo i:nth-child(3) { background: #b6d6ed; }
.logo i:nth-child(4) { background: #edbfce; transform: rotate(15deg); }
button, input, select, summary { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.game-card { min-width: 0; }
button:active { outline: 2px solid var(--accent); outline-offset: -2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.locale {
  position: relative;
  gap: 6px;
  flex: none;
  min-height: 46px;
  padding-inline: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 650;
}
.locale:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.globe, .chevron { display: inline-block; flex: none; }
.globe { width: 12px; height: 12px; border: 1px solid currentColor; border-radius: 50%; }
.globe::after { content: ""; display: block; width: 4px; height: 10px; margin: 0 auto; border: solid currentColor; border-width: 0 1px; border-radius: 50%; }
.chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.search {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  margin: 10px 0 11px;
  gap: 12px;
  padding-inline: 13px 0;
}
.lens { position: relative; display: block; flex: none; width: 14px; height: 14px; border: 1.6px solid var(--subtle); border-radius: 50%; }
.lens::after { position: absolute; content: ""; width: 5px; height: 1.5px; background: var(--subtle); inset-inline-end: -4px; inset-block-end: -2px; transform: rotate(45deg); }
[dir="rtl"] .lens::after { transform: rotate(-45deg); }
.search input { width: 100%; min-width: 0; padding: 10px 0; padding-inline-end: 12px; background: transparent; border: 0; font-size: 16px; }
.search input::placeholder { color: var(--subtle); opacity: 1; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#clear-search {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  color: var(--subtle);
  background: transparent;
}
#clear-search::before, #clear-search::after {
  content: "";
  position: absolute;
  left: calc(50% - 6px);
  top: calc(50% - 1px);
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}
#clear-search::after { transform: rotate(-45deg); }
#shortcuts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.shortcut {
  min-width: 44px;
  min-height: 57px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 5px 2px;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.shortcut[data-key="all"] { background: #e7ece6; color: var(--accent); }
.shortcut[data-key="chill"] { background: var(--chill); color: var(--chill-ink); }
.shortcut[data-key="sort"] { background: var(--sort); color: var(--sort-ink); }
.shortcut[data-key="match"] { background: var(--match); color: var(--match-ink); }
.shortcut[data-key="puzzle"] { background: var(--puzzle); color: var(--puzzle-ink); }
.shortcut[aria-pressed="true"] { border: 2px solid currentColor; padding: 4px 1px; }
.symbol { position: relative; width: 19px; height: 19px; display: grid; place-items: center; }
.symbol::before, .symbol::after { content: ""; position: absolute; }
[data-key="all"] .symbol::before {
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 8px 0 currentColor, 0 8px currentColor, 8px 8px currentColor;
  transform: translate(-4px, -4px);
}
[data-key="chill"] .symbol::before { width: 13px; height: 15px; border: 1.6px solid; border-radius: 94% 12% 89% 16%; transform: rotate(12deg); }
[data-key="chill"] .symbol::after { width: 10px; height: 1.4px; background: currentColor; transform: rotate(-50deg); }
[data-key="sort"] .symbol::before { width: 16px; height: 2px; border-radius: 6px; background: currentColor; box-shadow: 0 5px 0 currentColor, 0 -5px 0 currentColor; }
[data-key="match"] .symbol::before, [data-key="match"] .symbol::after { width: 7px; height: 7px; border: 1.6px solid; border-radius: 2px; transform: rotate(45deg); }
[data-key="match"] .symbol::before { inset-inline-start: 1px; }
[data-key="match"] .symbol::after { inset-inline-end: 1px; }
[data-key="puzzle"] .symbol::before { width: 12px; height: 11px; border: 1.6px solid; border-radius: 3px; transform: translateY(2px); }
[data-key="puzzle"] .symbol::after { width: 4px; height: 5px; border: solid; border-width: 1.6px 1.6px 0; border-radius: 5px 5px 0 0; top: 0; background: var(--puzzle); }
@media (min-width: 320px) and (max-width: 400px) {
  #shortcuts { grid-template-columns: repeat(5, minmax(max-content, 1fr)); }
}
@media (max-width: 360px) {
  #shortcuts { gap: 4px; }
  .shortcut { font-size: 11px; }
}
.heading { margin: 5px 0 2px; }
.heading-text { gap: 7px; flex-wrap: wrap; min-width: 0; }
h2 { font-size: 18px; line-height: 1.25; margin: 0; }
#count { color: var(--subtle); font-size: 12px; white-space: nowrap; }
details { position: relative; flex: none; }
summary {
  min-height: 44px;
  display: flex;
  gap: 7px;
  align-items: center;
  padding-inline: 8px 3px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
}
summary::-webkit-details-marker { display: none; }
#categories {
  position: absolute;
  z-index: 1;
  inset-block-start: 100%;
  inset-inline-end: 0;
  min-width: 180px;
  max-height: 57vh;
  max-height: min(57vh, var(--category-room, 57vh));
  max-height: min(57dvh, var(--category-room, 57dvh));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 8px 20px #101a2320;
}
#filters[data-placement="above"] #categories {
  inset-block-start: auto;
  inset-block-end: 100%;
}
#categories button {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: start;
  border: 0;
  border-radius: 6px;
  padding-inline: 10px;
  background: transparent;
  font-size: 14px;
}
#categories button[aria-pressed="true"] { background: var(--play-bg); font-weight: 750; }
#games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.play {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  align-items: center;
  position: relative;
  text-align: start;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  padding: 4px;
}
.cover { position: relative; display: block; overflow: hidden; height: 0; padding-top: 56.25%; direction: ltr; border-radius: 9px; background: var(--play-bg); }
.cover img { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover[data-tile] img { width: 204%; height: 204%; }
.cover[data-tile="0"] img { left: -1%; top: -1%; }
.cover[data-tile="1"] img { left: -103%; top: -1%; }
.cover[data-tile="2"] img { left: -1%; top: -103%; }
.cover[data-tile="3"] img { left: -103%; top: -103%; }
.caption {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  min-height: 50px;
  padding-inline: 5px 3px;
}
.caption b { display: block; font-size: 14px; line-height: 1.2; overflow-wrap: anywhere; }
.caption > span:first-child { min-width: 0; }
.genre { display: block; overflow-wrap: anywhere; margin-top: 4px; color: var(--subtle); font-size: 11px; line-height: 1.2; }
.action {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  color: var(--accent);
  background: var(--play-bg);
}
.action::before { content: ""; width: 0; height: 0; border: solid transparent; border-width: 5px 0 5px 8px; border-left-color: currentColor; margin-left: 2px; }
.pin { display: block; margin-top: 3px; color: var(--accent); font-size: 11px; font-weight: 700; }
.game-card[data-pinned] .play { border-color: var(--accent); }
@media (min-width: 640px) {
  .library { --library-edge: 22px; --library-top: 20px; }
  #shortcuts { gap: 10px; }
  .shortcut { min-height: 64px; font-size: 13px; }
  #games { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
  .caption { min-height: 55px; padding-inline: 8px; }
  .caption b { font-size: 16px; }
  .genre { font-size: 12px; }
}
@media (min-width: 860px) { #games { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#empty { padding: 24px 0; text-align: center; color: var(--subtle); }

#empty .secondary {
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
}
.secondary {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 14px;
}
body.preparing { overflow: hidden; }
#launch-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 24px;
  padding: max(16px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  background: rgba(14, 25, 21, .56);
}
.launch-dialog {
  width: 100%;
  max-width: 340px;
  margin: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(14, 25, 21, .24);
}
.launch-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .94fr);
  align-items: center;
  gap: 12px;
}
#launch-cover { display: block; min-width: 0; }
#launch-cover .cover { border-radius: 9px; }
#launch-title { font-size: 19px; font-weight: 750; overflow-wrap: anywhere; }
.launch-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  margin: 10px 0 6px;
}
#launch-status {
  min-width: 0;
  margin: 0;
  color: var(--subtle);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#launch-percent {
  flex: none;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
#launch-progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: var(--accent);
  background: #cad5cb;
}
#launch-progress::-webkit-progress-bar { background: #cad5cb; }
#launch-progress::-webkit-progress-value { border-radius: 999px; background: var(--accent); }
#launch-progress::-moz-progress-bar { border-radius: 999px; background: var(--accent); }
.launch-actions { display: grid; margin-top: 18px; }
.launch-actions .secondary {
  min-width: 0;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
  overflow-wrap: anywhere;
}
@media (forced-colors: active) {
  #launch-progress { -webkit-appearance: auto; appearance: auto; }
}
body.playing { overflow: hidden; background: #09131e; }
#player {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: var(--player-height, 100%);
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  color-scheme: dark;
  color: #f5f6f8;
  background: #09131e;
  --accent: #83efbd;
}
.player-bar {
  display: flex;
  align-items: center;
  flex: none;
  gap: 8px;
  padding: 5px 10px;
  padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
}
[dir="rtl"] .player-bar {
  padding-inline: max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-left));
}
.player-bar .secondary {
  min-width: 44px;
  flex: 0 1 auto;
  padding-inline: 9px;
  color: #f5f6f8;
  background: #182430;
  border: 1px solid #536373;
  border-radius: 10px;
}
#playing-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #b1bac5;
  font-size: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-left: env(safe-area-inset-left);
  margin-right: env(safe-area-inset-right);
}
#stage iframe { display: block; width: 100%; height: 100%; border: 0; background: #09131e; }
#opening {
  position: absolute;
  z-index: 1;
  inset: 25% 20px auto;
  padding: 12px;
  border-radius: 9px;
  background: #182430;
  text-align: center;
  pointer-events: none;
}
@media (hover: hover) {
  .play:hover { border-color: var(--accent); }
  #categories button:hover { background: var(--play-bg); }
}

/* Email registration */
#registration { width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--ink); box-shadow: 0 24px 90px #142b2440; }
#registration::backdrop { background: #142b24a6; backdrop-filter: blur(5px); }
.registration-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; color: var(--subtle); font-size: 12px; font-weight: 750; letter-spacing: .14em; }
.registration-brand .logo { width: 30px; height: 30px; border-radius: 9px; }
#registration h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.25; letter-spacing: -.035em; font-weight: 750; }
#registration p { color: var(--subtle); line-height: 1.6; font-size: 16px; }
#registration label { display: block; margin: 18px 0 8px; font-size: 14px; font-weight: 650; }
#registration input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 16px; }
#registration input:focus-visible, #registration button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
#registration button { min-height: 44px; border-radius: 12px; padding: 10px 14px; }
#registration-submit { display: block; width: 100%; background: var(--accent); color: white; border: 0; font-weight: 650; }
#registration-cancel { width: 100%; margin-top: 10px; }
#registration-resend, #registration-change { margin-top: 12px; font-size: 14px; }
#registration button:disabled { cursor: wait; opacity: .55; }
#registration-status { margin: 12px 0; overflow-wrap: anywhere; }
#registration-status:empty { height: 8px; margin: 0; }
#registration-status[data-error="true"] { color: #a52e25; }
#registration .registration-note { font-size: 13px; margin-bottom: 0; }
body.registering { overflow: hidden; }

#registration-description { margin: 0 0 22px; }
#registration #registration-cancel { background: transparent; border-color: transparent; color: var(--subtle); }
#registration .registration-note { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
@media (max-width: 420px) { #registration { padding: 24px; } }
