/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --secondary: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --info: #3b82f6;
    --gold: #fbbf24;
    
    --bg-dark: #1f2937;
    --bg-darker: #111827;
    --bg-card: #374151;
    --bg-light: #4b5563;
    
    --text-light: #f9fafb;
    --text-muted: #9ca3af;
    
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    color: var(--text-light);
    overflow: hidden;
}

#app {
    height: 100%;
    width: 100%;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    height: 100%;
    width: 100%;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen.hidden {
    display: none;
}

/* ===== MAIN MENU ===== */
.menu-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.logo h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 10px var(--gold); }
    to { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px var(--gold), 0 0 30px var(--primary); }
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.name-input {
    margin-bottom: 30px;
}

.name-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.name-input input {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid var(--bg-light);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-light);
    text-align: center;
    transition: border-color 0.3s;
}

.name-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-info {
    margin-top: 40px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-darker);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-light);
}

.btn-tertiary {
    background: var(--bg-card);
    color: var(--text-light);
    border: 2px solid var(--bg-light);
}

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

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary-dark) 100%);
    color: var(--bg-darker);
}

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

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.btn-large {
    padding: 18px 35px;
    font-size: 1.3rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.btn-icon:hover {
    opacity: 1;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 450px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid var(--bg-light);
    border-radius: var(--border-radius);
    background: var(--bg-dark);
    color: var(--text-light);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 5px;
    margin-bottom: 20px;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ===== ROOMS LIST ===== */
.rooms-container, .rankings-container, .tutorial-container {
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.rooms-container h2, .rankings-container h2, .tutorial-container h2 {
    margin-bottom: 20px;
}

.rooms-list, .rankings-list {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 10px;
}

.room-item:last-child {
    margin-bottom: 0;
}

.room-info {
    text-align: left;
}

.room-info .room-host {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 8px;
}

.ranking-position {
    font-size: 1.3rem;
    font-weight: bold;
    width: 40px;
    color: var(--gold);
}

.ranking-position.top-1 { color: #ffd700; }
.ranking-position.top-2 { color: #c0c0c0; }
.ranking-position.top-3 { color: #cd7f32; }

.ranking-name {
    flex: 1;
    text-align: left;
    margin-left: 10px;
}

.ranking-stats {
    text-align: right;
    font-size: 0.9rem;
}

.ranking-stats .points {
    color: var(--gold);
    font-weight: bold;
}

.loading {
    color: var(--text-muted);
    padding: 20px;
}

.no-rooms {
    color: var(--text-muted);
    padding: 30px;
    font-style: italic;
}

/* ===== TUTORIAL ===== */
.tutorial-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 20px;
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
}

.tutorial-section {
    margin-bottom: 25px;
}

.tutorial-section:last-child {
    margin-bottom: 0;
}

.tutorial-section h3 {
    color: var(--primary);
    margin-bottom: 10px;
}

.tutorial-section p, .tutorial-section li {
    color: var(--text-muted);
    line-height: 1.6;
}

.tutorial-section strong {
    color: var(--text-light);
}

.card-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-type {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: var(--bg-dark);
    border-radius: 8px;
}

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

/* ===== LOBBY ===== */
.lobby-container {
    max-width: 700px;
    width: 100%;
}

.lobby-header {
    text-align: center;
    margin-bottom: 20px;
}

.room-code {
    font-size: 1.3rem;
    margin-top: 10px;
}

.room-code span {
    background: var(--bg-card);
    padding: 8px 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 1.5rem;
    letter-spacing: 3px;
    color: var(--gold);
}

.players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.player-card {
    background: var(--bg-card);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    transition: transform 0.3s;
}

.player-card:hover {
    transform: scale(1.02);
}

.player-card.host {
    border: 2px solid var(--gold);
}

.player-card .player-avatar {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.player-card .player-name {
    font-weight: 600;
}

.player-card .host-badge {
    background: var(--gold);
    color: var(--bg-darker);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-top: 5px;
    display: inline-block;
}

.lobby-actions {
    text-align: center;
    margin-bottom: 20px;
}

#waiting-message {
    color: var(--text-muted);
    margin: 10px 0;
}

/* ===== CHAT ===== */
.chat-container {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 15px;
}

.chat-messages {
    height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.chat-message {
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.chat-message .sender {
    font-weight: 600;
    color: var(--primary);
}

.chat-message .text {
    color: var(--text-light);
}

.chat-message.system {
    color: var(--text-muted);
    font-style: italic;
}

.chat-message.emote {
    font-size: 1.5rem;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

.chat-input-container input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-light);
}

.chat-input-container input:focus {
    outline: 2px solid var(--primary);
}

.emote-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.emote-buttons.small {
    margin-top: 5px;
}

.emote-btn {
    background: var(--bg-dark);
    border: none;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.emote-btn:hover {
    transform: scale(1.2);
    background: var(--bg-light);
}

/* ===== GAME SCREEN ===== */
#game-screen.active {
    display: block;
    padding: 0;
}

.game-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-darker);
    border-bottom: 2px solid var(--bg-light);
}

.role-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-card);
}

.role-badge.miner {
    background: var(--success);
}

.role-badge.saboteur {
    background: var(--danger);
}

.turn-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#current-turn {
    font-weight: 600;
}

#deck-count {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.tools-status {
    display: flex;
    gap: 10px;
}

.tool {
    font-size: 1.5rem;
    padding: 5px;
    border-radius: 8px;
    background: var(--bg-card);
    transition: all 0.3s;
}

.tool.broken {
    filter: grayscale(100%);
    opacity: 0.5;
    position: relative;
}

