:root {
  color-scheme: dark;
  --bg: #090916;
  --card: rgba(17, 18, 39, 0.92);
  --primary: #00f5ff;
  --primary-dark: #8b5cf6;
  --accent: #ff2bd6;
  --gold: #ffd166;
  --text: #f8fbff;
  --muted: #a9b3d6;
  --line: rgba(0, 245, 255, 0.28);
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 43, 214, 0.34), transparent 24rem),
    radial-gradient(circle at 82% 14%, rgba(0, 245, 255, 0.26), transparent 26rem),
    linear-gradient(135deg, #080812 0%, var(--bg) 55%, #141032 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.character-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 18, 0.9);
  box-shadow: 0 12px 40px rgba(0, 245, 255, 0.12);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.character-bar span {
  color: var(--muted);
  font-weight: 800;
}

.character-option,
.language-select,
.ranking-page-button,
.player-row button,
.leaderboard-header button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  box-shadow: inset 0 0 18px rgba(0, 245, 255, 0.08);
}

.character-option {
  padding: 9px 14px;
}

.character-option.active {
  border-color: var(--primary);
  color: #08111f;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.35);
}

.language-label {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  color: var(--muted);
  font-weight: 800;
}

.language-select {
  min-width: 150px;
  padding: 9px 42px 9px 14px;
  appearance: none;
  -webkit-appearance: none;
  color: #08111f;
  border-color: var(--primary);
  background:
    linear-gradient(45deg, transparent 50%, #08111f 50%) calc(100% - 22px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--primary), var(--gold));
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.35), inset 0 0 18px rgba(255, 255, 255, 0.18);
  outline: none;
}

.language-select:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(255, 43, 214, 0.28), 0 0 22px rgba(0, 245, 255, 0.32);
}

.language-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 245, 255, 0.22), 0 0 26px rgba(255, 43, 214, 0.3);
}

.language-select option {
  color: var(--text);
  background: #111227;
}

.ranking-page-button {
  padding: 9px 14px;
  color: #08111f;
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--gold));
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.35), inset 0 0 18px rgba(255, 255, 255, 0.18);
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 24px;
  width: min(1420px, calc(100% - 32px));
  min-height: calc(100vh - 70px);
  margin: 0 auto;
  padding: 32px 0;
}

.faq-section {
  width: min(1420px, calc(100% - 32px));
  margin: -8px auto 32px;
}

.faq-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.faq-card h2 {
  margin-bottom: 10px;
}

.faq-card #faqText {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.info-grid section {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.info-grid h3 {
  margin: 0 0 8px;
  color: var(--gold);
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.project-credit {
  margin: 18px 0 0;
  color: var(--gold);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-rights {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.site-footer {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto 32px;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.site-footer a,
.legal-page a,
.cookie-banner a {
  color: var(--primary);
  font-weight: 800;
}

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(8, 8, 18, 0.94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.cookie-banner button {
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  color: #08111f;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  font-weight: 900;
}

.legal-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.legal-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.legal-card h1 {
  margin-bottom: 18px;
  font-size: clamp(34px, 7vw, 58px);
}

.legal-card h2 {
  margin-top: 24px;
  margin-bottom: 10px;
}

.legal-card p,
.legal-card li {
  color: var(--muted);
  line-height: 1.65;
}

.legal-card ul {
  padding-left: 22px;
}

.view-hidden {
  display: none !important;
}

.ranking-page {
  width: min(1160px, calc(100% - 32px));
  min-height: calc(100vh - 70px);
  margin: 0 auto;
  padding: 32px 0;
}

.ranking-page-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.ranking-page-header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.ranking-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.ranking-tab,
.book-pagination button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  box-shadow: inset 0 0 18px rgba(0, 245, 255, 0.08);
}

.ranking-tab.active {
  color: #08111f;
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--gold));
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.35);
}

