:root {
  color-scheme: dark;
  --bg: #070907;
  --panel: #0d100e;
  --panel-strong: #111611;
  --line: rgba(229, 199, 111, 0.24);
  --line-muted: rgba(255, 255, 255, 0.12);
  --gold: #e7c467;
  --gold-strong: #f1d681;
  --text: #f7f2e6;
  --muted: #bab7ad;
  --muted-strong: #d7d1c1;
  --success: #81d59a;
  --danger: #e78a76;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(231, 196, 103, 0.11), transparent 32rem),
    linear-gradient(135deg, #050705 0%, #0b120d 48%, #08090a 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 46px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow,
.panel-label {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.subtitle {
  max-width: 520px;
  margin: 10px 0 0;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.6;
}

.player-panel,
.account-strip,
.summary-strip,
.filter-strip,
.auth-dialog-inner,
.comment-dialog-inner {
  border: 1px solid var(--line);
  background: rgba(13, 16, 14, 0.82);
  box-shadow: 0 16px 50px var(--shadow);
}

.player-panel {
  min-width: 188px;
  padding: 14px 16px;
  text-align: right;
}

.player-panel strong {
  display: inline-block;
  margin-right: 4px;
  font-size: 30px;
  color: var(--gold-strong);
}

.summary-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
  padding: 14px 16px;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 14px 16px;
}

.account-strip strong {
  display: block;
  font-size: 20px;
}

.account-strip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.summary-strip strong {
  display: block;
  font-size: 20px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(231, 196, 103, 0.34);
  background: #050705;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #b98b38, #f2d376, #8ed19e);
  transition: width 220ms ease;
}

.ghost-button,
.primary-button,
.oauth-button,
.icon-button,
.claim-button {
  min-height: 40px;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.ghost-button {
  padding: 0 14px;
}

.primary-button,
.oauth-button {
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border-color: rgba(241, 214, 129, 0.76);
  color: #080a08;
  background: var(--gold-strong);
}

.oauth-button {
  min-width: 120px;
  background: rgba(231, 196, 103, 0.08);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.ghost-button:hover,
.primary-button:hover,
.oauth-button:hover,
.icon-button:hover,
.claim-button:hover,
.filter-strip input:hover,
.filter-strip select:hover,
.auth-form input:hover {
  border-color: rgba(241, 214, 129, 0.82);
  background: rgba(231, 196, 103, 0.09);
}

.ghost-button:active,
.primary-button:active,
.oauth-button:active,
.icon-button:active,
.claim-button:active {
  transform: translateY(1px);
}

.primary-button:hover {
  color: #080a08;
  background: #f4dd93;
}

.filter-strip {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 12px 16px;
}

.filter-strip input,
.filter-strip select,
.auth-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  background: #050705;
  font: inherit;
  outline: none;
}

.filter-strip input,
.auth-form input {
  padding: 0 12px;
}

.filter-strip select {
  padding: 0 10px;
}

.toggle-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted-strong);
  white-space: nowrap;
}

.toggle-filter input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--gold);
}

.result-count {
  color: var(--gold-strong);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

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

.empty-state {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.6;
}

.auth-dialog {
  width: min(920px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
}

.comment-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
}

.auth-dialog::backdrop,
.comment-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.auth-dialog-inner,
.comment-dialog-inner {
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(231, 196, 103, 0.08), transparent 50%),
    var(--panel);
}

.auth-dialog-head,
.comment-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.auth-dialog h2,
.auth-form h3,
.comment-dialog h2 {
  margin: 0;
}

.auth-dialog h2,
.comment-dialog h2 {
  font-size: 24px;
}

.comment-achievement-description {
  margin: -4px 0 16px;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.6;
}

.oauth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.auth-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.auth-form {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(231, 196, 103, 0.18);
  background: rgba(5, 7, 5, 0.58);
}

.auth-form h3 {
  color: var(--gold-strong);
  font-size: 16px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted-strong);
  font-size: 13px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.auth-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--gold-strong);
  font-size: 13px;
}

.auth-message[data-type="error"] {
  color: var(--danger);
}

.achievement-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 22px;
  min-height: 214px;
  padding: 20px;
  border: 1px solid rgba(231, 196, 103, 0.2);
  background:
    linear-gradient(90deg, rgba(231, 196, 103, 0.07), transparent 42%),
    var(--panel);
  box-shadow: 0 20px 56px var(--shadow);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.achievement-card:hover {
  border-color: rgba(241, 214, 129, 0.52);
  background:
    linear-gradient(90deg, rgba(231, 196, 103, 0.1), transparent 42%),
    var(--panel);
}

