/* Animation for new player items */
.player-enter {
  animation: slide-in 0.3s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation for deleting player items */
.player-leave {
  animation: slide-out 0.3s ease-in forwards;
  pointer-events: none; /* Prevent clicks during exit */
  will-change: transform, opacity, max-height;
}

@keyframes slide-out {
  0% {
    opacity: 1;
    transform: translateX(0);
    max-height: 100px; /* Adjust as needed */
    margin-bottom: 0;
  }
  100% {
    opacity: 0;
    transform: translateX(50px);
    max-height: 0;
    margin-bottom: 0;
    padding: 0;
    border: none;
    overflow: hidden;
  }
}

/* Screen transitions */
.screen {
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
}

.screen:focus {
    outline: none;
}

.fade-out {
    opacity: 0 !important;
}

.fade-in {
    opacity: 0 !important;
}

.fade-enter {
    animation: fade-enter-anim 0.3s ease-out forwards;
}

.fade-leave {
    animation: fade-leave-anim 0.3s ease-in forwards;
}

@keyframes fade-enter-anim {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-leave-anim {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Empty State */
.empty-state-message {
    text-align: center;
    padding: 0 2rem;
    color: #555;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 0;
    border: 0px dashed #e0e0e0;
    transition: all 0.3s ease;

    /* Base hidden state */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.empty-state-message.is-visible {
    max-height: 200px;
    opacity: 1;
    padding: 2.5rem 2rem;
    margin-bottom: 1.5rem;
    border-width: 2px;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .empty-state-message {
        transition: none !important;
    }
}

.empty-state-message h3 {
    color: #2c3e50;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state-message p {
    margin-bottom: 0;
    font-size: 1rem;
    color: #7f8c8d;
}

/* Player Card Styling */
.player-card {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}

.player-card:hover, .player-card:focus-within {
    border-color: #b3b3b3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.player-card input.playerNameInput {
    border: none;
    box-shadow: none;
    margin: 0;
    padding: 0.5rem;
    font-size: 1.1rem;
    flex: 1;
    background: transparent;
}

.player-card input.playerNameInput:focus {
    border: none;
    box-shadow: none;
    background: transparent;
}

.player-card .remove-player-btn {
    margin: 0;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 50%;
    color: #999;
    border: none;
    background: transparent;
    transition: all 0.2s ease;
}

.player-card .remove-player-btn:hover, .player-card .remove-player-btn:focus {
    background: #fee2e2;
    color: #ef4444;
    outline: none;
}

/* Staggered animation for role reveal list */
.role-reveal-item {
  opacity: 0; /* Start hidden */
  animation: slide-up-fade 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; /* refined easing */
  animation-delay: calc(var(--i) * 0.08s); /* slightly faster stagger */
  transition: opacity 0.3s ease;
}

@keyframes slide-up-fade {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
    scroll-behavior: auto !important;
  }

  .role-reveal-item {
    opacity: 1;
    animation: none;
  }
  .game-player-item {
    opacity: 1;
    animation: none;
  }
}

/* Staggered animation for game player list */
.game-player-item {
  opacity: 0; /* Start hidden */
  animation: slide-in-fade 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--i) * 0.1s);
}

@keyframes slide-in-fade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form validation styles */
.is-invalid-input {
    border-color: #cc4b37 !important;
    background-color: #f9ecea !important;
    transition: all 0.2s ease-in-out;
}

.is-invalid-input:focus {
    border-color: #cc4b37 !important;
    box-shadow: 0 0 0 3px rgba(204, 75, 55, 0.2) !important;
    background-color: #fff !important; /* Return to white on focus for better readability */
}

.form-error-message {
    border-radius: 6px;
    font-weight: 600;
    background-color: transparent;
    border: 1px solid transparent;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: none;

    /* Base hidden state */
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-bottom: 0;
    overflow: hidden;
    transition: all 0.3s ease-out;
}

.form-error-message.is-visible {
    max-height: 100px;
    opacity: 1;
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    background-color: #fef2f2; /* Light red background */
    border: 1px solid #fecaca; /* Red border */
    color: #991b1b; /* Dark red text */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.form-error-message::before {
    content: "⚠️";
    font-size: 1.25rem;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.form-error-message.is-visible::before {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .form-error-message {
        transition: none !important;
    }
}

/* Staggered animation for player list on load */
.player-list-load-item {
  opacity: 0; /* Start hidden */
  animation: slide-in-stagger 0.3s ease-out forwards;
  animation-delay: calc(var(--i) * 0.05s);
}

@keyframes slide-in-stagger {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-list-load-item {
    opacity: 1;
    animation: none;
  }
}

/* Button transitions */
.button {
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.button:active {
    transform: scale(0.98);
}

/* Input transitions */
input[type="text"], input[type="password"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="week"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], input[type="time"], input[type="url"], input[type="color"], textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* App Logo */
.app-logo {
  display: block;
  margin: 1rem auto 1rem auto;
  max-width: 120px;
  height: auto;
}

/* Loading Feedback & Optimistic UI */
.is-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.is-loading::after {
    content: '';
    position: absolute;
    width: 1.2rem;
    height: 1.2rem;
    top: 50%;
    left: 50%;
    margin-top: -0.6rem;
    margin-left: -0.6rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinner 0.6s linear infinite;
}

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

.success-pulse {
    animation: success-pulse 0.4s ease-out;
}

@keyframes success-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

/* Skeleton Loader */
.skeleton {
    background-color: #e2e8f0;
    border-radius: 8px;
    height: 3.5rem;
    position: relative;
    overflow: hidden;
}

.role-reveal-skeleton {
    margin-bottom: 1rem;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Modals UI Polish */
.role-reveal-card,
.game-over-card {
    padding: 1rem;
}

.modal-header {
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.role-details {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e9ecef;
}

.topic-row {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.category-row {
    color: #6c757d;
}

.helper-text {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.impostor-reveal-text {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.topic-reveal-label {
    font-size: 1.1rem;
    color: #495057;
}

.spacer {
    height: 2rem;
}

.primary-action-btn {
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Emphasis Classes */
.text-primary { color: #007bff; }
.text-success { color: #28a745; }
.text-alert { color: #dc3545; }
.text-muted { color: #6c757d; }
.text-center { text-align: center; }
