:root {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: 'Noto Sans', system-ui, -apple-system, sans-serif;
  background: #0b0f1a;
  color: #f8fafc;
}

.peakid-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  position: relative;
  z-index: 2;
}

.peakid-hero {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(14, 116, 144, 0.1));
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 24px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.peakid-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw, 2.6rem);
  letter-spacing: 0.5px;
}

.peakid-hero p {
  margin: 0;
  font-size: 1.05rem;
  color: #d6e3f1;
}

.peakid-scoreboard {
  margin-top: 24px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.peakid-score-card {
  background: #111827;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 18px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.2);
}

.peakid-score-card span {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.peakid-score-card strong {
  font-size: 1.6rem;
  color: #f8fafc;
}

.peakid-progress {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.peakid-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #0ea5a8);
  transition: width 0.4s ease;
}

.peakid-round {
  margin-top: 28px;
}

.peakid-instructions {
  font-size: 1rem;
  color: #cbd5f5;
  margin-bottom: 16px;
}

.peakid-round-grid {
  display: grid;
  gap: 24px;
}

.peakid-game-panel {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 28px;
  padding: 24px 26px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  position: relative;
  overflow: hidden;
}

.peakid-game-panel::before {
  content: '';
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 50%;
  width: 1px;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0), rgba(148, 163, 184, 0.4), rgba(148, 163, 184, 0));
  pointer-events: none;
}

.peakid-slot-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  grid-column: 3 / span 2;
  align-content: start;
}

.peakid-slot-column {
  display: grid;
  gap: 16px;
}

.peakid-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  grid-column: 1 / span 2;
  align-content: start;
}

.peakid-slot-grid {
  gap: 22px;
}

.peakid-card {
  background: #0f172a;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 0;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  display: flex;
  cursor: grab;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  transform: translate3d(0, 0, 0);
  touch-action: none;
  user-select: none;
  width: 96%;
  aspect-ratio: 4 / 3;
  justify-self: center;
  align-self: center;
  perspective: 900px;
  position: relative;
}

.peakid-card:focus-visible {
  outline: 2px solid #22c55e;
  outline-offset: 4px;
}

.peakid-card.dragging {
  cursor: grabbing;
  box-shadow: 0 18px 40px rgba(34, 197, 94, 0.35);
  z-index: 5;
}

.peakid-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.peakid-card.flipped .peakid-card-inner {
  transform: rotateY(180deg);
}

.peakid-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.peakid-card-front {
  padding: 10px;
}

.peakid-card-front img {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}

.peakid-card-back {
  transform: rotateY(180deg);
  padding: 16px;
  justify-content: center;
  gap: 10px;
  text-align: left;
}

.peakid-card-back h3 {
  margin: 0;
  font-size: 1rem;
  color: #f8fafc;
}

.peakid-card-meta {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  font-size: 0.78rem;
  color: #cbd5f5;
}

.peakid-card-meta dt {
  font-weight: 700;
  color: #94a3b8;
}

.peakid-card-meta dd {
  margin: 0;
  color: #e2e8f0;
}

.peakid-card.selected {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
}

.peakid-slot {
  background: #0b1224;
  border-radius: 20px;
  border: 2px dashed rgba(34, 197, 94, 0.35);
  padding: 26px 20px;
  min-height: 220px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #e2e8f0;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}

.peakid-slot.highlight {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.35);
}

.peakid-slot.correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.16);
}

.peakid-slot.incorrect {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.18);
}

.peakid-slot-feedback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  opacity: 0;
  pointer-events: none;
  animation: peakid-feedback-pop 1.2s ease forwards;
}

.peakid-slot.feedback-correct {
  animation: peakid-slot-pop 0.6s ease;
}

.peakid-slot.feedback-incorrect {
  animation: peakid-slot-shake 0.55s ease;
}

.peakid-slot-feedback.correct {
  color: #22c55e;
  text-shadow: 0 0 12px rgba(34, 197, 94, 0.65);
}

.peakid-slot-feedback.incorrect {
  color: #ef4444;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.65);
}

