/* ===== RESET E VARIÁVEIS ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0f0e17;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text-primary: #fffffe;
    --text-secondary: #a7a9be;
    --accent: #ff8906;
    --success: #0fdb7a;
    --danger: #ff6b6b;
    --info: #4cc9f0;
    --gold: #ffd700;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    
    --color-red: #ff4757;
    --color-blue: #3742fa;
    --color-green: #2ed573;
    --color-yellow: #ffa502;
    --color-purple: #a29bfe;
    --color-pink: #ff6b81;
    --color-cyan: #0abde3;
    --color-orange: #ff6348;
    --color-teal: #0be881;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ===== GLASSMORPHISM ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
}

/* ===== WRAPPER ===== */
.game-wrapper {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100%;
    padding: 6px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== PARTICLES ===== */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    opacity: 0.2;
    animation: float-particle linear infinite;
}

@keyframes float-particle {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.2; }
    90% { opacity: 0.2; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* ===== HEADER ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    margin-bottom: 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: white;
    box-shadow: 0 4px 12px rgba(255, 137, 6, 0.3);
}

.game-title {
    font-size: 0.85rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    gap: 3px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 14px;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-badge i {
    color: var(--accent);
    font-size: 0.5rem;
}

/* ===== WELCOME ===== */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
    overflow-y: auto;
}

.welcome-content {
    text-align: center;
    max-width: 360px;
    width: 100%;
}

.welcome-animation {
    margin-bottom: 8px;
}

.block-animation {
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 1.8rem;
    animation: bounce-blocks 2s ease-in-out infinite;
}

.block-emoji {
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.block-emoji:nth-child(1) { animation-delay: 0s; }
.block-emoji:nth-child(2) { animation-delay: 0.4s; }
.block-emoji:nth-child(3) { animation-delay: 0.8s; }
.block-emoji:nth-child(4) { animation-delay: 1.2s; }
.block-emoji:nth-child(5) { animation-delay: 1.6s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    50% { transform: translateY(-8px) rotate(15deg) scale(1.1); }
}

@keyframes bounce-blocks {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.welcome-title {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 2px;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 8px;
    font-weight: 400;
}

/* ===== FORM ===== */
.player-form {
    padding: 8px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 10px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.6;
    z-index: 2;
}

.form-input {
    width: 100%;
    padding: 7px 8px 7px 32px;
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 137, 6, 0.05);
    box-shadow: 0 0 0 4px rgba(255, 137, 6, 0.1);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* ===== HOW TO PLAY ===== */
.how-to-play {
    padding: 6px 10px;
    margin-bottom: 6px;
    text-align: left;
}

.how-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.how-icon {
    font-size: 0.9rem;
    min-width: 20px;
}

/* ===== BOTÕES DO WELCOME ===== */
.welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.welcome-buttons button {
    min-height: 44px;
    padding: 10px;
    font-size: 0.9rem;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.btn-start {
    position: relative;
    overflow: hidden;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 137, 6, 0.3);
    min-height: 48px;
}

.btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    animation: glow-rotate 4s linear infinite;
    z-index: 1;
}

@keyframes glow-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.btn-start:active {
    transform: scale(0.95);
}

.btn-ranking {
    padding: 10px;
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gold);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.btn-ranking:active {
    transform: scale(0.95);
    background: rgba(255, 215, 0, 0.15);
}

.btn-back {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.btn-back:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.08);
}

/* ===== GAME CONTAINER ===== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2px 0;
    min-height: 0;
    max-height: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.game-layout {
    display: flex;
    gap: 6px;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

/* ===== GAME AREA ===== */
.game-area {
    flex: 1;
    display: flex;
    gap: 6px;
    min-height: 0;
    max-height: 100%;
}

/* ===== GAME BOARD WRAPPER ===== */
.game-board-wrapper {
    flex: 1;
    padding: 4px;
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    position: relative;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1.5px;
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 0.65;
    padding: 2px;
}

