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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
}

header {
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 10px 0;
    text-align: center;
    width: 100%;
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
}

footer {
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    text-align: center;
    padding: 10px 0;
    width: 100%;
    margin-top: auto;
}

footer p {
    margin: 0;
    font-size: 0.9rem;
}

.game-container {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    margin: 20px auto;
    flex: 1;
    align-items: center;
    justify-content: center;
    touch-action: pan-x;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-info h1 {
    color: white;
    font-size: 2.5em;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.score-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score, .level {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    min-width: 120px;
}

.score span:first-child, .level span:first-child {
    font-size: 0.9em;
    margin-bottom: 5px;
}

.score span:last-child, .level span:last-child {
    font-size: 1.8em;
    font-weight: bold;
}

.game-board-container {
    position: relative;
}

#gameBoard {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    touch-action: none;
    cursor: pointer;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.next-section {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    color: white;
}

.next-section h3 {
    margin-bottom: 10px;
    text-align: center;
}

#nextBoard {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.8);
    display: block;
    margin: 0 auto;
}

.instructions {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    color: white;
    max-width: 200px;
}

.instructions h3 {
    margin-bottom: 10px;
    text-align: center;
}

.instructions ul {
    list-style: none;
}

.instructions li {
    margin-bottom: 5px;
    font-size: 0.9em;
}

.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;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: #333;
    margin-bottom: 15px;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.2em;
}

#restartBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: transform 0.2s;
}

#restartBtn:hover {
    transform: translateY(-2px);
}

.ranking-buttons {
    margin-top: 20px;
}

#showRankingBtn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
    width: 100%;
}

#showRankingBtn:hover {
    transform: translateY(-2px);
}

#nicknameInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 20px;
    text-align: center;
}

#nicknameInput:focus {
    outline: none;
    border-color: #667eea;
}

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

.modal-buttons button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
    min-width: 120px;
}

.modal-buttons button:hover {
    transform: translateY(-2px);
}

#skipRankingBtn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

.ranking-modal {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.ranking-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    color: #666;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

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

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ranking-content {
    min-height: 300px;
    text-align: left;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.ranking-table th,
.ranking-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.ranking-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #333;
}

.ranking-table tr:nth-child(even) {
    background: #f8f9fa;
}

.ranking-table tr:hover {
    background: #e9ecef;
}

.rank-number {
    font-weight: bold;
    color: #667eea;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.loading {
    text-align: center;
    color: #666;
    padding: 40px 0;
}

.no-data {
    text-align: center;
    color: #666;
    padding: 40px 0;
}

.ranking-message {
    color: #28a745;
    font-weight: bold;
    margin: 10px 0;
}

#closeRankingBtn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 20px;
}

#closeRankingBtn:hover {
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-info {
        order: 2;
        flex-direction: row;
        justify-content: center;
    }
    
    .controls {
        order: 3;
        flex-direction: row;
        justify-content: center;
    }
}