@keyframes peakid-feedback-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  25% {
    opacity: 1;
    transform: scale(1);
  }
  55% {
    opacity: 0.2;
    transform: scale(0.98);
  }
  80% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 0;
    transform: scale(1.06);
  }
}

@keyframes peakid-slot-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes peakid-slot-shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

.peakid-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.peakid-actions button,
.peakid-primary-button {
  background: linear-gradient(135deg, #22c55e, #0ea5a8);
  border: none;
  color: #0b0f1a;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.peakid-actions button[disabled],
.peakid-primary-button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.peakid-actions button:not([disabled]):hover,
.peakid-primary-button:not([disabled]):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.4);
}

.peakid-summary {
  color: #f8fafc;
  font-weight: 600;
}

.peakid-final {
  min-height: 100vh;
  padding: 32px 20px 80px;
  display: none;
  position: relative;
  z-index: 1;
}

.peakid-final.active {
  display: block;
}

.peakid-final-content {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.peakid-final-header {
  text-align: center;
  margin-bottom: 28px;
}

.peakid-final-header h2 {
  font-size: clamp(2.2rem, 4vw, 3rem);
  margin-bottom: 12px;
}

.peakid-final-header p {
  color: #d4e6f5;
  font-size: 1.1rem;
}

.peakid-final-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
}

.peakid-secondary-button {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.peakid-social-panel {
  margin-top: 32px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 24px;
  display: grid;
  gap: 20px;
}

.peakid-social-settings {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.peakid-social-settings legend {
  font-size: 1rem;
  font-weight: 700;
  margin-right: 8px;
}

.peakid-setting {
  display: flex;
  align-items: center;
  gap: 6px;
}

.peakid-setting input[type='text'] {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  padding: 6px 10px;
  color: #f8fafc;
}

.peakid-setting label {
  color: #e2e8f0;
  font-size: 0.9rem;
}

.peakid-social-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.peakid-toggle-group {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
}

.peakid-toggle-group button {
  background: transparent;
  border: none;
  color: #e2e8f0;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.peakid-toggle-group button.active {
  background: #22c55e;
  color: #0b0f1a;
}

.peakid-social-preview {
  display: flex;
  justify-content: center;
}

.peakid-social-card {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.peakid-social-card.gradient::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 10, 0.2), rgba(5, 8, 18, 0.9));
  z-index: 0;
}

.peakid-social-card > * {
  position: relative;
  z-index: 1;
}

.peakid-social-card.landscape {
  width: min(640px, 100%);
  aspect-ratio: 16 / 9;
}

.peakid-social-card.portrait {
  width: min(420px, 100%);
  aspect-ratio: 9 / 16;
}

.peakid-social-card h3 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.peakid-social-card p {
  margin: 0;
  font-size: 1rem;
  color: #e2e8f0;
}

.peakid-social-card .peakid-score-label {
  font-size: 1.3rem;
  font-weight: 700;
}

.peakid-social-card .peakid-social-name {
  font-size: 0.9rem;
  color: #f0f9ff;
}

.peakid-social-link a {
  color: #22c55e;
  text-decoration: underline;
  font-size: 0.8rem;
}

.peakid-share-buttons {
  margin-top: 24px;
  text-align: center;
}

.peakid-share-buttons h3 {
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.peakid-share-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}

.share-button {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  color: #f8fafc;
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}

.share-button:hover {
  background: rgba(34, 197, 94, 0.7);
  color: #0b0f1a;
}

.peakid-splash {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.peakid-splash.active {
  opacity: 1;
}

.peakid-splash-mask {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: none;
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

@media (max-width: 900px) {
  .peakid-round-grid {
    display: flex;
    flex-direction: column;
    gap: 28px;
  }

  .peakid-game-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .peakid-game-panel::before {
    display: none;
  }

  .peakid-card-grid,
  .peakid-slot-columns {
    grid-column: auto;
  }

  .peakid-slot-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
  }

  .peakid-slot-column {
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .peakid-hero {
    padding: 22px;
  }

  .peakid-card-grid,
  .peakid-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .peakid-slot-feedback,
  .peakid-slot.feedback-correct,
  .peakid-slot.feedback-incorrect {
    animation: none;
  }

  .peakid-card-inner {
    transition: none;
  }
}
