:root {
  color-scheme: dark;
  color: #edf1ec;
  background: #0d1210;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  --background: #0d1210;
  --surface: #151b18;
  --surface-raised: #1a211d;
  --border: #2a352f;
  --border-strong: #526157;
  --text: #edf1ec;
  --muted: #9ca8a0;
  --accent: #d6c367;
  --accent-dark: #302c13;
  --danger: #ffb0a8;
  --shadow: 0 24px 70px rgb(0 0 0 / 34%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgb(77 95 69 / 22%), transparent 38rem),
    var(--background);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgb(214 195 103 / 40%);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.site-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 44px) 48px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-name {
  max-width: 240px;
  overflow: hidden;
  color: #cbd3ce;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.center-view {
  display: grid;
  min-height: calc(100vh - 126px);
  min-height: calc(100dvh - 126px);
  place-items: center;
  padding: 36px 0;
  color: var(--muted);
  text-align: center;
}

#loading-view {
  align-content: center;
  gap: 12px;
}

#loading-view p {
  margin: 0;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-card {
  width: min(100%, 420px);
  padding: clamp(26px, 5vw, 40px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgb(21 27 24 / 94%);
  box-shadow: var(--shadow);
  text-align: left;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
}

.login-card h1 {
  font-size: 29px;
}

.muted {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

#login-form {
  display: grid;
  gap: 9px;
  margin-top: 28px;
}

#login-form label {
  margin-top: 7px;
  color: #d8ded9;
  font-size: 14px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  background: #0f1412;
}

input::placeholder {
  color: #77827b;
}

input:hover {
  border-color: #748077;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
  transition: 150ms ease;
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-primary {
  color: #17160b;
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: #e3d178;
}

.button-quiet {
  border-color: var(--border);
  color: #dce2de;
  background: var(--surface);
}

.button-quiet:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.button-block {
  width: 100%;
  min-height: 49px;
  margin-top: 8px;
}

.form-message {
  min-height: 20px;
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.login-note {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: #818c85;
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.games-view {
  padding: clamp(30px, 5vw, 60px) 0;
}

.page-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.search-field {
  width: min(310px, 100%);
  flex: 0 0 auto;
}

.search-field input {
  padding-left: 42px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%239ca8a0' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.provider-tabs {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  margin-top: 34px;
  padding: 1px 1px 11px;
  scrollbar-width: thin;
}

.provider-tab {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding: 0 17px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #c9d0cb;
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
}

.provider-tab span {
  color: #8f9b93;
  font-size: 12px;
}

.provider-tab[aria-pressed="true"] {
  border-color: var(--accent);
  color: #17160b;
  background: var(--accent);
}

.provider-tab[aria-pressed="true"] span {
  color: #51491d;
}

.page-message {
  min-height: 22px;
  margin: 8px 0;
  color: var(--danger);
  font-size: 13px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 22px);
}

.game-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.game-card:hover:not(:disabled) {
  border-color: #637168;
  box-shadow: 0 12px 34px rgb(0 0 0 / 24%);
  transform: translateY(-2px);
}

.game-card:disabled {
  cursor: wait;
  opacity: 0.68;
}

.game-cover {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #111713;
}

.game-info {
  display: block;
  padding: 12px 13px 14px;
}

.game-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.game-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgb(8 12 10 / 78%);
  font-size: 13px;
  font-weight: 750;
}

.empty-state {
  padding: 62px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  color: #dce2de;
  font-size: 19px;
}

.empty-state p {
  margin: 9px 0 0;
  font-size: 14px;
}

.launch-dialog {
  width: min(92vw, 430px);
  padding: 27px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.launch-dialog::backdrop {
  background: rgb(0 0 0 / 66%);
}

.launch-dialog h2 {
  margin: 0;
  font-size: 21px;
}

.launch-dialog p {
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(380px, calc(100vw - 36px));
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  background: #202823;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1200px) {
  .game-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .game-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .site-header {
    min-height: 68px;
  }

  .brand small,
  .account-name {
    display: none;
  }

  .center-view {
    min-height: calc(100dvh - 96px);
    align-items: start;
    padding-top: max(46px, 10vh);
  }

  .login-card {
    border-radius: 17px;
  }

  .page-intro {
    align-items: stretch;
    flex-direction: column;
    gap: 22px;
  }

  .search-field {
    width: 100%;
  }

  .provider-tabs {
    margin-inline: -16px;
    padding-inline: 16px;
  }

  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .site-shell {
    padding-bottom: 28px;
  }

  .login-card {
    padding: 25px 20px;
  }

  .games-view {
    padding-top: 34px;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .game-info {
    padding: 10px 10px 12px;
  }

  .game-name {
    font-size: 13px;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}

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