:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: #f2f2f7;
  background: #0e0e12;
  --panel: #17171e;
  --line: #2a2a35;
  --muted: #aaaab9;
  --accent: #a59bff;
  --ready: #78ddbc;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  position: relative;
  width: min(100%, 27.5rem);
  min-height: 100vh;
  margin: 0 auto;
  container-type: inline-size;
}
p, h1, h2 { margin: 0; }

.shell {
  width: calc(100% - 2rem);
  margin-inline: auto;
}

.home-link {
  position: absolute;
  z-index: 1;
  inset-block-start: 1rem;
  inset-inline-start: 1rem;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  color: #f2f2f7;
  font-size: 1.65rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  text-shadow: 0 1px 4px #000, 0 0 2px #000;
}

.home-link:hover { color: #ffde86; }

h1 {
  font-size: 2.25rem;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -.055em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.catalog {
  position: relative;
  isolation: isolate;
}

.catalog::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: url('/art/home-background.webp') center top / 100% auto no-repeat;
  content: "";
}

.game-list {
  display: grid;
  gap: clamp(.85rem, 3.65cqw, 1rem);
  padding: 51.4% max(.75rem, 3.5%) 2.5rem;
}

.game-category {
  min-width: 0;
  overflow: hidden;
  padding-top: .5rem;
  border: 1px solid #323232;
  border-radius: .9rem / .45rem;
  background: #292929;
}

.game-category h2 {
  margin-inline: clamp(.5rem, 2.5cqw, 1rem);
  font-family: Rockwell, "Bookman Old Style", Georgia, serif;
  font-size: clamp(1.1rem, 3.8cqw, 1.55rem);
  font-variant: small-caps;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: .025em;
}

.game-rail {
  --card-gap: clamp(.55rem, 2.35cqw, 1rem);
  --rail-pad: clamp(.6rem, 3cqw, 1.15rem);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 41%;
  gap: var(--card-gap);
  margin: 0;
  padding: .8rem var(--rail-pad) var(--rail-pad);
  overflow-x: auto;
  list-style: none;
  scroll-padding-inline: var(--rail-pad);
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}

.game-rail li { min-width: 0; scroll-snap-align: start; }

.game-card {
  display: flex;
  width: 100%;
  min-height: 4.7rem;
  aspect-ratio: 1.7;
  align-items: center;
  justify-content: center;
  padding: clamp(.57rem, 2cqw, 1.05rem);
  border: 1px solid #40404a;
  border-radius: .43rem;
  background: #17171e;
  color: #fff;
  font-size: .9rem;
  font-weight: 850;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  word-break: keep-all;
}

.game-placeholder { white-space: pre-line; letter-spacing: .08em; }
a.game-card { border-color: #c09244; background: #242015; color: #fff1b9; }
a.game-card:hover { background: #382b18; }
a.game-card:focus-visible { outline-offset: -4px; outline-color: #ffce55; }

.game-hero {
  display: flex;
  min-height: 12.75rem;
  flex-direction: column;
  justify-content: end;
  gap: .3rem;
  padding: 4.75rem 1rem 1.35rem;
  background:
    linear-gradient(0deg, #0e0e12, #0e0e121a 88%),
    url('/art/home-background.webp') center 37% / 100% auto no-repeat,
    #0e0e12;
  color: #fffbd9;
}

.game-genre {
  font-family: Rockwell, "Bookman Old Style", Georgia, serif;
  font-size: 1rem;
  font-variant: small-caps;
  font-weight: 900;
  letter-spacing: .05em;
}

.game-hero h1 { font-size: clamp(2.25rem, 10cqw, 2.75rem); }
.game-overview { padding-block: .5rem 2.5rem; }

.game-description-panel {
  padding: 1rem 1.1rem;
  border: 1px solid #dfdab3;
  border-radius: .65rem;
  background: #fffbd9;
  color: #292419;
}

.game-description-panel h2 { font-size: .85rem; font-weight: 850; }

.game-description {
  margin-top: .3rem;
  line-height: 1.7;
  word-break: keep-all;
}

.game-description-panel h2[hidden] + .game-description { margin-top: 0; }

.game-actions {
  display: grid;
  gap: .65rem;
  margin-top: 1.1rem;
}

.game-actions > .button { min-height: 3rem; font-size: .95rem; }
#join-form { margin-top: 1rem; }
#join-form label { display: block; margin-bottom: .35rem; font-size: .86rem; color: var(--muted); }

button, input { font: inherit; }

.button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 2.65rem;
  padding: .58rem .95rem;
  border: 1px solid transparent;
  border-radius: .32rem;
  font-size: .88rem;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.button > span { font-size: 1.05em; }
.button-primary { background: #ffce55; color: #211806; }
.button-primary:hover { background: #ffde86; }
.button-secondary { border-color: #494754; background: #292933; color: #f2f2f7; }
.button-secondary:hover { background: #393944; }
.button:disabled { opacity: .66; cursor: wait; }

.link-row { display: flex; gap: .45rem; }

input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  padding: .58rem .7rem;
  border: 1px solid #45454f;
  border-radius: .32rem;
  background: #101017;
  color: #f2f2f7;
  font-size: 1rem;
}

input::placeholder { color: #9696a7; }
input[aria-invalid="true"] { border-color: #f09ea7; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.feedback {
  margin-top: .65rem;
  color: var(--muted);
  font-size: .8rem;
  overflow-wrap: anywhere;
}

.feedback:empty { margin: 0; }
#join-status { color: #f2afb8; }

.room { padding-block: 4.75rem 2.5rem; }

.room-banner {
  display: flex;
  min-height: 11rem;
  flex-direction: column;
  justify-content: end;
  align-items: start;
  gap: .65rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background:
    linear-gradient(90deg, #111018 8%, #111018cc 35%, #11101810 76%),
    linear-gradient(0deg, #111018b0, transparent 80%),
    url('/art/duel.webp') center 45% / cover,
    #1c1829;
}

.room-status {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  color: #d1cbdf;
  font-size: .95rem;
}

.room-status::before, .presence::before {
  display: inline-block;
  width: .48rem;
  height: .48rem;
  flex: none;
  border-radius: 50%;
  background: #9b93aa;
  content: "";
}

.room-status.ready, .presence.online { color: var(--ready); }
.room-status.ready::before, .presence.online::before { background: var(--ready); }

.room-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  margin-top: 1rem;
}

.room-panel {
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--panel);
}

.room-panel h2, .panel-title {
  display: block;
  margin-bottom: .85rem;
  font-size: 1rem;
  font-weight: 750;
}

.players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.players li {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .7rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: #1e1e27;
  font-size: .9rem;
  font-weight: 700;
}

.seat {
  display: grid;
  width: 2.5rem;
  aspect-ratio: 1;
  flex: none;
  place-items: center;
  border-radius: .35rem;
  font-weight: 850;
}

.seat-host { background: #33284e; color: #c4acff; }
.seat-guest { background: #1d373b; color: #a4e7e4; }

.presence {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: .1rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
}

.presence::before { width: .34rem; height: .34rem; }

.flag-lobby { margin-top: 1rem; }
.flag-lobby > .button { width: 100%; min-height: 3rem; }

.flag-match h1 { color: #fffbd9; }

.flag-progress, .flag-scores {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
}

.flag-progress { min-height: 2rem; margin-top: .85rem; color: var(--muted); font-size: .9rem; }
.flag-timer { color: #ffce55; font-size: 1.15rem; font-variant-numeric: tabular-nums; font-weight: 850; }

.flag-scores { margin-top: .5rem; }
.flag-scores > span {
  display: flex;
  flex: 1;
  justify-content: space-between;
  gap: .5rem;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--panel);
  font-size: .9rem;
}

.flag-scores strong { color: #ffe39b; }
.flag-instruction { margin-block: 1.15rem .8rem; color: #f2f2f7; font-weight: 700; }

.flag-spotlight {
  display: grid;
  min-height: 13rem;
  place-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--panel);
}

.flag-picture {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: .2rem;
  background-repeat: no-repeat;
}

.flag-spotlight .flag-picture { width: min(100%, 15rem); border-radius: .4rem; }

.flag-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(.2rem, 1.4cqw, .4rem);
}

.flag-tile {
  position: relative;
  min-height: 2.75rem;
  padding: .2rem;
  border: 2px solid #373741;
  border-radius: .38rem;
  background: #1a1a24;
  cursor: pointer;
}

.flag-tile[aria-disabled="true"] { cursor: default; }
.flag-tile:hover:not([aria-disabled="true"]) { border-color: #b7b4c7; }
.flag-tile.picked { border-color: #ffce55; }
.flag-tile.correct { border-color: #62dcb1; }
.flag-tile.incorrect { border-color: #f28592; }

.flag-tile.correct::after, .flag-tile.incorrect::after {
  position: absolute;
  inset-inline-end: .12rem;
  inset-block-end: .12rem;
  padding-inline: .2rem;
  border-radius: .15rem;
  background: #101018;
  color: #62dcb1;
  font-size: .75rem;
  font-weight: 850;
  content: '✓';
}

.flag-tile.incorrect::after { color: #f28592; content: '×'; }
.flag-error { color: #f2afb8; }
.flag-finish { width: 100%; margin-top: 1rem; text-decoration: none; }

@container (max-width: 25rem) {
  .room-panel, .players li { padding: .65rem; }
  .players li { gap: .45rem; }
  .seat { width: 1.8rem; }
}