/* ===== CELLS - BLOCOS MENORES ===== */
.cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: none;
    position: relative;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.cell.filled {
    border-color: rgba(255, 255, 255, 0.06);
}

.cell .block {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    transition: none;
    display: block;
    position: relative;
}

/* Cores dos blocos */
.block-red { background: var(--color-red); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(255,71,87,0.3); }
.block-blue { background: var(--color-blue); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(55,66,250,0.3); }
.block-green { background: var(--color-green); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(46,213,115,0.3); }
.block-yellow { background: var(--color-yellow); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(255,165,2,0.3); }
.block-purple { background: var(--color-purple); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(162,155,254,0.3); }
.block-pink { background: var(--color-pink); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(255,107,129,0.3); }
.block-cyan { background: var(--color-cyan); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(10,189,227,0.3); }
.block-orange { background: var(--color-orange); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(255,99,72,0.3); }
.block-teal { background: var(--color-teal); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 2px 8px rgba(11,232,129,0.3); }

/* ===== SIDE PANEL ===== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 50px;
    flex-shrink: 0;
    max-height: 100%;
    overflow: hidden;
}

.next-piece {
    padding: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.next-label {
    font-size: 0.45rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.next-piece-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.next-piece-grid .cell {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1px;
}

.next-piece-grid .cell.filled {
    background: transparent;
    border-color: transparent;
}

/* ===== GAME INFO ===== */
.game-info {
    padding: 3px 5px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-height: 0;
    overflow: hidden;
}

.player-badge {
    font-size: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 3px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1px;
}

.player-badge i {
    color: var(--accent);
    font-size: 0.55rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.5rem;
    color: var(--text-secondary);
    padding: 0.5px 0;
}

.score-row span:last-child {
    color: var(--text-primary);
    font-weight: 700;
}

/* ===== CONTROLES - CORRIGIDO PARA MOBILE ===== */
.game-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    gap: 4px;
    margin-top: 3px;
    flex-shrink: 0;
    padding: 4px 2px;
    background: rgba(15, 14, 23, 0.95);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 10;
    border: 1px solid var(--glass-border);
}

.game-controls button {
    padding: 6px 4px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    width: 100%;
}

.game-controls button:active {
    transform: scale(0.88);
}

.btn-left {
    background: rgba(76, 201, 240, 0.2);
    color: var(--info);
    border: 1px solid rgba(76, 201, 240, 0.2);
}

.btn-right {
    background: rgba(76, 201, 240, 0.2);
    color: var(--info);
    border: 1px solid rgba(76, 201, 240, 0.2);
}

.btn-rotate {
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    color: white;
    font-size: 1rem;
    box-shadow: 0 2px 12px rgba(255, 137, 6, 0.3);
}

.btn-drop {
    background: linear-gradient(135deg, var(--success), #27ae60);
    color: white;
    font-size: 1rem;
    box-shadow: 0 2px 12px rgba(15, 219, 122, 0.3);
}

.btn-reset {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.2);
    font-size: 1rem;
}

/* ===== VICTORY - CORRIGIDO ===== */
.victory-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 20;
    padding: 14px;
    animation: fadeIn 0.4s ease;
}

.victory-content {
    max-width: 300px;
    width: 100%;
    padding: 16px 14px;
    text-align: center;
    animation: victory-bounce 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes victory-bounce {
    0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
    60% { transform: scale(1.05) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.victory-animation {
    margin-bottom: 4px;
}

.confetti {
    font-size: 1.4rem;
    display: flex;
    justify-content: center;
    gap: 4px;
    animation: confetti-float 2s ease-in-out infinite;
}

@keyframes confetti-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(8deg); }
}

.victory-icon-wrapper {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--gold), #ff6b6b);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
}

.victory-icon {
    font-size: 1.5rem;
    color: white;
}

