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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

.screen {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-container h1 {
    color: #4a9eff;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    text-align: center;
}

#login-form {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* User Selection Screen */
.user-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
}

.user-btn {
    padding: 1rem 2rem;
    border: 2px solid #4a9eff;
    border-radius: 8px;
    background-color: transparent;
    color: #4a9eff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-btn:hover {
    background-color: #4a9eff;
    color: white;
    transform: translateY(-2px);
}

/* Header updates */
.header-info {
    display: flex;
    align-items: center;
}

.current-user {
    background-color: #4a9eff;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}


/* Header */
header {
    background-color: #2a2a2a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header h1 {
    color: #4a9eff;
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Search */
.search-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

#search-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #444;
    border-radius: 8px;
    background-color: #333;
    color: #e0e0e0;
    font-size: 1rem;
}

#search-input:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* Restaurants Grid */
.restaurants-grid {
    padding: 0 2rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.restaurant-card {
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.restaurant-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Collapsible Restaurant Cards */
.restaurant-header.clickable {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid #444;
    margin-bottom: 1rem;
}

.restaurant-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.restaurant-rating-summary .restaurant-rating.compact {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
}

.restaurant-rating-summary .restaurant-rating.compact .average-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.expand-icon {
    color: #4a9eff;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.restaurant-card .restaurant-header.clickable:hover .expand-icon {
    transform: scale(1.1);
}

.restaurant-details {
    overflow: hidden;
    transition: all 0.3s ease;
}

.restaurant-details.collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

.restaurant-details:not(.collapsed) {
    max-height: 2000px;
    margin-top: 0;
    opacity: 1;
}

/* Move actions to details section */
.restaurant-details .restaurant-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: flex-end;
}

/* Old restaurant-header style removed - now using .restaurant-header.clickable */

.restaurant-name {
    color: #4a9eff;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

/* Old restaurant-actions styles moved to .restaurant-details .restaurant-actions */

.restaurant-actions button {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.restaurant-actions button:hover {
    color: #e0e0e0;
}

.restaurant-location {
    color: #aaa;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.restaurant-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background-color: #444;
    color: #e0e0e0;
    padding: 0.25rem 0.5rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
}

.restaurant-rating {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: #333;
    border-radius: 8px;
}

.average-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #4a9eff;
}

.rating-stars {
    color: #ffd700;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.member-ratings {
    display: flex;
    gap: 1rem;
}

.member-rating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.member-name {
    font-size: 0.8rem;
    color: #aaa;
}

.rating-input {
    width: 60px;
    padding: 0.25rem;
    border: 1px solid #555;
    border-radius: 4px;
    background-color: #444;
    color: #e0e0e0;
    text-align: center;
    font-size: 0.9rem;
}

.rating-input:focus {
    outline: none;
    border-color: #4a9eff;
}

/* Current User Rating Section */
.current-user-rating {
    margin: 1rem 0;
    padding: 1rem;
    background-color: #333;
    border-radius: 8px;
    border: 2px solid #4a9eff;
}

.rating-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.save-rating-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s ease;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.save-rating-btn:hover {
    background: #45a049;
    transform: scale(1.05);
}

.rating-label {
    font-weight: 600;
    color: #4a9eff;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.current-rating {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid #4a9eff;
    border-radius: 6px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
}

.current-rating:focus {
    outline: none;
    border-color: #3d8ce6;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

/* Other Members Ratings */
.other-member-ratings {
    margin-top: 1rem;
}

.other-ratings-title {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.member-rating.readonly {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background-color: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.member-rating.readonly .member-name {
    font-size: 0.85rem;
    color: #ccc;
}

.member-score {
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a9eff;
}

/* Locked Rating State */
.restaurant-rating.locked {
    filter: blur(2px);
    opacity: 0.7;
    position: relative;
}

.restaurant-rating.locked .rating-stars {
    color: #666;
}

/* Locked Ratings Message */
.locked-ratings {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
}

.locked-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    text-align: center;
}

.lock-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.locked-message span:last-child {
    font-size: 0.9rem;
    font-style: italic;
}

.restaurant-visits {
    margin-top: 1rem;
}

.visits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.visits-title {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.visit-item {
    background-color: #333;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.visit-info {
    flex: 1;
}

.visit-date-time {
    color: #4a9eff;
    font-weight: 500;
    font-size: 0.9rem;
}

.visit-amount {
    color: #90ee90;
    font-weight: 500;
    font-size: 0.9rem;
}

.visit-notes {
    color: #aaa;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.visit-delete {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.visit-delete:hover {
    background-color: rgba(255, 107, 107, 0.1);
}

.restaurant-notes {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #333;
    border-radius: 6px;
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #4a9eff;
    color: white;
}

.btn-primary:hover {
    background-color: #3d8ce6;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #555;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background-color: #666;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

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

.btn-danger:hover {
    background-color: #ff5252;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #2a2a2a;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #444;
}

.modal-header h2 {
    color: #4a9eff;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.close-btn:hover {
    color: #e0e0e0;
}

/* Forms */
form {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #e0e0e0;
    font-weight: 500;
    font-size: 0.95rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #444;
    border-radius: 6px;
    background-color: #333;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Visit Form Grid */
.visit-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 1rem;
}

.form-group-full {
    grid-column: 1 / -1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: #4a9eff;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1001;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95rem;
    max-width: 300px;
    word-wrap: break-word;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background-color: #dc3545;
    color: white;
    border-left: 4px solid #fff;
}

.toast.success {
    background-color: #28a745;
    color: white;
    border-left: 4px solid #fff;
}

/* Loading */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    z-index: 1002;
}

/* Error Messages */
.error {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #888;
}

.empty-state h3 {
    margin-bottom: 1rem;
    color: #aaa;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-info {
        order: 1;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        order: 2;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .search-container {
        padding: 1rem;
    }

    .restaurants-grid {
        padding: 0 1rem 1rem;
        grid-template-columns: 1fr;
    }

    .restaurant-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .restaurant-details .restaurant-actions {
        justify-content: center;
    }

    .member-ratings {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .visit-form-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container h1 {
        font-size: 2rem;
    }
    
    .restaurant-card {
        padding: 1rem;
    }
    
    .restaurant-rating {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .average-rating {
        align-self: center;
    }
}

/* Game Styles */
.btn-game {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(247, 147, 30, 0.3);
    white-space: nowrap;
}

.btn-game:hover {
    background: linear-gradient(135deg, #e55a2b, #e8851a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(247, 147, 30, 0.4);
}

.modal-wide {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.game-phase {
    animation: fadeIn 0.3s ease;
}

.predictions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 1rem 0;
}

.prediction-item {
    background: #2a2a2a;
    padding: 0.75rem;
    border-radius: 6px;
    border: 2px solid #333;
}

.prediction-item.current-user {
    border-color: #4a9eff;
    background: #1e2a3a;
}

.prediction-item h4 {
    color: #4a9eff;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
}

.prediction-item input {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    padding: 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.prediction-item input:focus {
    border-color: #4a9eff;
    outline: none;
}

.predictions-summary {
    background: #2a2a2a;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.predictions-summary h4 {
    color: #4a9eff;
    margin-bottom: 1rem;
}

.prediction-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #333;
}

.prediction-display:last-child {
    border-bottom: none;
}

.prediction-display .member-name {
    font-weight: 500;
}

.prediction-display .prediction-amount {
    color: #4a9eff;
    font-weight: bold;
}

.game-results {
    margin-bottom: 2rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin: 0.5rem 0;
    background: #2a2a2a;
    border-radius: 8px;
    border-left: 4px solid #444;
}

.result-item.winner {
    background: #1e3a1e;
    border-left-color: #4caf50;
}

.result-item.winner .member-name {
    color: #4caf50;
    font-weight: bold;
}

.result-item .difference {
    color: #888;
    font-size: 0.9rem;
}

.result-item.winner .difference {
    color: #4caf50;
}

.crown-icon {
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

.crowns-leaderboard {
    background: #2a2a2a;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.crowns-leaderboard h4 {
    color: #4a9eff;
    margin-bottom: 1rem;
    text-align: center;
}

.crown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: #1a1a1a;
    border-radius: 6px;
}

.crown-item.top {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #1a1a1a;
}

.crown-item.top .member-name {
    font-weight: bold;
}

.crown-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: bold;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .predictions-grid {
        grid-template-columns: 1fr;
    }

    .modal-wide {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }
    
    .header-actions button {
        font-size: 0.75rem;
        padding: 0.5rem;
        min-width: auto;
    }
    
    .btn-game {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}