@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

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

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#app {
    width: 100%;
    max-width: 420px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.avatar-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.username {
    font-size: 12px;
    opacity: 0.9;
}

.scores {
    display: flex;
    gap: 10px;
}

.score-box {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    min-width: 80px;
}

.score-box.best {
    cursor: pointer;
    transition: transform 0.2s;
}

.score-box.best:hover {
    transform: scale(1.05);
}

.label {
    font-size: 10px;
    opacity: 0.8;
    font-weight: 600;
}

.value {
    font-size: 20px;
    font-weight: 700;
    margin-top: 2px;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 10px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.next-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    margin-bottom: 10px;
}

.next-label {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
}

.next-blocks {
    display: flex;
    gap: 8px;
    align-items: center;
}

.next-block {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.next-block.small {
    width: 40px;
    height: 40px;
    font-size: 16px;
    opacity: 0.7;
}

.drop-indicators {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    margin-bottom: 5px;
}

.drop-arrow {
    font-size: 24px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.drop-arrow.active {
    color: #667eea;
    transform: scale(1.3);
}

.drop-arrow:hover {
    color: #667eea;
    transform: scale(1.2);
}

#gameCanvas {
    display: block;
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    background: #2a2a3e;
    cursor: pointer;
}

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.game-over-text {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #fff;
}

.final-score {
    font-size: 24px;
    margin-bottom: 25px;
    color: #ffd93d;
}

.retry-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.retry-btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.primary {
    background: #667eea;
    color: white;
}

.primary:hover {
    background: #5568d3;
}

/* Block colors */
.block-2 {
    background: #ffadad;
}

.block-4 {
    background: #ffd6a5;
}

.block-8 {
    background: #fdffb6;
}

.block-16 {
    background: #caffbf;
}

.block-32 {
    background: #9bf6ff;
}

.block-64 {
    background: #a0c4ff;
}

.block-128 {
    background: #bdb2ff;
}

.block-256 {
    background: #ffc6ff;
}

.block-512 {
    background: #ff9770;
}

.block-1024 {
    background: #ffd60a;
}

.block-2048 {
    background: #00b4d8;
}

/* Modal styles */
.score-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: #fff;
    color: #333;
    border-radius: 16px;
    padding: 25px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    font-size: 22px;
    margin-bottom: 18px;
    text-align: center;
    color: #667eea;
}

.best-score-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.best-label {
    color: #fff;
    font-size: 13px;
    margin-bottom: 8px;
    opacity: 0.95;
}

.best-number {
    color: #fff;
    font-size: 38px;
    font-weight: 700;
}

.recent-scores-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    color: #667eea;
}

.no-scores {
    text-align: center;
    color: #999;
    padding: 20px 0;
}

.score-list {
    margin: 15px 0;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    gap: 10px;
}

.score-rank {
    font-size: 15px;
    font-weight: 600;
    color: #667eea;
    min-width: 30px;
}

.score-number {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    flex: 1;
}

.score-date {
    font-size: 12px;
    color: #999;
    min-width: 75px;
    text-align: right;
}

.close-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 18px;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #5568d3;
}