.victory-title {
    font-size: 1.3rem;
    font-weight: 900;
    margin-bottom: 2px;
    background: linear-gradient(135deg, var(--gold), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-text {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.victory-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 6px;
}

.victory-stat {
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.victory-stat.highlight {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.06);
}

.victory-stat .stat-label {
    display: block;
    font-size: 0.45rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.victory-stat .stat-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--accent);
}

.victory-stat.highlight .stat-value {
    color: var(--gold);
}

.victory-message {
    color: var(--text-secondary);
    font-size: 0.65rem;
    margin-bottom: 6px;
}

/* ===== VICTORY BUTTONS - BOTÃO ÚNICO CENTRALIZADO ===== */
.victory-buttons {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}

.victory-buttons button {
    padding: 10px 30px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    min-height: 44px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    flex: 1;
    max-width: 200px;
}

/* ===== BOTÃO RANKING NA TELA DE VITÓRIA ===== */
.victory-content .btn-ranking {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gold);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.victory-content .btn-ranking:active {
    transform: scale(0.95);
    background: rgba(255, 215, 0, 0.15);
}

.btn-store {
    background: var(--info);
    color: var(--text);
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    min-height: 40px;
}

.btn-store:active {
    transform: scale(0.95);
}

/* ===== RANKING ===== */
.ranking-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 25;
    padding: 10px;
    animation: fadeIn 0.3s ease;
}

.ranking-content {
    max-width: 360px;
    width: 100%;
    max-height: 85vh;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.ranking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--glass-border);
}

.ranking-title-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ranking-title-wrapper i {
    color: var(--gold);
    font-size: 1rem;
}

.ranking-title-wrapper h2 {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-primary);
}

.btn-close-ranking {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.btn-close-ranking:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}

.ranking-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 6px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item .posicao {
    font-weight: 800;
    min-width: 22px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.ranking-item .posicao.top1 { color: #ffd700; }
.ranking-item .posicao.top2 { color: #c0c0c0; }
.ranking-item .posicao.top3 { color: #cd7f32; }

.ranking-item .jogador {
    flex: 1;
}

.ranking-item .jogador .nome {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--text-primary);
}

.ranking-item .jogador .detalhes {
    font-size: 0.5rem;
    color: var(--text-secondary);
}

.ranking-item .pontos {
    font-weight: 800;
    color: var(--gold);
    font-size: 0.75rem;
}

.btn-back-ranking {
    padding: 10px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 44px;
}

.btn-back-ranking:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.08);
}

/* ===== LOADING ===== */
.loading-ranking {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
}

.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.06);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 6px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== FOOTER ===== */
.game-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.45rem;
    padding: 3px 0 2px 0;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    margin-top: 2px;
    padding-bottom: calc(2px + var(--safe-bottom));
    position: relative;
    z-index: 1;
}

.game-footer span {
    color: var(--accent);
    font-weight: 600;
}

/* ===== ANIMAÇÕES ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

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

.ranking-item:nth-child(1) { animation-delay: 0.03s; }
.ranking-item:nth-child(2) { animation-delay: 0.06s; }
.ranking-item:nth-child(3) { animation-delay: 0.09s; }
.ranking-item:nth-child(4) { animation-delay: 0.12s; }
.ranking-item:nth-child(5) { animation-delay: 0.15s; }
.ranking-item:nth-child(6) { animation-delay: 0.18s; }
.ranking-item:nth-child(7) { animation-delay: 0.21s; }
.ranking-item:nth-child(8) { animation-delay: 0.24s; }
.ranking-item:nth-child(9) { animation-delay: 0.27s; }
.ranking-item:nth-child(10) { animation-delay: 0.30s; }

/* ============================================
   RESPONSIVO - MOBILE FIRST
   ============================================ */

