/* === Reset and Base Styles === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* === Layout Components === */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* === Typography === */
h1 {
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 3em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    color: #764ba2;
    margin-bottom: 20px;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    color: white;
    text-align: center;
}

/* === Header Styles === */
header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding-top: 40px;
}

header h1 {
    margin-bottom: 10px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* === Card Component === */
.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.divider {
    text-align: center;
    color: white;
    font-weight: bold;
    margin: 20px 0;
    font-size: 1.2em;
}

/* === Form Elements === */
input[type="text"],
input[type="email"],
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

textarea {
    resize: vertical;
    font-family: inherit;
}

/* === Button Styles === */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

/* Full width variant */
button.btn {
    width: 100%;
}

/* Inline link buttons */
a.btn {
    width: auto;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

/* Leave Game button specific styles */
#leave-game-btn {
    max-width: 120px;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.players-list {
    list-style: none;
    margin: 20px 0;
}

.players-list li {
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.players-list .host {
    font-weight: bold;
}

.players-list .host::after {
    content: "👑";
    margin-left: 5px;
}

.players-list .storyteller {
    background: #fff3cd;
}

.players-list .storyteller::after {
    content: "📖";
    margin-left: 5px;
}

.players-list .score {
    font-weight: bold;
    color: #667eea;
}

.info {
    color: #666;
    margin: 10px 0;
}

.error-message, .success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    display: none;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.error-message {
    background: #e74c3c;
}

.success-message {
    background: #27ae60;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Game Styles */
.game-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

.game-header {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.game-info span {
    margin-right: 30px;
    color: #666;
}

.game-info strong {
    color: #333;
}

.game-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.players-sidebar, .hand-sidebar {
    width: 250px;
    background: white;
    padding: 20px;
    overflow-y: auto;
}

.players-sidebar {
    border-right: 1px solid #e0e0e0;
}

.hand-sidebar {
    border-left: 1px solid #e0e0e0;
}

.game-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.clue-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.clue-section h2 {
    color: #764ba2;
}

.game-phase {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.game-phase h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.card-hand, .voting-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.card-item {
    cursor: pointer;
    transition: transform 0.3s;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: relative;
}

.card-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-item:hover {
    transform: scale(1.05);
}

.card-item.selected {
    border: 3px solid #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.card-item.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.card-buttons {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 5px;
    z-index: 2;
}

.card-preview-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #667eea;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.card-preview-btn:hover {
    background: #667eea;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.player-hand-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Persistent Hand Display */
.player-hand-persistent {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.player-hand-persistent h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

.hand-cards {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
}

.hand-cards .card-item {
    flex: 0 0 120px;
    height: 160px;
}

.hand-cards .card-item img {
    height: 130px;
    object-fit: cover;
}

.persistent-card {
    opacity: 0.9;
    transition: opacity 0.2s;
}

.persistent-card:hover {
    opacity: 1;
}

.player-hand-sidebar .card-item {
    height: 120px;
}

.player-hand-sidebar .card-item img {
    height: 100%;
}

.waiting-status {
    text-align: center;
    padding: 40px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    position: relative;
    margin: 5% auto;
    max-width: 600px;
    max-height: 80vh;
}

.modal-content img {
    width: 100%;
    height: auto;
    border-radius: 10px;
}

.close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #f1f1f1;
}

.results-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.result-card {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.result-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.result-card.storyteller-card {
    background: #d1ecf1;
    border: 2px solid #0c5460;
}

.storyteller-badge {
    color: #0c5460;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.submitter-info {
    margin: 5px 0;
    color: #333;
}

.voters-info {
    margin: 5px 0;
    color: #666;
}

.points-info {
    margin-top: 8px;
}

.points-info .points {
    color: #28a745;
    font-size: 1.2em;
}

.round-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.round-summary h4 {
    margin-top: 0;
    color: #333;
}

.scores-list {
    list-style: none;
    padding: 0;
}

.scores-list li {
    padding: 5px 0;
    font-size: 1.1em;
}

.vote-list {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

/* Active Rooms List */
.active-rooms-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 0;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.room-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.room-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.room-code {
    font-weight: bold;
    font-size: 1.2em;
    color: #667eea;
}

.room-players {
    color: #666;
}

.room-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
}

.status-waiting {
    background: #d4edda;
    color: #155724;
}

.status-playing {
    background: #fff3cd;
    color: #856404;
}

.room-full {
    color: #999;
    font-style: italic;
}

.btn-small {
    padding: 6px 16px;
    font-size: 0.9em;
}

/* Contact Page Styles */

.contact-intro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1.1rem;
}

.contact-form {
    background: rgba(0, 0, 0, 0.5);
    padding: 2rem;
    border-radius: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.contact-form .form-group {
    margin-bottom: 1.5rem;
}

.contact-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: white;
    font-weight: 500;
}

/* Override form elements for dark background */
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.contact-form input[type="text"]::placeholder,
.contact-form input[type="email"]::placeholder,
.contact-form textarea::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.contact-form input[type="text"]:focus,
.contact-form input[type="email"]:focus,
.contact-form textarea:focus {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.15);
}

.contact-form .btn-primary {
    width: 100%;
    margin-top: 1rem;
}

.form-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.form-message.success {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.5);
    color: #10b981;
    display: block;
}

.form-message.error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ef4444;
    display: block;
}

.back-link {
    text-align: center;
    margin-top: 2rem;
}