:root {
  --bg: #f6f2ea;
  --ink: #1f1c16;
  --muted: #645c51;
  --accent: #ed6a4c;
  --accent-dark: #c2513a;
  --card: #fff6e8;
  --ring: rgba(237, 106, 76, 0.35);
  --shadow: 0 20px 40px rgba(31, 28, 22, 0.12);
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #fffaf2 0%, #f1e6d5 55%, #e6d6c0 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

.page {
  min-height: 100vh;
  padding: 32px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  align-items: center;
}

.hero-text h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  margin: 6px 0 10px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin: 0;
}

.search-card {
  background: var(--card);
  padding: 20px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(31, 28, 22, 0.08);
  width: min(520px, 100%);
  margin-inline: auto;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #e8dccb;
  position: relative;
  transition: background 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(31, 28, 22, 0.12);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(31, 28, 22, 0.15);
  transition: transform 0.2s ease;
}

.toggle-input:checked + .toggle-track {
  background: rgba(237, 106, 76, 0.35);
}

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

.toggle-text {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-label {
  font-weight: 600;
  display: block;
  margin-bottom: 10px;
}

.search-row {
  display: flex;
  gap: 10px;
}

.filter-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  cursor: default;
  user-select: none;
}

.filter-text {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.price-row .price-input {
  width: 110px;
}

.price-sep {
  color: var(--muted);
  font-weight: 600;
}

.price-unit {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.price-reset {
  border: 1px solid rgba(31, 28, 22, 0.2);
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.price-reset:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 28, 22, 0.35);
}

.search-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(31, 28, 22, 0.2);
  font-size: 1rem;
}

.search-input:focus {
  outline: 2px solid var(--ring);
  border-color: transparent;
}

.search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.search-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.status {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.result-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-header {
  display: inline-flex;
  gap: 10px;
  background: rgba(255, 255, 255, 0.6);
  padding: 6px;
  border-radius: 14px;
  width: fit-content;
  box-shadow: var(--shadow);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.tab-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(31, 28, 22, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-direction: column;
}

.result-footer {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.is-hidden {
  display: none;
}

.result-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-family: var(--font-display);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager-btn {
  border: 1px solid rgba(31, 28, 22, 0.2);
  background: #fff;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.pager-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 240px);
  gap: 16px;
  justify-content: center;
}

.history-card {
  background: var(--card);
  padding: 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(31, 28, 22, 0.08);
}

.history-row {
  display: flex;
  gap: 10px;
}

.range-select {
  border: 1px solid rgba(31, 28, 22, 0.2);
  border-radius: 12px;
  padding: 12px 10px;
  background: #fff;
  font-size: 0.95rem;
}

.extrema {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.extrema-item {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  min-width: 150px;
}

.extrema-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.extrema-value {
  font-weight: 700;
  color: var(--accent-dark);
  margin-top: 4px;
  display: block;
}

.chart-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.game-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(31, 28, 22, 0.16);
}

.game-thumb {
  width: 100%;
  aspect-ratio: 231 / 87;
  object-fit: cover;
  display: block;
  background: #ece3d6;
}

.game-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-title {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.price {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent-dark);
}

.price-free {
  color: #0b7a4b;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.discount-badge {
  background: #ed6a4c;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.skeleton {
  animation: pulse 1.2s infinite ease-in-out;
  background: linear-gradient(90deg, #efe5d6 25%, #f7efe4 50%, #efe5d6 75%);
  background-size: 200% 100%;
}

@keyframes pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

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

  .search-btn {
    width: 100%;
  }

  .filter-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .price-row {
    width: 100%;
  }

  .price-row .price-input {
    width: 100%;
  }

  .history-row {
    flex-direction: column;
  }

  .game-thumb {
    width: 100%;
    aspect-ratio: 231 / 87;
  }

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