:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #39322e;
  --muted: #6f7475;
  --pearl: #fbfaf4;
  --mist: #edf7f7;
  --aqua: #4b9d9c;
  --aqua-soft: #dff3f0;
  --gold: #b79252;
  --gold-soft: #f2e4bd;
  --panel: rgba(255, 254, 249, 0.9);
  --line: rgba(113, 105, 90, 0.18);
  --shadow: 0 18px 46px rgba(77, 94, 103, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 280px;
  min-height: 100%;
  background: #f5f8f6;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(116deg, transparent 0 67%, rgba(99, 137, 150, 0.055) 67% 67.12%, transparent 67.12%),
    linear-gradient(28deg, transparent 0 28%, rgba(173, 142, 84, 0.05) 28% 28.12%, transparent 28.12%),
    radial-gradient(circle at 12% 4%, rgba(243, 222, 164, 0.38), transparent 25rem),
    radial-gradient(circle at 88% 15%, rgba(164, 211, 220, 0.3), transparent 31rem),
    linear-gradient(145deg, #fcfaf2 0%, #f6faf9 50%, #eef4f8 100%);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  border: 1px solid rgba(104, 126, 137, 0.075);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

body::before { width: 42rem; height: 42rem; top: -29rem; left: 19%; }
body::after { width: 30rem; height: 30rem; right: -17rem; bottom: -14rem; }

button, a { font: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid #287b81;
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.9rem, env(safe-area-inset-right))
    max(1.2rem, env(safe-area-inset-bottom)) max(0.9rem, env(safe-area-inset-left));
}

.topbar,
.app-main {
  width: min(88rem, 100%);
  margin-inline: auto;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.38rem 0.85rem;
  border: 1px solid rgba(133, 119, 94, 0.18);
  border-radius: 1rem;
  background: rgba(255, 254, 249, 0.76);
  box-shadow: 0 8px 26px rgba(69, 79, 85, 0.08), inset 0 1px rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.identity-banner {
  min-height: 5.8rem;
  padding: 0.85rem 1.25rem;
  overflow: hidden;
}

.identity-banner::after {
  position: absolute;
  right: 20%;
  bottom: -4.8rem;
  width: 15rem;
  aspect-ratio: 1;
  border: 1px solid rgba(91, 144, 151, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 1.8rem rgba(180, 151, 95, 0.035), 0 0 0 3.8rem rgba(91, 144, 151, 0.025);
  content: "";
  pointer-events: none;
}

.brand,
.brand-cluster,
.topbar-actions {
  display: flex;
  align-items: center;
}

.brand { gap: 0.7rem; color: var(--ink); text-decoration: none; }
.brand-cluster, .topbar-actions { gap: 0.55rem; }

.brand-mark {
  display: grid;
  width: 2.7rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(161, 126, 67, 0.35);
  border-radius: 50% 50% 44% 56%;
  color: #6e5735;
  background: radial-gradient(circle at 35% 30%, #fffdf3, #f0e1bd 72%, #dbdfe0);
  box-shadow: inset 0 0 0 0.22rem rgba(255, 255, 255, 0.58), 0 5px 15px rgba(116, 92, 57, 0.1);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
}

.brand-copy { display: grid; gap: 0.1rem; }
.brand-name, .brand-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-tagline { color: #777068; font-family: Georgia, "Times New Roman", serif; font-size: 0.76rem; }

.guest-status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 1.9rem;
  color: #665e55;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.77rem;
  white-space: nowrap;
}

.guest-status::before {
  width: 0.52rem;
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  content: "";
}

.guest-status[data-tone="on"]::before { border-color: #4d8a78; background: #9bd3c0; }
.guest-status[data-tone="off"]::before { border-color: #aa874c; background: #eed79d; }

.topbar-link {
  display: inline-flex;
  min-height: 2.1rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  color: #514a44;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.8rem;
  text-decoration: none;
}
.topbar-link:hover { color: #236d73; }

.app-main { margin-top: 0.9rem; }

.collection-layout {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: clamp(0.8rem, 1.6vw, 1.35rem);
  align-items: start;
}

.collection-rail {
  position: sticky;
  top: 0.75rem;
  min-height: 25rem;
  padding: 1.25rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background:
    radial-gradient(circle at 50% 0, rgba(240, 221, 174, 0.3), transparent 9rem),
    rgba(255, 254, 249, 0.68);
  box-shadow: 0 12px 34px rgba(73, 88, 94, 0.09), inset 0 0 0 0.28rem rgba(255, 255, 255, 0.34);
}

.collection-rail::after {
  display: block;
  width: 2.25rem;
  aspect-ratio: 1;
  margin: 3rem auto 0;
  border: 1px solid rgba(82, 143, 149, 0.16);
  border-radius: 50%;
  color: rgba(177, 139, 75, 0.55);
  content: "◇";
  line-height: 2.1rem;
  text-align: center;
  transform: rotate(45deg);
}

.collection-rail-kicker {
  margin: 0 0 0.25rem;
  color: var(--aqua);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.collection-rail h1 {
  margin: 0 0 1.1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
}

.collection-filters { display: grid; gap: 0.25rem; }

.collection-filter {
  display: block;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-left: 2px solid transparent;
  color: #6a6259;
  background: transparent;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: left;
}

.collection-filter:hover { color: #28777b; background: rgba(226, 244, 242, 0.44); }
.collection-filter[aria-pressed="true"],
.collection-filter-current {
  border-left-color: var(--gold);
  color: #326f72;
  background: linear-gradient(90deg, rgba(221, 241, 238, 0.72), transparent);
}

.collection-content {
  min-width: 0;
  padding: 1rem clamp(0.85rem, 2vw, 1.6rem) 1.6rem;
  border: 1px solid rgba(128, 119, 105, 0.16);
  border-radius: 1rem;
  background: linear-gradient(rgba(255, 255, 255, 0.49), rgba(246, 250, 249, 0.64));
  box-shadow: var(--shadow), inset 0 0 4rem rgba(255, 255, 255, 0.52);
}

.collection-heading {
  display: grid;
  grid-template-columns: minmax(1rem, 1fr) auto minmax(1rem, 1fr);
  align-items: center;
  gap: 0.65rem;
  margin: 0.1rem 0 1rem;
}

.collection-heading h2 {
  margin: 0;
  color: #715b3d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 500;
  letter-spacing: 0.025em;
}

.heading-rule { height: 1px; background: linear-gradient(90deg, transparent, rgba(166, 133, 75, 0.4)); }
.heading-rule:last-child { transform: rotate(180deg); }

.collection-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 10.5rem));
  justify-content: start;
  align-items: start;
  gap: clamp(0.7rem, 1.25vw, 1.05rem);
}

.collection-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 2 / 3;
  border-radius: clamp(0.5rem, 0.8vw, 0.76rem);
}

.empty-slot {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(167, 151, 120, 0.17);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.54), rgba(229, 241, 240, 0.22)),
    rgba(250, 248, 239, 0.45);
  box-shadow: inset 0 0 0 0.24rem rgba(255, 255, 255, 0.24), inset 0 0 0 0.3rem rgba(155, 139, 106, 0.055);
}

.empty-slot::before,
.empty-slot::after {
  position: absolute;
  border: 1px solid rgba(132, 156, 157, 0.075);
  content: "";
}
.empty-slot::before { width: 48%; aspect-ratio: 1; border-radius: 50%; }
.empty-slot::after { width: 29%; aspect-ratio: 1; border-radius: 20%; transform: rotate(45deg); }
.empty-slot-rune { position: relative; z-index: 1; color: rgba(174, 139, 76, 0.34); font-size: 0.85rem; }

.game-card {
  z-index: 2;
  perspective: 62rem;
  transition: transform 180ms ease, filter 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .game-card:not(.game-card-flipped):hover {
    filter: drop-shadow(0 12px 18px rgba(67, 107, 109, 0.18));
    transform: translateY(-0.2rem) rotateX(1deg);
  }
}

.game-card-flipped {
  z-index: 8;
  filter: drop-shadow(0 16px 25px rgba(67, 107, 109, 0.22));
  transform: translateY(-0.25rem);
}

.game-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 300ms cubic-bezier(0.2, 0.72, 0.3, 1);
}
.game-card-flipped .game-card-inner { transform: rotateY(180deg); }

.game-card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(170, 128, 59, 0.53);
  border-radius: inherit;
  background: linear-gradient(155deg, #fffdf5, #e7f7f3 68%, #d6efec);
  box-shadow: inset 0 0 0 0.2rem rgba(255, 255, 255, 0.62), 0 8px 20px rgba(76, 97, 100, 0.13);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.game-card-face::before,
.game-card-face::after {
  position: absolute;
  z-index: 4;
  color: rgba(157, 117, 53, 0.72);
  font-size: 0.63rem;
  content: "◇";
  pointer-events: none;
}
.game-card-face::before { top: 0.28rem; left: 0.3rem; }
.game-card-face::after { right: 0.3rem; bottom: 0.28rem; }

.game-card-front {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  padding: 0.38rem;
  color: inherit;
  cursor: pointer;
  text-align: center;
}

.game-card-artwork {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(161, 131, 80, 0.36);
  border-radius: calc(clamp(0.5rem, 0.8vw, 0.76rem) - 0.16rem) calc(clamp(0.5rem, 0.8vw, 0.76rem) - 0.16rem) 0.25rem 0.25rem;
  background: #d7eeee;
  background-position: center;
  background-size: cover;
}

.game-card-fallback { display: block; width: 100%; height: 100%; }
.game-card-fallback { display: grid; place-items: center; font-family: Georgia, serif; font-size: 3rem; }

.game-card-identity {
  display: grid;
  grid-template-columns: 0.8rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.2rem;
  min-height: 3.5rem;
  padding: 0.3rem 0.18rem 0.12rem;
}

.game-card-identity h2 {
  margin: 0;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.72rem, 1.15vw, 1rem);
  font-weight: 500;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.card-rune { color: var(--gold); font-size: 0.62rem; }
.card-player-count { color: #4c7777; font-family: Georgia, "Times New Roman", serif; font-size: 0.68rem; font-weight: 700; }
.card-genre { grid-column: 1 / -1; color: #74807d; font-size: 0.52rem; letter-spacing: 0.11em; text-transform: uppercase; }

.game-card-back {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.78rem 0.72rem 0.68rem;
  transform: rotateY(180deg);
  text-align: center;
}

.card-back-toggle {
  position: absolute;
  top: 0.36rem;
  right: 0.4rem;
  z-index: 5;
  display: grid;
  width: 1.65rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(164, 128, 66, 0.22);
  border-radius: 50%;
  color: #7c6644;
  background: rgba(255, 254, 247, 0.82);
  cursor: pointer;
}
.card-back-rune { color: var(--gold); font-size: 0.58rem; }

.game-card-back h2 {
  margin: 0.18rem 1.4rem 0.35rem;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.82rem, 1.2vw, 1.02rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-preview {
  position: relative;
  height: 4rem;
  overflow: hidden;
  border: 1px solid rgba(151, 132, 96, 0.22);
  border-radius: 0.28rem;
  background: var(--aqua-soft);
  background-position: center;
  background-size: cover;
}
.card-preview span { display: grid; height: 100%; place-items: center; font-family: Georgia, serif; }

.card-back-description {
  margin: 0.48rem 0 0;
  color: #57534e;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.64rem, 0.82vw, 0.74rem);
  line-height: 1.28;
}
.card-back-meta { margin: 0.28rem 0 0; color: #625d55; font-size: 0.58rem; font-weight: 700; }

.play-button,
.message-link,
.admin-submit {
  display: inline-flex;
  min-height: 2.1rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(164, 128, 66, 0.22);
  border-radius: 0.35rem;
  color: #514638;
  background: linear-gradient(90deg, #f8ecd0, #dcefea);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}
.game-card-back .play-button { width: 100%; margin-top: auto; }
.play-button-locked { color: #81776b; background: #f2eee4; cursor: not-allowed; }
.card-back-lock { margin: 0.28rem 0 0; color: #786d61; font-size: 0.55rem; }

.game-page { display: grid; gap: 1rem; padding-top: 0.3rem; }
.game-heading h1,
.message-panel h1,
.admin-panel h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.02;
}
.game-heading h1 { font-size: clamp(1.8rem, 4vw, 3rem); }
.game-heading p, .message-panel p, .admin-copy, .admin-status { color: var(--muted); line-height: 1.55; }
.game-heading p { margin: 0.35rem 0 0; }
.game-mount { min-width: 0; }

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--aqua);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.message-panel,
.admin-panel {
  max-width: 38rem;
  margin: clamp(1.5rem, 7vw, 5rem) auto;
  padding: clamp(1.35rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.message-panel { text-align: center; }
.message-panel h1, .admin-panel h1 { font-size: clamp(2rem, 6vw, 3.5rem); }
.message-panel .message-link { margin-top: 1rem; padding-inline: 1.1rem; }
.loading { min-height: 12rem; display: grid; place-items: center; color: var(--muted); }
.admin-copy { margin-bottom: 0; }
.admin-form { display: grid; gap: 0.9rem; margin-top: 1.25rem; }

.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(237, 247, 246, 0.72);
  font-weight: 750;
}
.admin-toggle input { width: 2rem; height: 2rem; accent-color: var(--aqua); }
.admin-submit { width: 100%; }
.admin-submit:disabled, .admin-toggle input:disabled { cursor: wait; opacity: 0.65; }
.admin-status[data-kind="error"] { color: #a13f3f; }
.admin-status[data-kind="success"] { color: #17725d; }

.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;
}

@media (max-width: 70rem) {
  .collection-layout { grid-template-columns: 9rem minmax(0, 1fr); }
  .collection-board { grid-template-columns: repeat(4, minmax(0, 10rem)); }
}

@media (max-width: 48rem) {
  .app-shell { padding: 0.45rem; }
  .identity-banner { min-height: 3.8rem; padding: 0.42rem 0.7rem; }
  .brand-mark { width: 2.15rem; }
  .brand-name { font-size: 0.98rem; }
  .brand-tagline { display: none; }
  .guest-status, .topbar-link { font-size: 0.67rem; }
  .collection-layout { display: block; }
  .collection-rail { position: static; min-height: 0; margin-bottom: 0.55rem; padding: 0.4rem 0.65rem; }
  .collection-rail-kicker, .collection-rail::after { display: none; }
  .collection-rail h1 { display: inline; margin: 0 0.75rem 0 0; font-size: 0.9rem; }
  .collection-filters { display: inline-flex; max-width: calc(100% - 6rem); gap: 0.15rem; overflow-x: auto; vertical-align: middle; }
  .collection-filter { width: auto; min-height: 1.9rem; padding: 0.3rem 0.48rem; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .collection-filter[aria-pressed="true"], .collection-filter-current { border-bottom-color: var(--gold); }
  .collection-content { padding: 0.65rem; }
  .collection-heading { margin-bottom: 0.65rem; }
  .collection-board { grid-template-columns: repeat(4, minmax(0, 9.3rem)); gap: 0.5rem; }
  .game-card-identity { min-height: 2.85rem; }
  .card-preview { height: 3.1rem; }
  .game-card-back { padding: 0.55rem 0.5rem 0.48rem; }
  .card-back-description { margin-top: 0.3rem; }
  .play-button { min-height: 1.8rem; }
}

@media (orientation: portrait) and (max-width: 42rem) {
  .identity-banner { min-height: 4.2rem; }
  .topbar-actions { gap: 0.25rem; }
  .guest-status { max-width: 7.5rem; white-space: normal; line-height: 1.05; }
  .collection-board { grid-template-columns: repeat(2, minmax(0, 9.8rem)); justify-content: center; gap: 0.65rem; }
  .collection-heading h2 { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .game-card-inner, .game-card-flipped .game-card-inner { transform: none; }
  .game-card-front, .game-card-back { transform: none; transition: opacity 0.01ms linear; }
  .game-card-back { opacity: 0; visibility: hidden; }
  .game-card-flipped .game-card-front { opacity: 0; visibility: hidden; }
  .game-card-flipped .game-card-back { opacity: 1; visibility: visible; }
}
