/* Detective Conan Game Styles */
:root {
    --primary-color: #1a365d;
    --secondary-color: #2d3748;
    --accent-color: #3182ce;
    --danger-color: #e53e3e;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-light: #ffffff;
    --bg-primary: #f7fafc;
    --bg-secondary: #edf2f7;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --detective-blue: #1e40af;
    --detective-red: #dc2626;
    --detective-gold: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 2rem;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Main Menu */
.main-container {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.game-header {
    margin-bottom: 3rem;
}

.game-title {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-title i {
    color: var(--detective-gold);
    margin-right: 0.5rem;
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--bg-secondary);
    opacity: 0.9;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-btn.primary {
    background: var(--detective-blue);
    color: white;
    box-shadow: var(--shadow);
}

.menu-btn.primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.menu-btn.secondary {
    background: var(--detective-red);
    color: white;
    box-shadow: var(--shadow);
}

.menu-btn.secondary:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.menu-btn.tertiary {
    background: var(--detective-gold);
    color: var(--primary-color);
    box-shadow: var(--shadow);
}

.menu-btn.tertiary:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Form Containers */
.form-container,
.join-container,
.rules-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
}

.form-container h2,
.join-container h2,
.rules-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.form-container h2 i,
.join-container h2 i,
.rules-container h2 i {
    margin-right: 0.5rem;
    color: var(--accent-color);
}

/* Input Groups */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-group input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: var(--accent-color);
    background: var(--accent-color);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn.primary {
    background: var(--detective-blue);
    color: white;
}

.btn.primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn.secondary:hover {
    background: var(--border-color);
}

.btn.danger {
    background: var(--danger-color);
    color: white;
}

.btn.danger:hover {
    background: #c53030;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Tabs */
.join-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Rooms List */
.rooms-list {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.room-item {
    display: flex;
    justify-content: between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.room-item:hover {
    background: var(--border-color);
    transform: translateX(4px);
}

.room-item:last-child {
    margin-bottom: 0;
}

.room-item-info h4 {
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.room-item-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.room-item-players {
    font-weight: 600;
    color: var(--accent-color);
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.loading i {
    margin-right: 0.5rem;
}

/* Room Screen */
.room-container {
    max-width: 1200px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.room-header {
    background: var(--primary-color);
    color: var(--text-light);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-info h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.room-info p {
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.room-code {
    font-size: 0.9rem;
}

.room-code code {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.room-actions {
    display: flex;
    gap: 1rem;
}

.room-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
}

/* Players Section */
.players-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.players-list {
    display: grid;
    gap: 0.75rem;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.player-item:hover {
    background: var(--border-color);
}

.player-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.player-info h4 {
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.player-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.player-item.admin .player-avatar {
    background: var(--detective-gold);
    color: var(--primary-color);
}

/* Chat Section */
.chat-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.chat-messages {
    height: 300px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    padding: 1rem;
    background: var(--bg-primary);
}

.chat-message {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-radius: 6px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message.system {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

.chat-message .message-author {
    font-weight: 600;
    color: var(--accent-color);
    margin-right: 0.5rem;
}

.chat-message .message-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    float: right;
}

.chat-input {
    display: flex;
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.chat-input input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    font-size: 1rem;
}

.chat-input input:focus {
    outline: none;
}

.chat-input button {
    padding: 0.75rem 1rem;
    border: none;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
}

.chat-input button:hover {
    background: #2c5aa0;
}

/* Game Screen */
.game-container {
    max-width: 1400px;
    width: 100%;
    height: 100vh;
    display: grid;
    grid-template-areas: 
        "header header header"
        "role players chat"
        "actions players voting";
    grid-template-columns: 300px 1fr 350px;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
}

.game-header {
    grid-area: header;
    background: var(--bg-card);
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.phase-info {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.phase {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.phase.day {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: var(--primary-color);
}

.phase.night {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    color: white;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--danger-color);
}

.game-status {
    display: flex;
    gap: 2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Player Panel */
.player-panel {
    grid-area: role;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.role-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.role-avatar {
    height: 120px;
    background: linear-gradient(135deg, var(--detective-blue), var(--accent-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.role-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.role-info {
    padding: 1rem;
}

.role-info h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.role-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.role-faction {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-faction.good {
    background: var(--success-color);
    color: white;
}

.role-faction.evil {
    background: var(--danger-color);
    color: white;
}

.role-faction.neutral {
    background: var(--warning-color);
    color: var(--primary-color);
}

.action-panel {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.action-panel h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#actionButtons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--detective-blue);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.action-btn:disabled {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

/* Game Players List */
.game-players {
    grid-area: players;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1rem;
    overflow-y: auto;
}

.game-players h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-align: center;
}

.game-players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.game-player-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.game-player-card:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.game-player-card.dead {
    opacity: 0.6;
    background: #fee2e2;
    color: var(--danger-color);
}

.game-player-card.selected {
    border-color: var(--accent-color);
    background: rgba(49, 130, 206, 0.1);
}

.game-player-card .player-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.game-player-card .player-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.game-player-card.dead .player-status::before {
    content: "💀 ";
}

/* Game Chat */
.game-chat {
    grid-area: chat;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#gameChatMessages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    max-height: 400px;
}

/* Voting Panel */
.voting-panel {
    grid-area: voting;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.voting-panel h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    text-align: center;
}

.voting-panel p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.voting-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.vote-option {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vote-option:hover {
    border-color: var(--accent-color);
    background: rgba(49, 130, 206, 0.1);
}

.vote-option.selected {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: white;
}

.vote-count {
    font-weight: 600;
    font-size: 0.9rem;
}

.voting-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Rules Screen */
.rules-container {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.rules-content {
    margin-bottom: 2rem;
}

.rules-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.rules-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.rules-section h4 {
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rules-section ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.rules-section li {
    margin-bottom: 0.5rem;
}

.faction {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.faction.good {
    background: rgba(56, 161, 105, 0.1);
    border-left-color: var(--success-color);
}

.faction.evil {
    background: rgba(229, 62, 62, 0.1);
    border-left-color: var(--danger-color);
}

.faction.neutral {
    background: rgba(214, 158, 46, 0.1);
    border-left-color: var(--warning-color);
}

.phase-rule {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content {
    padding: 2rem;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#gameEndContent {
    margin-bottom: 2rem;
}

.winner-announcement {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
}

.winner-announcement.good {
    background: rgba(56, 161, 105, 0.2);
    color: var(--success-color);
}

.winner-announcement.evil {
    background: rgba(229, 62, 62, 0.2);  
    color: var(--danger-color);
}

.winner-announcement.neutral {
    background: rgba(214, 158, 46, 0.2);
    color: var(--warning-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-container {
        grid-template-areas: 
            "header header"
            "role chat"
            "players players"
            "actions voting";
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto 1fr auto;
    }

    .room-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .screen {
        padding: 1rem;
    }

    .game-title {
        font-size: 2rem;
    }

    .menu-options {
        gap: 0.75rem;
    }

    .menu-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .form-container,
    .join-container,
    .rules-container {
        padding: 1.5rem;
        margin: 0 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .room-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .room-actions {
        justify-content: center;
    }

    .game-container {
        grid-template-areas: 
            "header"
            "role"
            "actions"
            "players"
            "chat"
            "voting";
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto 1fr auto auto;
        height: auto;
        min-height: 100vh;
    }

    .game-players-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .phase-info {
        gap: 1rem;
    }

    .game-status {
        gap: 1rem;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }

    .form-container,
    .join-container,
    .rules-container {
        padding: 1rem;
    }

    .radio-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .game-players-list {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.screen.active {
    animation: fadeIn 0.5s ease-out;
}

.chat-message {
    animation: slideIn 0.3s ease-out;
}

.game-player-card:hover {
    animation: bounce 0.6s ease-in-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2c5aa0;
}