/* ===== TELAS MUITO PEQUENAS (iPhone SE, etc) ===== */
@media (max-width: 380px) {
    .game-wrapper { padding: 2px; border-radius: 10px; }
    .game-title { font-size: 0.55rem; }
    .logo-icon { width: 18px; height: 18px; font-size: 0.45rem; }
    .stat-badge { font-size: 0.35rem; padding: 1px 3px; }
    .game-header { padding: 2px 6px; margin-bottom: 2px; }
    .game-layout { gap: 3px; }
    .side-panel { min-width: 30px; }
    .next-piece-grid { width: 24px; height: 24px; }
    .next-label { font-size: 0.35rem; }
    .game-info { padding: 2px 3px; }
    .score-row { font-size: 0.35rem; }
    .player-badge { font-size: 0.4rem; }
    .game-board { gap: 1px; padding: 1px; aspect-ratio: 0.55; }
    .game-board-wrapper { padding: 2px; }
    .game-controls { gap: 3px; padding: 3px 2px; }
    .game-controls button { min-height: 32px; font-size: 0.65rem; padding: 4px 2px; border-radius: 8px; }
    .game-controls button i { font-size: 0.7rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.8rem; }
    .welcome-title { font-size: 1rem; }
    .welcome-subtitle { font-size: 0.6rem; }
    .how-item { font-size: 0.5rem; }
    .player-form { padding: 4px; gap: 2px; }
    .form-input { padding: 4px 6px 4px 24px; font-size: 0.6rem; }
    .welcome-buttons button { min-height: 36px; padding: 8px; font-size: 0.75rem; }
    .btn-start { min-height: 40px; font-size: 0.8rem; }
    .btn-ranking, .btn-back { min-height: 36px; font-size: 0.7rem; }
    .victory-content { padding: 12px 10px; }
    .victory-title { font-size: 1rem; }
    .victory-stat .stat-value { font-size: 0.7rem; }
    .victory-buttons button { min-height: 32px; font-size: 0.6rem; padding: 6px; }
    .victory-buttons { gap: 4px; }
    .victory-buttons button { padding: 8px 20px; font-size: 0.65rem; max-width: 150px; }
}

/* ===== TELAS PEQUENAS (até 400px) ===== */
@media (max-width: 400px) {
    .game-wrapper { padding: 3px; border-radius: 12px; }
    .game-title { font-size: 0.65rem; }
    .logo-icon { width: 20px; height: 20px; font-size: 0.55rem; }
    .stat-badge { font-size: 0.4rem; padding: 1px 4px; }
    .game-layout { gap: 3px; }
    .side-panel { min-width: 35px; }
    .next-piece-grid { width: 28px; height: 28px; }
    .game-info { padding: 2px 3px; }
    .score-row { font-size: 0.4rem; }
    .game-board { gap: 1px; padding: 1px; aspect-ratio: 0.6; }
    .game-board-wrapper { padding: 2px; }
    .game-controls { gap: 3px; padding: 3px 2px; }
    .game-controls button { min-height: 36px; font-size: 0.7rem; padding: 4px 2px; border-radius: 8px; }
    .game-controls button i { font-size: 0.75rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.85rem; }
    .welcome-title { font-size: 1.2rem; }
    .welcome-buttons button { min-height: 40px; padding: 8px; font-size: 0.8rem; }
    .btn-start { min-height: 44px; font-size: 0.85rem; }
    .btn-ranking, .btn-back { min-height: 38px; font-size: 0.75rem; }
    .victory-stats { grid-template-columns: 1fr 1fr; }
    .victory-stat.highlight { grid-column: span 2; }
    .victory-buttons button { min-height: 36px; font-size: 0.65rem; padding: 6px; }
}

/* ===== TELAS MÉDIAS (401px - 600px) ===== */
@media (min-width: 401px) and (max-width: 600px) {
    .game-wrapper { padding: 4px; }
    .side-panel { min-width: 45px; }
    .next-piece-grid { width: 32px; height: 32px; }
    .game-board { gap: 1.5px; padding: 2px; aspect-ratio: 0.65; }
    .game-board-wrapper { padding: 3px; }
    .game-controls button { min-height: 38px; font-size: 0.75rem; padding: 5px 3px; }
    .game-controls button i { font-size: 0.8rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.9rem; }
    .welcome-buttons button { min-height: 44px; padding: 10px; font-size: 0.85rem; }
    .btn-start { min-height: 48px; font-size: 0.9rem; }
    .victory-buttons button { min-height: 38px; font-size: 0.7rem; }
}

