@import url("/icons/src/regular/style.css");
@import url("/icons/src/fill/style.css");

:root {
  color-scheme: light;
  --bg: #f2f2f2;
  --surface: #ffffff;
  --text: #252629;
  --text-soft: #72757b;
  --line: #d1d3d6;
  --accent: #7ed6d6;
  --accent-dark: #48b8bd;
  --shadow: rgba(40, 43, 48, 0.2);
  --radius: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: Bahnschrift, "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body { width: 100%; min-width: 320px; min-height: 100%; }

body {
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
}

button,
a { font: inherit; -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--accent) 78%, white);
  outline-offset: 4px;
}

.brand-logo { display: block; object-fit: contain; object-position: left center; }

.library-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: 96px minmax(0, 1fr);
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.92), transparent 43%),
    var(--bg);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 320ms ease 80ms, transform 420ms var(--ease-out) 80ms;
}

body[data-phase="pairing"] .library-shell {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.console-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 0 clamp(32px, 4vw, 76px);
}

.console-actions,
.console-room,
.player-presence {
  display: flex;
  align-items: center;
}

.console-wordmark { width: 150px; height: 64px; }
.console-actions { gap: 10px; min-width: 0; }
.player-presence { gap: 7px; flex-wrap: nowrap; max-width: min(34vw, 390px); overflow: hidden; padding: 5px 2px; }

.player-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.76);
  background: #a8abb0;
  box-shadow: 0 0 0 1px #c9cbd0, 0 4px 12px rgba(28, 30, 34, 0.14);
  filter: grayscale(1);
  opacity: 0.48;
  transition: transform 220ms var(--ease-out), filter 180ms ease, opacity 180ms ease;
}

.player-chip img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  user-select: none;
}
.player-chip.online { filter: none; opacity: 1; transform: translateY(-2px); }
.player-chip.waiting { border-style: dashed; opacity: .72; }
.player-chip em {
  position: absolute;
  top: -6px;
  right: -7px;
  padding: 1px 4px;
  border-radius: 5px;
  color: #1a1308;
  background: #ffc25c;
  font-size: 9px;
  font-style: normal;
}
.player-chip::after {
  content: attr(data-order);
  position: absolute;
  right: -6px;
  bottom: -6px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 19px;
  height: 19px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  color: #485154;
  background: #d6dadd;
  font: 900 10px/1 Arial, sans-serif;
  box-shadow: 0 1px 4px rgba(25, 32, 34, 0.16);
}
.player-chip.ready::after { color: #123035; background: var(--accent); }

.console-room {
  flex: 0 0 auto;
  gap: 9px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #d1d5d7;
  border-radius: 12px;
  color: #283134;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 16px rgba(42, 44, 49, 0.08);
}

.console-room i {
  color: var(--accent-dark);
  font-size: 19px;
  transform: rotate(-12deg);
}

.console-room strong {
  font: 900 18px/1 Consolas, monospace;
  letter-spacing: 0.1em;
}

.console-fullscreen-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #d1d5d7;
  border-radius: 12px;
  color: #3c4245;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 16px rgba(42, 44, 49, 0.08);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.console-fullscreen-button i { font-size: 20px; }

.console-fullscreen-button:hover {
  color: #132126;
  border-color: var(--accent);
  background: var(--accent);
  transform: translateY(-1px);
}

.console-fullscreen-button:active { transform: translateY(0) scale(0.96); }

.console-home {
  display: grid;
  grid-template-rows: clamp(460px, 55vh, 610px) auto 1fr;
  align-content: stretch;
  min-height: 0;
  padding-top: 0;
}

.game-picker {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  min-height: 0;
  transform: translateY(20px);
}

.game-rail {
  display: grid;
  grid-auto-columns: clamp(370px, 32vw, 570px);
  grid-auto-flow: column;
  align-items: center;
  gap: clamp(18px, 2vw, 34px);
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  padding: 22px calc(50vw - clamp(185px, 16vw, 285px)) 28px;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.game-rail::-webkit-scrollbar { display: none; }

.game-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 5px solid transparent;
  border-radius: var(--radius);
  background: #dfe1e4;
  box-shadow: 0 12px 30px rgba(44, 47, 52, 0.16);
  cursor: pointer;
  scroll-snap-align: center;
  transform: scale(0.9);
  transition: transform 260ms var(--ease-out), border-color 180ms ease, box-shadow 220ms ease, opacity 180ms ease;
}

.game-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card:not(.selected) { opacity: 0.78; }

.game-card.selected {
  z-index: 2;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.94), 0 18px 38px rgba(22, 126, 138, 0.2);
  opacity: 1;
  transform: scale(1.055);
}

.edge-control {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 48px;
  height: 78px;
  margin: auto;
  border: 0;
  border-radius: 14px;
  color: #4c4f55;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(43, 46, 51, 0.12);
  cursor: pointer;
  font-size: 31px;
  transition: color 160ms ease, transform 180ms var(--ease-out), background 160ms ease;
}

.edge-control:hover { color: var(--accent-dark); background: #fff; transform: scale(1.05); }
.edge-control:active { transform: scale(0.96); }

.selected-game {
  min-height: 74px;
  padding: 0 32px;
  text-align: center;
}

.selected-game h1 {
  margin: 0;
  font-size: clamp(25px, 2.3vw, 36px);
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.selected-game p { margin: 8px 0 0; color: var(--text-soft); font-size: 14px; font-weight: 650; }

.console-dock {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 30px;
  min-height: 112px;
  padding-top: 18px;
  align-self: end;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  color: #6f7278;
  background: transparent;
  cursor: default;
}

button.dock-item { cursor: pointer; }

.dock-item > span {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 1px solid #d5d7da;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 17px rgba(42, 44, 49, 0.1);
  font-size: 29px;
  transition: transform 180ms var(--ease-out), border-color 160ms ease, color 160ms ease;
}

.dock-item small { font-size: 11px; font-weight: 750; }
.dock-item.active { color: var(--accent-dark); }
.dock-item.active > span { border: 4px solid var(--accent); }
button.dock-item:hover > span { color: var(--accent-dark); border-color: var(--accent); transform: translateY(-3px); }
button.dock-item:active > span { transform: scale(0.95); }

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 88px;
  padding: 11px 18px;
  border-radius: 999px;
  color: #fff;
  background: rgba(31, 33, 36, 0.92);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 220ms var(--ease-out);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 760px) {
  .library-shell { grid-template-rows: 78px minmax(0, 1fr); }
  .console-home { grid-template-rows: clamp(360px, 54vh, 430px) auto 1fr; }
  .game-picker { transform: translateY(10px); }
  .game-rail {
    grid-auto-columns: clamp(300px, 29vw, 420px);
    padding: 18px calc(50vw - clamp(150px, 14.5vw, 210px)) 22px;
  }
  .console-dock { min-height: 86px; padding-top: 8px; }
  .dock-item > span { width: 52px; height: 52px; font-size: 24px; }
}

@media (max-width: 900px) {
  .console-topbar { padding-inline: 24px; }
  .console-wordmark { width: 118px; }
  .player-presence { max-width: 150px; }
  .player-chip { width: 40px; height: 40px; }
  .console-room { padding-inline: 11px; }
  .game-picker { grid-template-columns: 52px minmax(0, 1fr) 52px; }
  .edge-control { width: 40px; height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