.full-ranking-list {
  display: grid;
  gap: 10px;
  min-height: 420px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.full-ranking-list li {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
}

.book-pagination {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.book-pagination span {
  min-width: 130px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.book-pagination button {
  min-width: 58px;
  font-size: 22px;
}

.book-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.game-card,
.leaderboard-card,
.records-card,
.login-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  content-visibility: auto;
  contain-intrinsic-size: 520px;
}

.game-card {
  display: flex;
  min-height: calc(100vh - 134px);
  padding: 40px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.leaderboard-card,
.records-card {
  position: sticky;
  top: 94px;
  height: calc(100vh - 126px);
  padding: 28px;
  overflow: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.95;
  text-shadow: 0 0 24px rgba(0, 245, 255, 0.35), 0 0 44px rgba(255, 43, 214, 0.18);
}

h2 {
  font-size: 28px;
}

.intro {
  max-width: 520px;
  margin: 18px 0 28px;
  color: var(--muted);
  font-size: 18px;
}

.player-row {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.player-row button,
.leaderboard-header button {
  padding: 8px 12px;
  color: var(--muted);
}

.score-row {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
}

.score-box {
  display: grid;
  gap: 4px;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 22px;
  background: rgba(0, 245, 255, 0.08);
  box-shadow: inset 0 0 30px rgba(0, 245, 255, 0.08);
}

.score-box span {
  color: var(--muted);
}

.score-box strong {
  font-size: 48px;
}

.sound-toggle {
  display: grid;
  width: 170px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 20px;
  place-items: center;
  color: var(--text);
  background: rgba(0, 245, 255, 0.08);
  box-shadow: inset 0 0 24px rgba(0, 245, 255, 0.1), 0 0 18px rgba(0, 245, 255, 0.18);
  font-size: 46px;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.sound-toggle:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 24px rgba(0, 245, 255, 0.14), 0 0 28px rgba(255, 43, 214, 0.24);
}

.sound-toggle.is-muted {
  opacity: 0.62;
  filter: grayscale(1);
}

.click-target-button {
  display: grid;
  width: min(340px, 74vw);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  place-items: center;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.95) 0 10%, transparent 11%),
    radial-gradient(circle at 66% 28%, rgba(255, 255, 255, 0.95) 0 10%, transparent 11%),
    linear-gradient(145deg, var(--gold), var(--accent), var(--primary));
  box-shadow: 0 18px 0 #3b1b7a, 0 0 55px rgba(0, 245, 255, 0.34), 0 32px 70px rgba(0, 0, 0, 0.42);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.click-target-button:hover {
  transform: translateY(-4px);
}

.click-target-button:active {
  transform: translateY(10px) scale(0.98);
  box-shadow: 0 8px 0 #3b1b7a, 0 0 36px rgba(255, 43, 214, 0.3), 0 18px 32px rgba(0, 0, 0, 0.32);
}

.character-icon {
  font-size: clamp(112px, 22vw, 190px);
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.18));
  user-select: none;
}

.click-message {
  min-height: 24px;
  margin: 26px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.leaderboard-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.leaderboard {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.rank {
  display: grid;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  font-weight: 800;
}

.world-record-holder {
  border-color: rgba(255, 209, 102, 0.75) !important;
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.18), inset 0 0 24px rgba(255, 209, 102, 0.08);
}

.world-record-holder .rank,
.medal-place .rank {
  background: rgba(255, 255, 255, 0.1);
  font-size: 20px;
}

.medal-1 {
  border-color: rgba(255, 209, 102, 0.8) !important;
}

.medal-2 {
  border-color: rgba(210, 220, 235, 0.72) !important;
}

.medal-3 {
  border-color: rgba(205, 127, 50, 0.72) !important;
}

.name {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}

.speed-progress-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(0, 245, 255, 0.08);
}

.progress-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.progress-topline strong {
  color: var(--gold);
}

.progress-track {
  height: 12px;
  margin: 12px 0;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--gold));
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.45);
  transition: width 140ms ease;
}

.rank-info {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(4, 4, 12, 0.68);
  backdrop-filter: blur(8px);
}

.overlay.hidden {
  display: none;
}