/* ===== TABLETS (601px - 768px) ===== */
@media (min-width: 601px) and (max-width: 768px) {
    .game-wrapper { max-width: 480px; padding: 8px; }
    .side-panel { min-width: 55px; }
    .next-piece-grid { width: 40px; height: 40px; }
    .game-board { gap: 2px; padding: 2px; aspect-ratio: 0.7; }
    .game-board-wrapper { padding: 4px; }
    .game-controls button { min-height: 42px; font-size: 0.8rem; padding: 6px 4px; }
    .game-controls button i { font-size: 0.85rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.95rem; }
    .welcome-buttons button { min-height: 48px; padding: 12px; font-size: 0.9rem; }
    .victory-buttons button { min-height: 40px; font-size: 0.75rem; }
}

/* ===== DESKTOP (769px+) ===== */
@media (min-width: 769px) {
    .game-wrapper { max-width: 600px; padding: 12px; max-height: 90vh; }
    .game-board { gap: 2px; padding: 2px; aspect-ratio: 0.7; }
    .game-board-wrapper { padding: 4px; }
    .next-piece-grid { width: 55px; height: 55px; }
    .side-panel { min-width: 65px; }
    .game-controls button { min-height: 44px; font-size: 0.9rem; padding: 8px 6px; border-radius: 12px; }
    .game-controls button i { font-size: 1rem; }
    .game-controls button:hover { transform: scale(1.05); opacity: 0.9; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 1.1rem; }
    .welcome-buttons button { min-height: 50px; padding: 14px; font-size: 1rem; }
    .btn-start:hover { transform: scale(1.02); box-shadow: 0 6px 30px rgba(255, 137, 6, 0.4); }
    .btn-ranking:hover { background: rgba(255, 215, 0, 0.1); }
    .btn-back:hover { background: rgba(255, 255, 255, 0.06); }
    .victory-buttons button { min-height: 44px; font-size: 0.85rem; }
    .victory-buttons button:hover { transform: scale(1.02); }
    .cell:hover { border-color: rgba(255, 255, 255, 0.1); }
}

/* ============================================
   ORIENTAÇÃO PAISAGEM (Landscape)
   ============================================ */

/* ===== PAISAGEM - TELAS PEQUENAS ===== */
@media (orientation: landscape) and (max-height: 500px) {
    .game-wrapper { max-width: 95vw; padding: 2px; border-radius: 12px; }
    .game-board-wrapper { padding: 2px; }
    .game-board { gap: 1px; padding: 1px; aspect-ratio: 0.55; }
    .game-layout { gap: 3px; }
    .side-panel { min-width: 28px; }
    .next-piece-grid { width: 22px; height: 22px; }
    .next-label { font-size: 0.35rem; }
    .game-info { padding: 2px 3px; }
    .score-row { font-size: 0.35rem; padding: 0px; }
    .game-controls { gap: 3px; padding: 2px 2px; }
    .game-controls button { min-height: 28px; font-size: 0.55rem; padding: 3px 2px; border-radius: 6px; }
    .game-controls button i { font-size: 0.6rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.7rem; }
    .player-badge { font-size: 0.4rem; padding: 1px 2px; }
    .game-title { font-size: 0.55rem; }
    .logo-icon { width: 16px; height: 16px; font-size: 0.45rem; }
    .stat-badge { font-size: 0.35rem; padding: 1px 3px; }
    .game-header { padding: 2px 6px; margin-bottom: 2px; }
    .welcome-buttons button { min-height: 32px; padding: 6px; font-size: 0.65rem; }
    .btn-start { min-height: 36px; font-size: 0.7rem; }
    .btn-ranking, .btn-back { min-height: 30px; font-size: 0.6rem; padding: 4px; }
    .victory-buttons button { min-height: 28px; font-size: 0.55rem; padding: 4px; }
    .victory-buttons { gap: 3px; }
    .victory-buttons button { padding: 4px 16px; font-size: 0.55rem; max-width: 120px; }
}

