:root {
  --primary-bg: rgba(0, 0, 0, 0.7);
  --accent-color: #FF5F5F;
  --accent-hover: #FF3F3F;
  --text-color: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --success-color: #4ade80;
  --warning-color: #facc15;
  --error-color: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 600;
  min-height: 100vh;
  background: linear-gradient(-45deg, #435294, #a83535, #353535, #f5576c);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: -1;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1rem, 3vw, 2rem);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h4 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, 5vw, 36px);
  height: clamp(32px, 5vw, 36px);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-color);
  text-decoration: none;
  font-size: clamp(1rem, 2vw, 1.1rem);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.social-link:hover {
  transform: translateY(-2px) scale(1.05);
  background: rgba(255, 255, 255, 0.2);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2rem);
  gap: 1rem;
}

#game-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 600px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
  position: relative;
  min-height: 500px;
  /* Ensure height for start screen */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Start Screen */
#start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
}

#start-screen h1 {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: -1rem;
}

.subtitle {
  font-size: 1.2rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

.start-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  text-align: left;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
}

.info-item .icon {
  font-size: 1.5rem;
}

.btn-primary.large {
  font-size: 1.5rem;
  padding: 1rem 3rem;
  border-radius: 16px;
}

#stats-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 10px;
}

#poster-container {
  margin: 0 auto 1.5rem;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: zoom-in;
  /* Indicate clickable */
  transition: transform 0.2s;
}

#poster-container:hover {
  transform: scale(1.02);
}

#poster-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Slider Styles */
#slider-container {
  margin: 2rem 0;
  position: relative;
  padding: 0 10px;
}

.rating-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

.rating-labels span {
  width: 40px;
  text-align: center;
  transition: color 0.2s;
}

.rating-labels span.active {
  color: var(--accent-color);
  transform: scale(1.1);
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus {
  outline: none;
}

/* Track */
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
}

/* Thumb */
input[type=range]::-webkit-slider-thumb {
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid white;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Tooltip */
.slider-tooltip {
  position: absolute;
  top: -40px;
  transform: translateX(-50%) scale(0.8);
  background: var(--accent-color);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.slider-tooltip.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  top: -50px;
}

.slider-tooltip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: var(--accent-color) transparent transparent transparent;
}

#submit-btn {
  padding: 0.8rem 2rem;
  background: linear-gradient(135deg, var(--accent-color), #ff7979);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(255, 95, 95, 0.4);
  width: 100%;
  max-width: 300px;
}

#submit-btn:disabled {
  background: #555;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

#submit-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 95, 95, 0.6);
}

/* Reveal Panel */
#reveal-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.countdown {
  font-size: 5rem;
  font-weight: 900;
  color: var(--accent-color);
  animation: pulse 1s infinite;
}

.result-content {
  text-align: center;
  width: 100%;
}

.rating-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 3px solid white;
  border-radius: 8px;
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.1);
}

#movie-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

#movie-year,
#movie-director {
  opacity: 0.8;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

#cast-list {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 1.5rem 0;
}

.cast-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60px;
}

.cast-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  margin-bottom: 5px;
}

.cast-name {
  font-size: 0.7rem;
  line-height: 1.1;
}

.points-display {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--success-color);
  margin-bottom: 1.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-size: 1rem;
  transition: transform 0.2s;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-2px);
}

/* Settings Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #222;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.toggle-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
  margin: 1rem 0;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.3s;
}

.toggle-btn.active {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.setting-desc {
  font-size: 0.9rem;
  opacity: 0.7;
  line-height: 1.5;
}

/* Help Modal Styles */
.points-table {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.point-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.point-row:last-child {
  margin-bottom: 0;
}

.p-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.p-badge.perfect {
  background: var(--success-color);
  color: #000;
}

.p-badge.close {
  background: var(--warning-color);
  color: #000;
}

.p-badge.far {
  background: var(--error-color);
  color: white;
}

.help-footer {
  text-align: center;
  font-style: italic;
  opacity: 0.7;
  margin-top: 1rem;
}

/* Stats Modal Styles */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.8rem;
  opacity: 0.7;
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.8rem;
  border-radius: 8px;
  opacity: 0.5;
  transition: all 0.3s;
}

.achievement-item.unlocked {
  opacity: 1;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.achievement-icon {
  font-size: 1.5rem;
}

.achievement-info h4 {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.achievement-info p {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid var(--accent-color);
  padding: 1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 200;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  font-size: 2rem;
}

.toast-title {
  font-weight: 800;
  color: var(--accent-color);
  font-size: 0.9rem;
}

.toast-message {
  font-size: 0.8rem;
}

/* Zoom Modal */
.zoom-content {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 90vh;
  width: auto;
  display: flex;
  justify-content: center;
}

#zoomed-poster {
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

/* Share Modal */
.share-content {
  text-align: center;
}

#share-preview-container {
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
}

#share-preview-container canvas {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.share-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: auto;
}