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

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  background:
    radial-gradient(1200px 700px at 15% 10%, rgba(88, 148, 255, 0.28), transparent 62%),
    radial-gradient(1000px 680px at 90% 90%, rgba(255, 160, 120, 0.2), transparent 58%),
    linear-gradient(180deg, #0a1020 0%, #111a2b 45%, #0b0f1d 100%);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Segoe UI", "Hiragino Sans", sans-serif;
}

.app {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom) 16px;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  visibility: visible;
}

.overlay.hidden {
  display: none;
  opacity: 0;
  visibility: hidden;
}

.overlay-card {
  width: 100%;
  max-width: 540px;
  height: auto;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(43, 57, 95, 0.92) 0%, rgba(19, 25, 46, 0.95) 55%, rgba(14, 18, 34, 0.97) 100%);
  border: 1px solid rgba(168, 205, 255, 0.35);
  border-radius: 20px;
  padding: 24px 20px;
  color: #f8f6ff;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 24px 48px rgba(0, 0, 0, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.5);
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


.overlay-card h2 {
  margin: 0 0 10px;
  font-size: clamp(40px, 8vw, 52px);
  font-weight: 800;
  text-align: center;
  color: #fff0b8;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.summary {
  margin: 0 0 14px;
  color: #e5dfff;
  font-size: clamp(24px, 4.5vw, 30px);
  line-height: 1.5;
  text-align: center;
  font-weight: 600;
}

.rank-emphasis {
  min-height: 24px;
  margin: -2px 0 14px;
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 800;
  color: #ffda6a;
  text-shadow: 0 0 12px rgba(255, 200, 80, 0.6);
  text-align: center;
}

.name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.name-row input {
  flex: 1;
  height: 60px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  padding: 0 14px;
  font-size: clamp(22px, 4vw, 28px);
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  outline: none;
}

.name-row input:focus {
  border-color: #8db1ea;
  background: rgba(10, 20, 40, 0.5);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(141, 177, 234, 0.3);
}

.name-row button,
.tabs button,
.close-btn {
  height: 60px;
  border: 1px solid rgba(141, 177, 234, 0.8);
  border-radius: 12px;
  background: linear-gradient(180deg, #6f95d8, #3c568f, #263a68);
  color: #ffffff;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.3);
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2, 0, 0, 1);
}

.name-row button:active,
.tabs button:active,
.close-btn:active {
  transform: scale(0.97) translateY(2px);
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #5a7ec0, #344c80, #1f3058);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button {
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tabs button.active {
  background: linear-gradient(180deg, #9ed9ff, #6790d1, #486a9f);
  color: #0d1a3a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
  border-color: #b5e1ff;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15),
    0 4px 8px rgba(0, 0, 0, 0.3);
}

.rank-list-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(6, 10, 24, 0.45);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(20px, 3.8vw, 26px);
}

.rank-table th,
.rank-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.rank-table thead th {
  position: sticky;
  top: 0;
  background: rgba(30, 45, 80, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1;
  color: #d1e2ff;
  font-size: clamp(18px, 3.4vw, 22px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.rank-table tbody tr {
  transition: background 0.15s ease;
}

.rank-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.08);
}

.rank-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.rank-table tbody tr:nth-child(even):hover {
  background: rgba(255, 255, 255, 0.09);
}

.close-btn {
  width: 100%;
  margin-top: 10px;
  flex-shrink: 0;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }
}