/* ===== PAISAGEM - TELAS MÉDIAS ===== */
@media (orientation: landscape) and (min-height: 501px) and (max-height: 700px) {
    .game-wrapper { max-width: 90vw; padding: 4px; }
    .game-board { gap: 1.5px; padding: 2px; aspect-ratio: 0.6; }
    .game-board-wrapper { padding: 3px; }
    .side-panel { min-width: 35px; }
    .next-piece-grid { width: 28px; height: 28px; }
    .game-controls button { min-height: 32px; font-size: 0.65rem; padding: 4px 3px; }
    .game-controls button i { font-size: 0.7rem; }
    .btn-rotate, .btn-drop, .btn-reset { font-size: 0.8rem; }
    .welcome-buttons button { min-height: 36px; padding: 8px; font-size: 0.7rem; }
    .btn-start { min-height: 40px; font-size: 0.75rem; }
    .victory-buttons button { min-height: 32px; font-size: 0.6rem; }
    .score-row { font-size: 0.4rem; }
}

/* ============================================
   AJUSTES GERAIS PARA TOQUE
   ============================================ */

/* Prevenir zoom em inputs no mobile */
@media (max-width: 768px) {
    input, button, select, textarea {
        font-size: 16px !important;
    }
    
    /* Área de toque mínima para botões */
    .game-controls button,
    .welcome-buttons button,
    .victory-buttons button,
    .btn-ranking,
    .btn-back,
    .btn-store,
    .btn-start,
    .btn-close-ranking,
    .btn-back-ranking {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Feedback visual para toque */
@media (pointer: coarse) {
    .game-controls button:active {
        transform: scale(0.85);
        opacity: 0.7;
    }
    
    .cell:active {
        transform: scale(0.90);
        border-color: var(--accent);
    }
    
    .btn-start:active {
        transform: scale(0.95);
    }
    
    .btn-ranking:active {
        transform: scale(0.95);
        background: rgba(255, 215, 0, 0.15);
    }
    
    .btn-back:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.08);
    }
    
    .btn-store:active {
        transform: scale(0.95);
    }
    
    .btn-close-ranking:active {
        transform: scale(0.85);
        background: rgba(255, 255, 255, 0.12);
    }
    
    .btn-back-ranking:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.08);
    }
}

/* Remover hover em dispositivos touch */
@media (hover: none) {
    .game-controls button:hover {
        transform: none !important;
    }
    
    .btn-start:hover {
        transform: none !important;
    }
    
    .btn-ranking:hover {
        background: transparent !important;
    }
    
    .btn-back:hover {
        background: transparent !important;
    }
    
    .btn-store:hover {
        transform: none !important;
    }
    
    .cell:hover {
        border-color: rgba(255, 255, 255, 0.03) !important;
    }
}

/* ============================================
   AJUSTES PARA DISPOSITIVOS COM NOTCH
   ============================================ */
@supports (padding: max(0px)) {
    .game-wrapper {
        padding-left: max(3px, env(safe-area-inset-left));
        padding-right: max(3px, env(safe-area-inset-right));
        padding-top: max(3px, env(safe-area-inset-top));
        padding-bottom: max(3px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   TELA DE BOAS-VINDAS - SCROLL PARA MOBILE
   ============================================ */
.welcome-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.welcome-screen::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* ============================================
   BOTÃO DE DESCER - EFEITO DE PRESSÃO
   ============================================ */
.btn-drop:active {
    transform: scale(0.85) !important;
    opacity: 0.7 !important;
}

.btn-drop.pressed {
    transform: scale(0.85);
    opacity: 0.7;
}

/* ============================================
   CORREÇÃO DE BORDA PARA MOBILE
   ============================================ */
@media (max-width: 480px) {
    .game-board-wrapper {
        border-radius: 8px;
    }
    
    .game-controls {
        border-radius: 8px;
    }
    
    .glass {
        border-radius: 10px;
    }
}