.achievement-card:focus-visible {
  outline: 2px solid rgba(241, 214, 129, 0.74);
  outline-offset: 3px;
}

.achievement-icon {
  width: 180px;
  aspect-ratio: 1;
  object-fit: contain;
  align-self: center;
  background: #030503;
}

.achievement-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.achievement-number {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.achievement-number {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 8px;
  padding: 3px 8px;
  border: 1px solid rgba(231, 196, 103, 0.28);
  background: rgba(231, 196, 103, 0.08);
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  min-width: 0;
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.claim-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted-strong);
}

.claim-button[aria-pressed="true"] {
  border-color: rgba(129, 213, 154, 0.7);
  color: var(--success);
  background: rgba(129, 213, 154, 0.12);
}

.check-mark {
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
}

.claim-button[aria-pressed="true"] .check-mark {
  position: relative;
  background: currentColor;
}

.claim-button[aria-pressed="true"] .check-mark::after {
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid #071008;
  border-width: 0 2px 2px 0;
  content: "";
  transform: rotate(45deg);
}

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

.divider {
  height: 1px;
  margin: 18px 0 16px;
  background: linear-gradient(90deg, var(--line-muted), transparent);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}

.stat-row svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: var(--gold);
}

.percent {
  color: var(--gold-strong);
  font-weight: 800;
}

.owners {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.48);
  font-size: 13px;
}

.achievement-card.is-complete {
  border-color: rgba(129, 213, 154, 0.42);
}

.comment-preview {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-muted);
}

.comment-preview-heading {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.comment-preview-item,
.comment-preview-empty {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.comment-preview-empty {
  color: rgba(255, 255, 255, 0.45);
}

.comment-open-button {
  justify-self: start;
  min-height: 32px;
  margin-top: 10px;
  padding: 0 10px;
  border: 1px solid rgba(231, 196, 103, 0.22);
  color: var(--gold-strong);
  background: rgba(231, 196, 103, 0.06);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.comment-open-button:hover {
  border-color: rgba(241, 214, 129, 0.82);
  background: rgba(231, 196, 103, 0.11);
}

.comment-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(231, 196, 103, 0.18);
  background: rgba(5, 7, 5, 0.58);
}

.comment-form label {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 13px;
}

.comment-form textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  background: #050705;
  font: inherit;
  line-height: 1.5;
  outline: none;
  padding: 10px 12px;
}

.comment-form textarea:hover,
.comment-form textarea:focus {
  border-color: rgba(241, 214, 129, 0.82);
}

.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.comment-form-actions span {
  color: var(--gold-strong);
  font-size: 13px;
}

.comment-form-actions span[data-type="error"] {
  color: var(--danger);
}

.comment-list {
  display: grid;
  gap: 10px;
  max-height: min(42dvh, 420px);
  overflow: auto;
  padding-right: 4px;
}

.comment-item {
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.comment-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.comment-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--gold-strong);
  font-size: 13px;
}

.comment-item-meta time {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.45);
}

.comment-item p,
.comment-empty {
  margin: 8px 0 0;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.6;
}

.comment-empty {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 920px) {
  .achievement-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 480px);
    padding-top: 24px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .subtitle {
    font-size: 14px;
  }

  .player-panel {
    text-align: left;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .account-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .account-actions {
    justify-content: flex-start;
  }

  .filter-strip {
    grid-template-columns: 1fr;
  }

  .auth-dialog {
    width: min(100% - 20px, 520px);
  }

  .comment-dialog {
    width: min(100% - 20px, 520px);
  }

  .auth-panels {
    grid-template-columns: 1fr;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

  .achievement-card {
    grid-template-columns: 112px 1fr;
    gap: 14px;
    min-height: 152px;
    padding: 14px;
  }

  .achievement-icon {
    width: 112px;
  }

  .title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  h2 {
    font-size: 22px;
  }

  .description {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
  }

  .divider {
    margin: 12px 0 10px;
  }

  .stat-row {
    align-items: flex-start;
    flex-wrap: wrap;
    font-size: 14px;
  }

  .comment-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .owners {
    width: 100%;
    margin-left: 28px;
  }
}

@media (max-width: 360px) {
  .achievement-card {
    grid-template-columns: 1fr;
  }

  .achievement-icon {
    width: min(100%, 156px);
  }
}
