/* =====================
   GAME INTERFACE
   ===================== */

#gameInterface {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    z-index: 1500;
    background: var(--bg-primary);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    overflow: hidden;
}

#gameInterface:not(.hidden) {
    display: flex !important;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    gap: 20px;
    flex-shrink: 0;
}

.game-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.progress-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 400px;
}

.progress-section .progress-bar-container {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-section .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00c853, #00e676, #69f0ae);
    border-radius: 8px;
    transition: width 0.4s ease;
    box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
}

.progress-section .progress-text {
    font-size: 0.9rem;
    color: white;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.hud-group {
    display: flex;
    gap: 8px;
}

/* Main Layout */
.main-area {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    min-height: 0;
    overflow: hidden;
}

/* The Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 12px;
    padding: 20px;
    position: relative;
    perspective: 1000px;
    overflow: auto;
    min-height: 0;
    height: 100%;
}

.tile {
    background: white;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 2px solid transparent;
    transform-style: preserve-3d;
    min-height: 80px;
    min-width: 80px;
}

.tile.flipping {
    animation: flip3D 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.tile.number-side {
    background: linear-gradient(135deg, #6C5CE7, #A29BFE);
    color: white;
}

.tile.category-side {
    background: white;
}

.tile-number {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.tile:active {
    transform: translateY(5px) rotateY(0deg);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}

.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.tile.taken {
    background: white !important;
    box-shadow: inset 0 0 0 4px;
    transform: none !important;
    cursor: default;
}

.tile-icon { 
    font-size: 1.8rem; 
    margin-bottom: 5px; 
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.2));
}

.tile-label { font-size: 0.8rem; font-weight: 600; color: #636e72; }

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    min-height: 0;
}

.turn-card {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    flex-wrap: wrap;
}

.turn-powerups {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.turn-powerup {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    animation: powerUpBounce 0.5s ease;
}

.turn-powerup.shield {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    box-shadow: 0 2px 8px rgba(9, 132, 227, 0.4);
}

.turn-powerup.double {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    box-shadow: 0 2px 8px rgba(225, 112, 85, 0.4);
}

.current-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: var(--bg-anim-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: pulseAvatar 2s infinite;
}

.turn-info {
    flex: 1;
}

.turn-label {
    font-size: 0.8rem;
    color: #636e72;
}

.turn-name {
    font-size: 1.3rem;
    font-weight: 700;
}

.score-list {
    flex: 1;
    background: rgba(255, 255, 255, 0.85);
    padding: 12px;
    overflow-y: auto;
    min-height: 180px;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 12px;
    border-left: 5px solid #ccc;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.score-item:hover {
    transform: translateX(5px);
}

.score-item.leader {
    background: linear-gradient(135deg, #FFF9E6, #FFF3CD);
    border-left-color: var(--gold);
}

.score-powerups {
    display: flex;
    gap: 4px;
    align-items: center;
}

.score-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 5px;
}

.score-rank.gold { background: var(--gold); color: white; }
.score-rank.silver { background: var(--silver); color: white; }
.score-rank.bronze { background: var(--bronze); color: white; }

.score-avatar {
    font-size: 1.4rem;
}

.score-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

.score-val {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.player-rank-stats {
    background: rgba(255, 255, 255, 0.85);
    padding: 12px;
    border-radius: 15px;
}

.player-rank-stats h4 {
    margin: 0 0 10px 0;
    color: var(--primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rank-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rank-stat-card {
    background: white;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #f0f0f0;
    transition: all 0.3s ease;
}

.rank-stat-card.rank-1 {
    border-color: #FFD700;
    background: linear-gradient(135deg, #FFF9E6, #FFFFFF);
}

.rank-stat-card.rank-2 {
    border-color: #C0C0C0;
    background: linear-gradient(135deg, #F8F8F8, #FFFFFF);
}

.rank-stat-card.rank-3 {
    border-color: #CD7F32;
    background: linear-gradient(135deg, #FFF5E6, #FFFFFF);
}

.rank-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rank-stat-avatar {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.rank-stat-name {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-stat-badges {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.rank-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    min-width: 32px;
}

.rank-badge.gold {
    background: #FFF9E6;
}

.rank-badge.silver {
    background: #F0F0F0;
}

.rank-badge.bronze {
    background: #FFEBD6;
}

.rank-badge-count {
    font-size: 0.9rem;
    font-weight: 700;
}

.rank-badge.gold .rank-badge-count {
    color: #B8860B;
}

.rank-badge.silver .rank-badge-count {
    color: #6B6B6B;
}

.rank-badge.bronze .rank-badge-count {
    color: #8B4513;
}

.rank-badge-label {
    font-size: 0.5rem;
    color: #999;
    margin-top: 1px;
}

.rank-badge.gold .rank-badge-label {
    color: #B8860B;
}

.rank-badge.silver .rank-badge-label {
    color: #6B6B6B;
}

.rank-badge.bronze .rank-badge-label {
    color: #8B4513;
}

/* Progress Panel */
.progress-panel {
    display: none;
    background: rgba(255, 255, 255, 0.85);
    padding: 12px;
    border-radius: 15px;
}

.progress-panel h4 {
    margin: 0 0 10px 0;
    color: var(--primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00b894, #00cec9);
    transition: width 0.5s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.7rem;
}

.progress-text {
    text-align: center;
    font-size: 0.8rem;
    color: #636e72;
    margin-top: 8px;
}
