:root {
  --primary-dark: #1a1110;
  --secondary-dark: #4a0e17;
  --warm-neutral: #b08d75;
  --soft-light: #f5f2eb;
  --obsidian: var(--primary-dark);
  --charcoal: var(--secondary-dark);
  --panel: #561722;
  --panel-soft: #641d29;
  --gold: var(--warm-neutral);
  --gold-light: var(--warm-neutral);
  --text: var(--soft-light);
  --muted: #c3a895;
  --line: rgba(176, 141, 117, 0.38);
  --shadow: 0 18px 50px rgba(26, 17, 16, 0.58);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--obsidian);
  color-scheme: dark;
}

body,
h1,
h2,
h3,
p,
ul,
ol,
figure,
form,
table,
caption {
  margin: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 85% 12%, rgba(176, 141, 117, 0.14), transparent 25rem),
    linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 52%, #271416 100%);
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  line-height: 1.7;
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  width: 100%;
  padding: 2.25rem clamp(1.25rem, 5vw, 5rem) 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(26, 17, 16, 0.88);
  backdrop-filter: blur(10px);
}

header h1 {
  color: var(--gold-light);
  font-family: 'Great Vibes', cursive;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  text-align: left;
  text-shadow: 0 0 24px rgba(176, 141, 117, 0.28);
}

.sidebar-toggle,
.sidebar-close {
  min-height: 2.5rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  color: var(--gold-light);
  font-size: 1.1rem;
  line-height: 1;
}

