[hidden] {
  display: none !important;
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #070b14;
  color: #e7eefc;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans", "Noto Sans SC", "Noto Sans CJK SC", "Noto Sans JP", "Noto Sans KR", "Microsoft YaHei", "Malgun Gothic", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

a {
  color: #8eeadf;
}

a:hover {
  color: #ffffff;
}

:focus-visible {
  outline: 2px solid #3ee0c5;
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #0c1322;
  border-bottom: 1px solid #243044;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 16px;
  flex: none;
}

.brand svg {
  width: 22px;
  height: 22px;
  display: block;
}

.tagline {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: #b7c3db;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-menu {
  position: relative;
  flex: none;
  margin-left: auto;
}

.lang-menu summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #31425f;
  border-radius: 8px;
  background: #162033;
  font-size: 13px;
  font-weight: 650;
}

.lang-menu summary::-webkit-details-marker {
  display: none;
}

.lang-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 148px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #101826;
  border: 1px solid #31425f;
  border-radius: 10px;
}

.lang-menu a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: #e7eefc;
  text-decoration: none;
  font-size: 14px;
}

.lang-menu a[aria-current="page"] {
  color: #3ee0c5;
}

.lang-menu a:hover {
  background: #1a2436;
}

.first-screen {
  align-content: start;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(240px, 1fr) auto;
  gap: 6px;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  padding: 8px 14px 6px;
  min-height: 0;
}

.first-screen h1 {
  margin: 0;
  font-size: 22px;
  line-height: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.modes {
  display: flex;
  gap: 4px;
}

.modes button {
  min-width: 112px;
}

.modes button[aria-selected="true"] {
  background: #3ee0c5;
  color: #07120f;
  border-color: #3ee0c5;
  font-weight: 700;
}

.controls,
.stats,
.legend,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #31425f;
  background: #162033;
  color: #e7eefc;
  font-size: 13px;
}

button {
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: #3ee0c5;
}

select {
  max-width: 190px;
}

.speed,
.size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid #243044;
  background: #101826;
  color: #b7c3db;
  font-size: 12px;
}

input[type="range"] {
  width: 108px;
  accent-color: #3ee0c5;
  margin: 0;
}

.legend {
  gap: 8px;
  color: #b7c3db;
  font-size: 12px;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.swatch i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 2px;
  flex: none;
}

.c-start { background: #3ddc97; border-radius: 50%; }
.c-goal { background: #ff5d73; transform: rotate(45deg); }
.c-wall { background: #d5deed; }
.c-visited { background: #2f6fed; }
.c-frontier { background: #9ec0ff; }
.c-path { background: #ffe14a; }
.c-bar { background: #3ec6e0; }
.c-compare { background: #ffb020; }
.c-swap { background: #ff5d9a; }
.c-pivot { background: #c49bff; }
.c-sorted { background: #3ddc97; }

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid #243044;
  background: #101826;
  color: #b7c3db;
  font-size: 12px;
}

.stat strong {
  color: #e7eefc;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

[data-state="ready"] { color: #8eeadf; }
[data-state="running"] { color: #ffb020; }
[data-state="paused"] { color: #9ec0ff; }
[data-state="found"],
[data-state="sorted"] { color: #3ddc97; }
[data-state="nopath"] { color: #ff8b9a; }

.stage {
  position: relative;
  min-height: 240px;
  height: 100%;
  background: #05080f;
  border: 1px solid #2a3b56;
  border-radius: 10px;
  overflow: hidden;
}

canvas#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

canvas#stage.is-sort {
  cursor: default;
}

.mini-foot {
  margin: 0;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
  color: #b7c3db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 72px;
  border-top: 1px solid #243044;
}

.docs h2 {
  margin: 28px 0 8px;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.docs h3 {
  margin: 22px 0 6px;
  font-size: 18px;
}

.docs p,
.docs li {
  color: #d5deef;
}

.docs ol {
  padding-left: 1.2rem;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 10px 0 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #243044;
  white-space: nowrap;
}

th {
  color: #8eeadf;
  font-weight: 650;
}

.faq h3 {
  margin-bottom: 4px;
}

.partner {
  margin-top: 32px;
  padding: 14px 16px;
  border: 1px solid #31425f;
  border-radius: 12px;
  background: #101826;
}

.partner h2 {
  margin-top: 0;
}

.partner ul {
  margin: 8px 0;
  padding-left: 1.1rem;
}

.ftc-disclosure {
  color: #b7c3db;
  font-size: 13px;
}

.colophon {
  margin-top: 28px;
  color: #b7c3db;
  font-size: 13px;
}

.noscript {
  padding: 10px 12px;
  border: 1px solid #31425f;
  border-radius: 10px;
  background: #101826;
}

.notfound {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 20px 80px;
}

.notfound h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.notfound-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 0;
  list-style: none;
}

@media (min-width: 1100px) {
  .first-screen h1 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}

@media (max-width: 900px) {
  .tagline {
    display: none;
  }

  .first-screen {
    height: auto;
    min-height: calc(100dvh - 48px);
    grid-template-rows: auto auto auto auto minmax(420px, 68vh) auto;
  }

  .first-screen h1 {
    font-size: 18px;
    line-height: 24px;
    white-space: normal;
  }

  .modes button {
    min-width: 0;
    flex: 1;
  }
}
