:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --bg-alt: #111c31;
  --card-bg: rgba(15, 23, 42, 0.75);
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --text: #e2e8f0;
  --text-muted: #cbd5f5;
  --shadow: rgba(8, 15, 35, 0.25);
  font-family: 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1e3a8a 0%, #020617 55%, #000 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.page-header {
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.4), transparent);
  padding: clamp(2rem, 4vw, 4rem) clamp(1.5rem, 6vw, 6rem);
}

.header-content {
  max-width: 800px;
}

.page-header h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
}

.page-header p {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-muted);
}

main {
  flex: 1;
  padding: clamp(1.5rem, 4vw, 4rem) clamp(1rem, 5vw, 5rem);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.countdown {
  margin: 0;
  align-self: stretch;
  text-align: right;
  font-size: 1rem;
  color: var(--text);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 16px;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 30px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.countdown[data-state='closed'] {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.6);
}

.countdown-label {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.countdown[data-state='closed'] .countdown-label {
  color: #fca5a5;
}

.countdown-value {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sort-controls {
  display: inline-flex;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.5rem;
  border-radius: 999px;
  box-shadow: 0 10px 30px var(--shadow);
}

.sort-button {
  background: transparent;
  color: var(--text);
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.sort-button:hover,
.sort-button:focus {
  outline: none;
  background: rgba(56, 189, 248, 0.18);
  color: white;
  transform: translateY(-1px);
}

.sort-button.is-active {
  background: rgba(56, 189, 248, 0.35);
  color: white;
}

.status-region {
  min-height: 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: right;
}

.status-region[data-status='error'] {
  color: #fca5a5;
}

.status-region[data-status='success'] {
  color: #86efac;
}

.status-region[data-status='info'] {
  color: var(--text);
}

.game-grid {
  display: grid;
  gap: clamp(1rem, 2vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.game-card {
  background: var(--card-bg);
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  box-shadow: 0 20px 45px var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card:hover,
.game-card:focus-within {
  transform: translateY(-6px);
  box-shadow: 0 30px 60px rgba(8, 15, 35, 0.45);
  border-color: rgba(56, 189, 248, 0.4);
}

.game-image {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #020617;
}

.game-content {
  padding: 1.4rem 1.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.game-title {
  margin: 0;
  font-size: 1.4rem;
}

.game-genre {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.game-summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.4rem 1.4rem;
  gap: 0.75rem;
}

.store-link {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 0.45rem 0.85rem;
  color: white;
  font-weight: 600;
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.store-link:hover,
.store-link:focus {
  outline: none;
  background: rgba(56, 189, 248, 0.4);
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-1px);
}

.vote-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vote-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: none;
  border-radius: 999px;
  color: white;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 10px 20px rgba(3, 105, 161, 0.45);
}

.vote-button:hover,
.vote-button:focus {
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(3, 105, 161, 0.55);
}

.vote-button[disabled] {
  cursor: wait;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.vote-count {
  font-weight: 700;
  font-size: 1.1rem;
}

.loading-message {
  margin: 2rem auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 15, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 10;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 20px;
  max-width: 840px;
  width: min(90vw, 840px);
  max-height: min(90vh, 640px);
  overflow: auto;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 40px 80px rgba(2, 6, 23, 0.6);
  position: relative;
  padding: 2rem;
  display: grid;
  gap: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(15, 23, 42, 0.6);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  display: grid;
  gap: 1rem;
}

.modal-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 2rem;
}

.modal-header p {
  margin: 0;
  color: var(--text-muted);
}

.modal-gallery {
  display: grid;
  gap: 1rem;
}

.modal-gallery img {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-description {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 1.05rem;
}

@media (max-width: 600px) {
  .controls {
    align-items: center;
  }

  .sort-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .status-region {
    text-align: center;
  }

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

  .vote-controls {
    justify-content: space-between;
  }
}

/* Spinner page styles */
.spinner-page main {
  display: flex;
  justify-content: center;
}

.spinner-layout {
  width: min(1100px, 100%);
  display: grid;
  gap: clamp(2rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

@media (min-width: 980px) {
  .spinner-layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

.spinner-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.5rem, 4vw, 2.5rem);
}

.spinner-stage-inner {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 1.75rem);
  border-radius: 999px;
}

.spinner-wheel {
  --rotation: 0deg;
  --spin-duration: 4500ms;
  --segment-count: 1;
  --wheel-colors: conic-gradient(from -90deg, #38bdf8 0deg 360deg);
  width: min(420px, 80vw);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--wheel-colors);
  border: 14px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 40px 80px rgba(8, 15, 35, 0.45);
  position: relative;
  overflow: hidden;
  transform: rotate(var(--rotation));
  transition: transform var(--spin-duration) cubic-bezier(0.26, 0.86, 0.25, 1.02);
}

.spinner-wheel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.05), rgba(15, 23, 42, 0.55) 60%, rgba(15, 23, 42, 0.85) 100%),
    repeating-conic-gradient(
      from -90deg,
      transparent 0deg calc(360deg / var(--segment-count) - 1deg),
      rgba(15, 23, 42, 0.35) calc(360deg / var(--segment-count) - 1deg) calc(360deg / var(--segment-count))
    );
}

.spinner-wheel::after {
  content: '';
  position: absolute;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 4px solid rgba(148, 163, 184, 0.5);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.35);
}

.spinner-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: clamp(0.65rem, 1.3vw, 0.85rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  --label-radius: 44%;
  z-index: 1;
}

.spinner-label {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(5.5rem, 16vw, 7rem);
  margin-left: calc(clamp(5.5rem, 16vw, 7rem) / -2);
  transform-origin: center;
  transform: rotate(var(--rotation)) translateY(calc(-1 * var(--label-radius))) rotate(var(--inverse-rotation));
  text-align: center;
  line-height: 1.2;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.spinner-indicator {
  position: absolute;
  top: calc(50% - min(210px, 40vw));
  left: 50%;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 28px solid #facc15;
  transform: translate(-50%, -100%);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6));
}

.spinner-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: min(420px, 80vw);
  text-align: center;
}

.spin-button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.9rem clamp(2.6rem, 6vw, 3.4rem);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  color: #0f172a;
  background: linear-gradient(135deg, #facc15, #f97316);
  box-shadow: 0 18px 30px rgba(250, 204, 21, 0.35);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.spin-button:hover,
.spin-button:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 24px 40px rgba(250, 204, 21, 0.45);
  outline: none;
}

.spin-button:active {
  transform: translateY(1px) scale(0.99);
}

.spin-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.spinner-status {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.spinner-status[data-status='success'] {
  color: #bef264;
}

.spinner-status[data-status='error'] {
  color: #fca5a5;
}

.spinner-status[data-status='info'] {
  color: var(--text);
}

.spinner-sidebar {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 24px;
  padding: clamp(1.5rem, 4vw, 2rem);
  box-shadow: 0 20px 45px rgba(8, 15, 35, 0.4);
  backdrop-filter: blur(12px);
}

.spinner-sidebar h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: clamp(1.6rem, 3vw, 2rem);
}

.spinner-sidebar p {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
}

.spinner-game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.spinner-game-list-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 18px;
  padding: 1rem 1.2rem;
  box-shadow: 0 14px 30px rgba(8, 15, 35, 0.35);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.spinner-game-list-item.is-active {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 20px 38px rgba(56, 189, 248, 0.25);
  transform: translateY(-2px);
}

.spinner-game-title {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
}

.spinner-game-genre {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .spinner-sidebar {
    order: -1;
  }

  .spinner-indicator {
    top: calc(50% - min(175px, 36vw));
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner-wheel {
    transition-duration: 0.01ms;
  }

  .spin-button:hover,
  .spin-button:focus-visible,
  .spin-button:active {
    transform: none;
    box-shadow: 0 18px 30px rgba(250, 204, 21, 0.35);
  }
}
