:root {
  color-scheme: dark;
  --bg: #070707;
  --bg-soft: #101010;
  --panel: #171717;
  --panel-strong: #202020;
  --panel-light: #ffffff;
  --text: #f7f7f7;
  --muted: #b8b8b8;
  --muted-dark: #555555;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --red: #e50914;
  --red-dark: #a90610;
  --red-soft: rgba(229, 9, 20, 0.16);
  --white-soft: rgba(255, 255, 255, 0.06);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 32px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(229, 9, 20, 0.18), transparent 30rem),
    linear-gradient(135deg, #050505 0%, #101010 48%, #210406 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 75%);
}

h1,
h2,
h3 {
  margin: 0 0 18px;
  line-height: 1.1;
  letter-spacing: 0;
  color: #ffffff;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 850;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2.25rem);
  font-weight: 780;
}

h3 {
  font-size: 1.15rem;
  font-weight: 760;
}

p,
label,
li,
td,
th,
span {
  color: inherit;
}

a {
  color: #ffffff;
  text-decoration: none;
  border-bottom: 1px solid rgba(229, 9, 20, 0.55);
  transition: color 160ms ease, border-color 160ms ease;
}

a:hover {
  color: #ff4851;
  border-color: #ff4851;
}

img {
  max-width: 100%;
}

button,
.file-label,
.download-btn,
#switchPageButton,
input::file-selector-button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: #ffffff;
  background: linear-gradient(180deg, #ff1d2a 0%, var(--red) 55%, var(--red-dark) 100%);
  box-shadow: 0 10px 24px rgba(229, 9, 20, 0.28);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
.file-label:hover,
.download-btn:hover,
#switchPageButton:hover,
input::file-selector-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 16px 34px rgba(229, 9, 20, 0.36);
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

input,
select,
textarea {
  width: min(100%, 420px);
  min-height: 42px;
  margin: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(229, 9, 20, 0.8);
  box-shadow: 0 0 0 4px var(--red-soft);
  background: rgba(255, 255, 255, 0.11);
}

input[type="file"] {
  padding: 8px;
}

select {
  color: #ffffff;
}

option {
  color: #111111;
  background: #ffffff;
}

ul {
  padding-left: 1.15rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 18, 18, 0.92);
  box-shadow: var(--shadow);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
}

th {
  color: #ffffff;
  background: #280507;
  font-weight: 800;
}

tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.035);
}

.container,
.html-files,
.player-result,
.character-card,
.upload-container,
.flex-container > div,
.password-start-container > div,
.status-container,
.result,
#roomList > div,
.header,
.username-change,
.error-message,
.loading {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(32, 32, 32, 0.96), rgba(14, 14, 14, 0.96));
  box-shadow: var(--shadow);
}

.container,
.html-files {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px);
}

body > h1,
body > h2,
body > h3,
body > p,
body > label,
body > pre,
body > #result,
body > #searchResult,
body > .result,
body > .grid-container,
body > table,
body > .loading,
body > .download-button {
  position: relative;
  z-index: 1;
  width: min(100%, 1120px);
  margin-left: auto;
  margin-right: auto;
}

body > input,
body > select,
body > button {
  position: relative;
  z-index: 1;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

body > pre,
body > #result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  overflow: auto;
  background: rgba(18, 18, 18, 0.92);
  box-shadow: var(--shadow);
}

.html-files {
  max-width: 760px;
}

.html-files h2 {
  text-align: center;
}

.html-files ul {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.html-files li {
  margin: 0;
}

.html-files a {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.055);
}

.html-files a:hover {
  background: var(--red-soft);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
}

.search-container,
.button-container,
.flex-row,
.roles,
.modes,
.download-button,
.upload-container,
.password-start-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.flex-row,
.download-button {
  margin: 12px 0;
}

.flex-container,
.grid-container {
  display: grid;
  gap: 16px;
}

.flex-container {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
}

.flex-container > div,
.password-start-container > div,
.result,
.player-result,
.upload-container,
.loading {
  padding: 18px;
}

.password-start-container {
  margin: 18px 0;
}

.grid-container {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 20px;
}

#comparisonResults.grid-container {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.character-card {
  padding: 12px;
  text-align: center;
}

.character-card img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius);
}

.character-card p {
  margin: 10px 0 0;
  font-weight: 800;
}

.image-section,
.form-section {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.container:has(> .image-section),
.container:has(> .form-section) {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.image-section img {
  width: min(280px, 60vw);
  height: auto;
}

.form-section {
  text-align: center;
}

.upload-section {
  margin-top: 10px;
}

.role-selection,
.mode-selection {
  margin-bottom: 22px;
}

.roles,
.modes {
  justify-content: center;
}

.role-button,
.queue-button {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.role-button.active,
.role-button:hover,
.queue-button.active,
.queue-button:hover {
  background: linear-gradient(180deg, #ff1d2a, var(--red));
  box-shadow: 0 14px 30px rgba(229, 9, 20, 0.32);
}

.mode {
  width: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.mode:hover,
.mode.active {
  transform: translateY(-3px);
  border-color: rgba(229, 9, 20, 0.65);
  background: var(--red-soft);
}

.mode img {
  width: 100%;
  display: block;
}

.mode span {
  display: block;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  font-weight: 750;
}

.path-text,
.top-left-text,
.username,
.muted-text {
  color: var(--muted);
  font-size: 0.85rem;
}

.path-text {
  position: absolute;
  top: 12px;
  right: 16px;
}

.top-left-text {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 2;
}

.file-drop-area,
.dropbox {
  margin: 16px 0;
  border: 1px dashed rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.055);
}

.file-drop-area:hover,
.dropbox:hover {
  border-color: rgba(229, 9, 20, 0.75);
  background: var(--red-soft);
}

.download-btn,
#switchPageButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

#switchPageButton {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3;
}

#titleHeader {
  margin-bottom: 22px;
  color: #ffffff !important;
  font-size: clamp(2rem, 5vw, 3.5rem) !important;
  text-align: center;
}

.choosefile.ready {
  background: linear-gradient(180deg, #ff1d2a, var(--red));
}

.choosefile.waiting {
  background: linear-gradient(180deg, #ffffff, #bdbdbd);
  color: #111111;
}

.choosefile.finished {
  background: linear-gradient(180deg, #ffffff, #f1f1f1);
  color: var(--red);
}

.choosefile.unready {
  background: #2a2a2a;
  color: var(--muted);
  box-shadow: none;
}

.status-entry,
.player-row,
#roomList li,
.player-info,
.username-change {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 10px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.username-change {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.username-change span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-dot,
.status-circle,
.online-indicator,
.offline-indicator,
.unknown-indicator {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.green,
.online,
.online-indicator {
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
}

.red,
.offline,
.offline-indicator {
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.orange,
.unknown,
.unknown-indicator {
  background: #8a8a8a;
}

.rank-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.player-result,
#searchResult {
  margin-top: 16px;
}

#searchResult,
.error-message {
  color: #ff6b73;
}

.archive-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.game-logo {
  display: block;
  width: min(220px, 60vw);
  margin: 30px auto 0;
}

.disclaimer {
  margin: 16px 0;
  border-left: 4px solid var(--red);
  padding: 12px 14px;
  color: #ffffff;
  background: var(--red-soft);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label input,
input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

#game {
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000000;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  body {
    padding: 18px;
  }

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

  .container {
    padding: 18px;
  }

  .path-text,
  .top-left-text {
    position: static;
    display: block;
    margin-bottom: 12px;
  }

  .mode {
    width: min(45vw, 160px);
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
