:root {
  color-scheme: light;
  --bg-start: #3f63dd;
  --bg-end: #7f4ad8;
  --panel-bg: rgba(255, 255, 255, 0.14);
  --panel-stroke: rgba(255, 255, 255, 0.16);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.82);
  --tile-bg: rgba(255, 255, 255, 0.88);
  --tile-text: #24314f;
  --button-main: #5d8cec;
  --button-main-hover: #4f78d7;
  --button-accent: #f39c12;
  --button-accent-hover: #d9870d;
  --button-soft: rgba(255, 255, 255, 0.18);
  --button-soft-hover: rgba(255, 255, 255, 0.26);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.28);
  --shadow-sm: 0 8px 18px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-primary);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.18), transparent 32%),
    linear-gradient(135deg, var(--bg-start), var(--bg-end));
  overflow-x: hidden;
}

.page-header {
  width: min(92vw, 1020px);
  padding-top: 28px;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.06em;
}

.container-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 0 168px;
}

.number-container {
  width: min(92vw, 1020px);
  height: 62vh;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--panel-stroke);
  border-radius: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.number-container::-webkit-scrollbar {
  display: none;
}

.random-number {
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: var(--tile-bg);
  color: var(--tile-text);
  font-size: 30px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.random-number:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.2);
}

.jump-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.35s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.82);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.control-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 10;
  width: min(92vw, 760px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--panel-stroke);
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.range-separator {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 18px;
}

input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: #24314f;
  font-size: 17px;
  text-align: center;
}

input:focus {
  outline: none;
  border-color: rgba(93, 140, 236, 0.95);
  box-shadow: 0 0 0 4px rgba(93, 140, 236, 0.18);
}

input::placeholder {
  color: rgba(36, 49, 79, 0.45);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.button-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.icon-button,
.action-button {
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.icon-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--button-main);
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  transform: translateY(-2px) scale(1.02);
  background: var(--button-main-hover);
}

.icon-button:focus-visible,
.action-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.icon-button svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#settingsBtn {
  background: var(--button-accent);
}

#settingsBtn:hover {
  background: var(--button-accent-hover);
}

.settings-panel {
  position: fixed;
  left: 50%;
  bottom: 98px;
  transform: translateX(-50%);
  z-index: 11;
  width: min(92vw, 360px);
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--panel-stroke);
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
}

.settings-panel.is-open {
  display: flex;
}

.settings-label {
  text-align: left;
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.03em;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.settings-toggle-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 50px;
  height: 30px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.switch-track {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  transition: background-color 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: rgba(93, 140, 236, 0.95);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.settings-actions {
  display: flex;
  gap: 10px;
}

.action-button {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--button-soft);
}

.action-button:hover {
  background: var(--button-soft-hover);
  transform: translateY(-1px);
}

.action-button svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 170px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

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

.language-menu {
  position: fixed;
  top: 28px;
  right: 22px;
  z-index: 30;
}

.language-menu summary {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.26);
  color: #fff;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

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

.language-menu summary svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.language-menu summary:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.language-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  margin-top: 10px;
  min-width: 164px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.84);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

.language-menu-link {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.language-menu-link:hover,
.language-menu-link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(1px);
}

.redirect-page {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.redirect-card {
  width: min(92vw, 560px);
  padding: 28px;
  border-radius: 24px;
  text-align: center;
  border: 1px solid var(--panel-stroke);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.redirect-card h1 {
  margin: 0 0 10px;
}

.redirect-card p {
  margin: 0 0 18px;
  color: var(--text-secondary);
}

@media (max-width: 720px) {
  .container-wrapper {
    padding-bottom: 230px;
  }

  .language-menu {
    top: 18px;
    right: 16px;
  }

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

  .range-inputs,
  .button-container {
    width: 100%;
  }

  .button-container {
    justify-content: center;
  }

  .random-number {
    width: 72px;
    height: 72px;
    font-size: 26px;
  }
}
