/* =====================
   SETUP SCREEN
   ===================== */

#setup {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

.setup-card {
    width: 100%;
    max-width: 1100px;
    height: 98vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.setup-header {
    padding: 15px 25px;
    height: 105px;
    text-align: center;
    background: linear-gradient(135deg, #6C5CE7, #a29bfe);
    color: white;
    position: relative;
    flex-shrink: 0;
}

.setup-header h1 {
    font-size: 1.8rem;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.setup-header p {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.setup-header .version-badge {
    position: absolute;
    top: 5px;
    right: 970px;
    background: rgba(255, 255, 255, 0.25);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
}

.setup-body {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

/* 2x2 Grid Layout */
.setup-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    grid-template-rows: 0.35fr 0.65fr;
    gap: 15px;
    min-height: 0;
}

.setup-tile {
    background: white;
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.setup-tile h3 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Bottom-Right: Player History */
.tile-history {
    background: linear-gradient(135deg, #f0f4ff, #e8eeff);
    border: 2px solid #e0e5ff;
}

.history-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
    overflow: hidden;
    padding: 4px;
}

.history-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px 10px;
    background: white;
    border-radius: 16px;
    border: 2px solid var(--primary);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.1);
    overflow: hidden;
    min-height: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.15);
}

.history-top-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    flex-shrink: 0;
}

.history-bottom-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.history-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 3px solid #f0f0f0;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-dark);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-family: 'Fredoka', sans-serif;
}

.history-stats {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-weight: 600;
}

.history-ranks {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

.history-ranks .rank-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 32px;
}

.history-ranks .rank-badge.gold {
    background: linear-gradient(135deg, #FFF9E6, #FFE4B5);
    color: #B8860B;
    border: 1px solid #FFD700;
}

.history-ranks .rank-badge.silver {
    background: linear-gradient(135deg, #F0F0F0, #E8E8E8);
    color: #6B6B6B;
    border: 1px solid #C0C0C0;
}

.history-ranks .rank-badge.bronze {
    background: linear-gradient(135deg, #FFEBD6, #F5DEB3);
    color: #8B4513;
    border: 1px solid #CD7F32;
}

.history-xp {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.history-level {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
}

.history-xp-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    font-family: 'Fredoka', sans-serif;
}

/* Top-Right: Game Buttons */
.tile-buttons {
    background: linear-gradient(135deg, #fff5f5, #ffe8e8);
    border: 2px solid #ffd9d9;
}

.game-buttons-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    min-height: 0;
}

.game-btn-start-container {
    grid-column: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottom-Left: Player Setup */
.tile-players {
    background: linear-gradient(135deg, #fff8f0, #fff5e6);
    border: 2px solid #ffe0b2;
}

.player-setup-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
    min-height: 0;
}

.player-card {
    background: white;
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid #f0f0f0;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.player-card.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, #fff, #f8f7ff);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.2);
}

.player-card.inactive {
    opacity: 0.55;
    background: #f8f8f8;
    border-color: #e8e8e8;
}

.player-avatar {
    font-size: 3rem;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.player-avatar:hover {
    transform: scale(1.1);
}

.player-avatar .edit-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.player-name {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 10px;
    text-align: center;
    color: var(--text-dark);
}

/* Top-Left: Menu Buttons */
.tile-menu {
    background: linear-gradient(135deg, #f0fff4, #e6fff0);
    border: 2px solid #b2f7c4;
}

.menu-buttons {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

/* Game Instructions */
.game-instructions {
    background: #f1f2f6;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    color: #636e72;
    display: none;
}

/* Google Sign-In Button */
.google-signin-btn {
    background: white;
    color: #5f6368;
    border: 1px solid #dadce0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.google-signin-btn:hover {
    background: #f8f9fa;
    border-color: #c2c8d0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.google-signin-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.google-signin-btn .fab {
    font-size: 1rem;
}

.google-signin-btn.signed-in {
    background: linear-gradient(135deg, #34a853, #4285f4);
    color: white;
    border-color: transparent;
}

.google-signin-btn.signed-in:hover {
    background: linear-gradient(135deg, #2d9147, #3b78e8);
}