.sidebar-toggle {
  order: -1;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible,
.sidebar-close:hover,
.sidebar-close:focus-visible {
  color: var(--primary-dark);
}

.user-status {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.user-avatar {
  display: inline-block;
  width: 1.65rem;
  height: 1.65rem;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: rgba(176, 141, 117, 0.16);
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  margin-top: 0;
}

nav a,
a {
  color: var(--gold-light);
  text-decoration: none;
  transition: color 0.4s ease, border-color 0.4s ease;
}

nav a {
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

nav a:hover,
nav a:focus-visible,
a:hover,
a:focus-visible {
  color: var(--soft-light);
  border-color: var(--gold);
}

.page-sidebar {
  position: fixed;
  z-index: 1100;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(20rem, 88vw);
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--line);
  background: rgba(74, 14, 23, 0.98);
  box-shadow: 20px 0 60px rgba(26, 17, 16, 0.65);
  transform: translateX(-105%);
  transition: transform 0.5s ease;
}

.page-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h2 {
  margin: 0;
  font-size: 1.65rem;
}

.page-sidebar nav {
  display: grid;
  justify-content: stretch;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.page-sidebar nav a {
  padding: 0.85rem 0.25rem;
  border-bottom: 1px solid rgba(176, 141, 117, 0.24);
}

.page-sidebar nav a[aria-current='page'] {
  color: var(--soft-light);
  border-color: var(--gold);
}

.sidebar-backdrop {
  position: fixed;
  z-index: 1050;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(26, 17, 16, 0.76);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

main {
  flex: 1 0 auto;
  width: 100%;
  animation: glideUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

main > .row {
  align-items: stretch;
}

.luxury-panel {
  height: 100%;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(145deg, rgba(100, 29, 41, 0.95), rgba(74, 14, 23, 0.98));
  box-shadow: var(--shadow);
  transition: transform 0.5s ease, box-shadow 0.5s ease;
}

.luxury-panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 25px 60px rgba(26, 17, 16, 0.76);
}

section + section {
  margin-top: 2rem;
}

h2,
h3 {
  color: var(--gold-light);
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.75rem, 4vw, 2.6rem);
}

h3 {
  margin-bottom: 0.9rem;
  font-size: 1.25rem;
}

p,
li {
  color: var(--muted);
}

img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.75) contrast(1.05);
}

.img-zoom-wrapper {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  margin-top: 1.5rem;
}

.carousel img {
  margin-top: 0;
}

.carousel-item {
  transition: transform 0.8s ease-in-out;
}

.carousel-control-prev,
.carousel-control-next {
  top: 50%;
  bottom: auto;
  width: 3.5rem;
  height: 5rem;
  border: 1px solid rgba(176, 141, 117, 0.5);
  border-radius: 2px;
  background: rgba(74, 14, 23, 0.82);
  opacity: 0.9;
  transform: translateY(-50%);
  transition: background 0.4s ease, border-color 0.4s ease, opacity 0.4s ease;
}

.carousel-control-prev {
  left: 1rem;
}

.carousel-control-next {
  right: 1rem;
}

.carousel-control-prev:hover,
.carousel-control-prev:focus-visible,
.carousel-control-next:hover,
.carousel-control-next:focus-visible {
  border-color: var(--soft-light);
  background: rgba(176, 141, 117, 0.88);
  opacity: 1;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
  filter: brightness(0) saturate(100%) invert(95%) sepia(7%) saturate(379%) hue-rotate(330deg) brightness(104%) contrast(93%);
}

label {
  display: block;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

input {
  display: block;
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(176, 141, 117, 0.42);
  border-radius: 2px;
  outline: 0;
  background: rgba(26, 17, 16, 0.9);
  color: var(--text);
  font: inherit;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(176, 141, 117, 0.26);
}

button {
  min-height: 2.8rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-light);
  cursor: pointer;
  font: 600 0.75rem 'Montserrat', sans-serif;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: background 0.4s ease, color 0.4s ease, transform 0.4s ease;
}

button:hover,
button:focus-visible {
  background: var(--gold);
  color: var(--primary-dark);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

form button {
  width: 100%;
}

form a {
  align-self: center;
  font-size: 0.8rem;
}

.game-section {
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

.game-section:first-of-type {
  margin-top: 1.5rem;
}

.play-page .game-section > button {
  margin: 0.25rem 0.35rem 0.25rem 0;
}

ul {
  padding-left: 1.25rem;
  list-style: none;
}

.play-page ul[aria-label='Piano note guesses'] {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.play-page ul[aria-label='Piano note guesses'] button {
  width: 100%;
  min-height: 3.5rem;
}

.play-page [aria-live='polite'] {
  margin-top: 1rem;
  color: var(--gold-light);
  font-weight: 600;
}

aside ul,
.scores-page section ul {
  display: grid;
  gap: 0.8rem;
  padding-left: 1.2rem;
}

table {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  overflow-x: auto;
  border-collapse: collapse;
  white-space: nowrap;
}

caption {
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(176, 141, 117, 0.24);
  text-align: left;
}

th {
  color: var(--gold-light);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(176, 141, 117, 0.11);
}

footer {
  flex-shrink: 0;
  padding: 1.5rem 1.25rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

footer p {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

#heroCarousel .carousel-control-prev,
#heroCarousel .carousel-control-next {
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(176, 141, 117, 0.5);
  border-radius: 2px;
  background: rgba(74, 14, 23, 0.82);
  color: var(--soft-light);
  transform: translateY(-50%);
}

#heroCarousel .carousel-control-prev:hover,
#heroCarousel .carousel-control-prev:focus-visible,
#heroCarousel .carousel-control-next:hover,
#heroCarousel .carousel-control-next:focus-visible,
#heroCarousel .carousel-control-prev:active,
#heroCarousel .carousel-control-next:active {
  border-color: var(--soft-light);
  background: rgba(176, 141, 117, 0.88);
  color: var(--primary-dark);
  transform: translateY(-50%);
}

#intro-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(26, 17, 16, 0.98);
  color: var(--gold-light);
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  font-size: clamp(1rem, 3vw, 1.5rem);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

#intro-overlay span {
  animation: pulse 2.2s ease-in-out infinite;
}

#intro-overlay:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: -0.75rem;
}

#intro-overlay.is-dismissed {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

@keyframes glideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

@media (max-width: 575.98px) {
  header {
    padding-top: 1.5rem;
  }

  .play-page ul[aria-label='Piano note guesses'] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  th,
  td {
    padding: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
