:root {
    --primary: #6C5CE7;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --dark: #2D3436;
    --light: #DFE6E9;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #FF7675;
    --glass: rgba(255, 255, 255, 0.9);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #74b9ff, #a29bfe);
    color: var(--dark);
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    font-family: 'Fredoka One', cursive;
    margin: 0;
}

.screen {
    display: none;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: var(--glass);
    backdrop-filter: blur(4px);
    box-shadow: var(--shadow);
    position: relative;
    overflow-y: auto;
    animation: slideIn 0.5s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* --- LOGIN --- */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.logo-area {
    margin-bottom: 20px;
}

.logo-img {
    max-width: 80%;
    height: auto;
    max-height: 100px;
    /* Tamanho reduzido para mobile */
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.2));
    animation: float 3s ease-in-out infinite;
}

.logo-area p {
    font-size: 1.2rem;
    color: var(--dark);
    margin-top: 10px;
    font-weight: bold;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.login-box {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 100%;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

select,
input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid var(--light);
    border-radius: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
}

button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: 'Fredoka One', cursive;
}

button:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 0 #4834d4;
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 5px 10px;
    font-size: 0.8rem;
    width: auto;
}

.btn-admin {
    background: var(--warning);
    color: var(--dark);
    padding: 5px 10px;
    font-size: 0.8rem;
    width: auto;
    margin-right: 5px;
}

/* --- DASHBOARD --- */
#tela-dashboard header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    cursor: pointer;
}

.user-profile img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}

.user-profile>div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-profile>div>span {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--dark);
    display: block;
}

.user-profile>div>button {
    font-size: 0.8rem !important;
    padding: 5px 10px !important;
    margin: 0 !important;
}

#tela-dashboard header>.btn-danger {
    padding: 10px 20px;
    font-size: 0.95rem;
}

.user-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    min-width: 200px;
    z-index: 1000;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    color: var(--dark);
}

.user-menu button:hover {
    background: var(--primary);
    color: white;
    transform: translateX(5px);
}

.user-menu button:first-child {
    margin-bottom: 4px;
}

main {
    padding: 20px;
    flex: 1;
}

.ranking-list {
    margin-top: 10px;
}