.login-card {
  width: min(430px, 100%);
  padding: 30px;
}

.login-card p {
  color: var(--muted);
}

.storage-note {
  border-left: 4px solid var(--primary);
  padding-left: 12px;
  font-size: 14px;
}

.login-card label {
  display: block;
  margin: 20px 0 8px;
  font-weight: 800;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 245, 255, 0.22);
}

.auth-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: #ff7a90;
  font-weight: 800;
}

.login-card button {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  font-weight: 800;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 1fr;
    width: min(760px, calc(100% - 24px));
    gap: 18px;
    padding: 20px 0;
  }

  .faq-section,
  .ranking-page {
    width: min(760px, calc(100% - 24px));
  }

  .game-card {
    order: 1;
  }

  .records-card {
    order: 2;
  }

  .leaderboard-card {
    order: 3;
  }

  .game-card,
  .leaderboard-card,
  .records-card {
    min-height: auto;
    height: auto;
  }

  .leaderboard-card,
  .records-card {
    position: static;
  }

  .game-card,
  .leaderboard-card,
  .records-card,
  .faq-card,
  .ranking-page-card,
  .login-card {
    backdrop-filter: none;
  }
}

@media (max-width: 720px) {
  :root {
    --shadow: 0 14px 38px rgba(0, 0, 0, 0.36);
  }

  body {
    background:
      radial-gradient(circle at 20% 0%, rgba(255, 43, 214, 0.2), transparent 16rem),
      linear-gradient(135deg, #080812 0%, #111024 100%);
  }

  .character-bar {
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 10px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .character-bar > * {
    flex: 0 0 auto;
  }

  .character-option,
  .language-select,
  .ranking-page-button {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 13px;
    white-space: nowrap;
  }

  .language-label {
    margin-left: 4px;
    font-size: 13px;
  }

  .language-select {
    min-width: 132px;
  }

  .app,
  .faq-section,
  .ranking-page {
    width: min(100% - 16px, 520px);
  }

  .game-card,
  .leaderboard-card,
  .records-card,
  .faq-card,
  .ranking-page-card {
    border-radius: 20px;
    padding: 18px;
  }

  h1 {
    font-size: clamp(36px, 13vw, 58px);
    text-shadow: 0 0 18px rgba(0, 245, 255, 0.24);
  }

  h2 {
    font-size: 22px;
  }

  .intro {
    margin: 14px 0 20px;
    font-size: 15px;
  }

  .player-row {
    margin-bottom: 16px;
  }

  .score-row {
    width: 100%;
    gap: 8px;
    margin-bottom: 20px;
  }

  .score-box,
  .sound-toggle {
    width: calc(50% - 4px);
    min-width: 0;
    min-height: 92px;
  }

  .score-box {
    padding: 14px 12px;
  }

  .score-box strong {
    font-size: 38px;
  }

  .sound-toggle {
    font-size: 36px;
  }

  .click-target-button {
    width: min(260px, 78vw);
    box-shadow: 0 12px 0 #3b1b7a, 0 0 26px rgba(0, 245, 255, 0.24);
  }

  .character-icon {
    font-size: clamp(96px, 34vw, 150px);
  }

  .leaderboard li,
  .full-ranking-list li {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .leaderboard li .points,
  .full-ranking-list li .points {
    grid-column: 2;
    justify-self: start;
  }

  .ranking-page-header {
    flex-direction: column;
  }

  .full-ranking-list {
    min-height: 320px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .book-pagination {
    gap: 8px;
  }

  .book-pagination span {
    min-width: 106px;
    font-size: 13px;
  }

  .login-card {
    padding: 22px;
  }
}

@media (max-width: 380px) {
  .score-row {
    flex-direction: column;
  }

  .score-box,
  .sound-toggle {
    width: 100%;
  }

  .click-target-button {
    width: min(230px, 82vw);
  }
}

@media (prefers-reduced-motion: reduce), (max-width: 720px) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .language-select:hover,
  .sound-toggle:hover,
  .click-target-button:hover {
    transform: none;
  }
}