.tool.broken::after {
    content: '✕';
    position: absolute;
    color: var(--danger);
    font-size: 1rem;
}

/* ===== GAME MAIN AREA ===== */
.game-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.board-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(9, 70px);
    grid-template-rows: repeat(5, 70px);
    gap: 3px;
    background: var(--bg-darker);
    padding: 10px;
    border-radius: var(--border-radius);
}

.board-cell {
    width: 70px;
    height: 70px;
    background: var(--bg-card);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.board-cell:hover {
    background: var(--bg-light);
}

.board-cell.valid-target {
    background: rgba(16, 185, 129, 0.3);
    border: 2px dashed var(--success);
}

.board-cell.start {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.board-cell.goal {
    background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
}

.board-cell.goal.revealed-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary-dark) 100%);
}

.board-cell.goal.revealed-rock {
    background: linear-gradient(135deg, var(--secondary) 0%, #4b5563 100%);
}

/* Tunnel visualization */
.tunnel-card {
    width: 100%;
    height: 100%;
    position: relative;
}

.tunnel-path {
    position: absolute;
    background: #78350f;
    border: 2px solid #92400e;
}

.tunnel-path.horizontal {
    height: 20px;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
}

.tunnel-path.vertical {
    width: 20px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.tunnel-path.top {
    width: 20px;
    height: 50%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

.tunnel-path.bottom {
    width: 20px;
    height: 50%;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
}

.tunnel-path.left {
    height: 20px;
    width: 50%;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.tunnel-path.right {
    height: 20px;
    width: 50%;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}

.tunnel-center {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #78350f;
    border: 2px solid #92400e;
    border-radius: 4px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.dead-end-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    z-index: 2;
}

/* ===== PLAYERS PANEL ===== */
.players-panel {
    width: 200px;
    background: var(--bg-darker);
    padding: 15px;
    overflow-y: auto;
    border-left: 2px solid var(--bg-light);
}

.game-player-card {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.game-player-card.current-turn {
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.game-player-card.me {
    background: var(--bg-light);
}

.game-player-name {
    font-weight: 600;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.game-player-tools {
    display: flex;
    gap: 5px;
    font-size: 0.9rem;
}

.game-player-tools .tool {
    font-size: 1rem;
    padding: 2px;
}

.game-player-cards {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ===== PLAYER HAND ===== */
.hand-container {
    background: var(--bg-darker);
    padding: 15px 20px;
    border-top: 2px solid var(--bg-light);
}

.hand-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

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

.hand-card {
    min-width: 90px;
    height: 120px;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid transparent;
}

.hand-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.hand-card.selected {
    border-color: var(--primary);
    transform: translateY(-10px);
}

.hand-card.rotated {
    transform: rotate(180deg);
}

.hand-card.selected.rotated {
    transform: rotate(180deg) translateY(10px);
}

.hand-card .card-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.hand-card .card-name {
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-muted);
}

.hand-card.tunnel .card-preview {
    width: 50px;
    height: 50px;
    position: relative;
    margin-bottom: 5px;
}

.hand-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ===== GAME CHAT ===== */
.game-chat-toggle {
    position: fixed;
    bottom: 200px;
    right: 20px;
}

.game-chat-panel {
    position: fixed;
    bottom: 250px;
    right: 20px;
    width: 300px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow-lg);
}

.game-chat-panel.hidden {
    display: none;
}

.game-chat-panel .chat-messages {
    height: 150px;
}

/* ===== GAME END MODAL ===== */
.game-end-content {
    max-width: 500px;
}

#game-end-title {
    font-size: 2rem;
}

#game-end-message {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-muted);
}

.game-end-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.result-card {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.result-card.winner {
    border: 2px solid var(--gold);
    background: rgba(251, 191, 36, 0.1);
}

.result-card .result-name {
    font-weight: 600;
    margin-bottom: 5px;
}

.result-card .result-role {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-card .result-role.miner {
    color: var(--success);
}

.result-card .result-role.saboteur {
    color: var(--danger);
}

/* ===== MAP MODAL ===== */
.map-targets {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.map-target {
    width: 80px;
    height: 80px;
    background: var(--bg-dark);
    border: 3px solid var(--bg-light);
    border-radius: var(--border-radius);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.map-target:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.map-result {
    font-size: 4rem;
    padding: 30px;
}

.map-result.gold::after {
    content: ' Złoto!';
    font-size: 1.5rem;
    color: var(--gold);
}

.map-result.rock::after {
    content: ' Kamień...';
    font-size: 1.5rem;
    color: var(--secondary);
}

/* ===== PLAYER SELECT ===== */
.player-select-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.player-select-btn {
    padding: 15px;
    background: var(--bg-dark);
    border: 2px solid var(--bg-light);
    border-radius: 8px;
    color: var(--text-light);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-select-btn:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.player-select-btn .player-tools {
    display: flex;
    gap: 5px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 350px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--info);
}

.toast.warning {
    border-left: 4px solid var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-main {
        flex-direction: column;
    }
    
    .players-panel {
        width: 100%;
        height: 100px;
        border-left: none;
        border-top: 2px solid var(--bg-light);
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }
    
    .game-player-card {
        min-width: 150px;
        margin-right: 10px;
        margin-bottom: 0;
    }
    
    .game-board {
        grid-template-columns: repeat(9, 50px);
        grid-template-rows: repeat(5, 50px);
    }
    
    .board-cell {
        width: 50px;
        height: 50px;
    }
    
    .hand-card {
        min-width: 70px;
        height: 100px;
    }
    
    .game-chat-panel {
        width: calc(100% - 40px);
        bottom: 220px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}