.rank-item {
    background: white;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.rank-item.campeao {
    background: linear-gradient(45deg, #ffeaa7, #fab1a0);
    border: 2px solid gold;
    transform: scale(1.02);
}

.rank-pos {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
    font-weight: bold;
    color: var(--primary);
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
}

.info {
    flex: 1;
    text-align: left;
}

.stats {
    font-size: 0.8rem;
    color: #636e72;
    display: flex;
    gap: 10px;
}

.grid-oponentes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.oponente-card {
    background: white;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.oponente-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}

.btn-desafio-small {
    margin-top: 10px;
    font-size: 0.9rem;
    padding: 8px;
    background: var(--secondary);
    color: white;
}

.convite-toast {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 15px;
    margin-top: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    animation: slideInDown 0.5s ease;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 1000;
}

.convite-info {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.convite-actions {
    display: flex;
    gap: 10px;
}

.btn-accept {
    background: var(--success);
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

.btn-decline {
    background: var(--danger);
    color: white;
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- HISTÓRICO MENSAL --- */
.history-section {
    margin-top: 30px;
}

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

#historico-mensal {
    display: grid;
    gap: 15px;
}

.mes-card {
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.mes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mes-header h4 {
    margin: 0;
}

.btn-reabrir {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 2px 8px;
    font-size: 0.8rem;
    border-radius: 5px;
}

/* Permitir seleção para screenshots */
* {
    user-select: auto;
    -webkit-user-select: auto;
}

.mini-ranking {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.9rem;
}

.mini-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* --- RESULTS SECTION --- */
.results-section {
    margin-top: 30px;
}

.results-section h3 {
    margin-bottom: 15px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.results-table thead {
    background: var(--primary);
    color: white;
}

.results-table thead th {
    padding: 12px 10px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: bold;
}

.results-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.results-table tbody tr:nth-child(odd) {
    background-color: #f9f9f9;
}

.results-table tbody tr:nth-child(even) {
    background-color: white;
}

.results-table tbody tr:hover {
    background-color: #f0f0ff;
}

.results-table td {
    padding: 12px 10px;
    font-size: 0.9rem;
}

.result-datetime {
    width: 80px;
}

.datetime-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.datetime-wrapper .date {
    font-weight: bold;
    font-size: 0.85rem;
}

.datetime-wrapper .time {
    font-size: 0.75rem;
    color: #666;
}

.result-opponent {
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.result-game {
    text-align: center;
}

.choice-icons {
    font-size: 1.1rem;
}

.result-outcome {
    font-weight: bold;
    text-align: center;
}

.result-outcome.win {
    color: var(--success);
}

.result-outcome.loss {
    color: var(--danger);
}

.result-outcome.draw {
    color: var(--warning);
}

/* --- GAME --- */
.game-header {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
}

.btn-back {
    background: transparent;
    color: var(--dark);
    width: auto;
    padding: 5px;
    font-size: 1.2rem;
}

.arena {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

.placar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 30px;
}

.player-card {
    text-align: center;
}

.avatar-game {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    background: #eee;
}

.vs-badge {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--danger);
    font-family: 'Fredoka One';
}

.status-msg {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 30px;
    color: var(--primary);
    min-height: 30px;
}

.pulsing {
    animation: pulse 1s infinite;
}

.cards-container {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.card {
    width: 90px;
    height: 130px;
    background: white;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    border-bottom: 5px solid #dfe6e9;
}

.card:hover {
    transform: translateY(-10px);
    background: #f1f2f6;
}

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

/* --- RESULT OVERLAY --- */
.result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.result-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    width: 80%;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-overlay.win .result-content {
    border: 5px solid var(--success);
}

.result-overlay.lose .result-content {
    border: 5px solid var(--danger);
}

.result-overlay.draw .result-content {
    border: 5px solid var(--warning);
}

/* --- MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 350px;
    position: relative;
}

.close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: bold;
}

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

.admin-tab {
    animation: fadeInTab 0.3s;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Avatar Upload Section */
.avatar-upload-section {
    display: flex;
    gap: 15px;
    margin: 15px 0;
}

.radio-option {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.radio-option:hover {
    border-color: var(--primary);
    background: #f5f5ff;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option input[type="radio"]:checked+span {
    font-weight: bold;
    color: var(--primary);
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: #f0f0ff;
}

.upload-area {
    margin: 15px 0;
}

.upload-label {
    display: block;
    cursor: pointer;
}

#preview-container {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    border: 3px dashed #ccc;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    transition: all 0.3s;
}

#preview-container:hover {
    border-color: var(--primary);
    background: #f5f5ff;
}

#preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#preview-img.preview-hidden {
    display: none;
}

#upload-placeholder {
    text-align: center;
    color: #666;
    padding: 20px;
}

#upload-placeholder.hidden {
    display: none;
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

#upload-placeholder span {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

#upload-placeholder small {
    font-size: 0.75rem;
    color: #999;
}

#avatar-file {
    display: none;
}

/* --- UTILS --- */
.hidden {
    display: none !important;
}

/* User Management */
.btn-secondary-small {
    padding: 6px 12px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 8px;
    transition: all 0.3s;
}

.btn-secondary-small:hover {
    background: #00a0c6;
    transform: scale(1.05);
}

.user-profile>div>.btn-admin,
.user-profile>div>.btn-secondary-small {
    display: inline-block;
    margin-right: 6px;
}

.user-management-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
}

.user-card:hover {
    transform: translateX(5px);
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 1rem;
    color: var(--dark);
}

.user-info small {
    font-size: 0.85rem;
    color: #666;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.btn-edit {
    padding: 8px 12px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-edit:hover {
    background: #00a0c6;
    transform: scale(1.1);
}

.btn-delete {
    padding: 8px 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-delete:hover {
    background: #c0392b;
    transform: scale(1.1);
}

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

.avatar-preview-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 10px auto;
    border: 3px solid var(--primary);
}

.avatar-change-options {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

/* Help Modal */
.btn-help {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-help:hover {
    background: var(--primary);
    transform: scale(1.1) rotate(15deg);
}

.help-content {
    text-align: left;
    line-height: 1.6;
}

.help-content h3 {
    color: var(--primary);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.help-content p {
    color: #555;
    margin-bottom: 15px;
}

.game-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.choice-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.choice-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.choice-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.choice-desc {
    font-size: 0.9rem;
    opacity: 0.9;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.rule-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.rule-item.win {
    border-color: var(--success);
    background: #d4edda;
}

.rule-item.draw {
    border-color: #ffc107;
    background: #fff3cd;
}

.rule-emoji {
    font-size: 2rem;
}

.rule-vs {
    font-weight: bold;
    color: #666;
    font-size: 0.9rem;
}

.rule-result {
    font-weight: bold;
    color: var(--primary);
    font-size: 1.1rem;
}

.rule-item small {
    color: #666;
    font-size: 0.85rem;
}

.points-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.point-item {
    background: white;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.point-icon {
    font-size: 2rem;
}

.point-value {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary);
}

.point-label {
    font-size: 0.9rem;
    color: #666;
}

.ranking-formula {
    background: #e9ecef;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    margin: 15px 0;
    border-left: 4px solid var(--primary);
}

.ranking-formula code {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: bold;
}

.tips-list {
    background: #fff3cd;
    padding: 20px 40px;
    border-radius: 12px;
    border-left: 4px solid #ffc107;
}

.tips-list li {
    margin-bottom: 10px;
    color: #856404;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        transform: scale(0.5);
    }

    to {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .screen {
        max-width: 100%;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
    }

    .login-container {
        max-width: 400px;
        margin: 0 auto;
    }

    main {
        max-width: 800px;
        margin: 0 auto;
        width: 100%;
    }
}