:root {
    --glide-accent: #4F7DF7;
    --bg: #0D1B2E;
    --card-bg: #14243C;
    --card-bg-2: #1B2F4E;
    --text: #F4F7FB;
    --text-secondary: #8FA3C0;
    --gold: #F5C84C;
    --glide-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 400px;
    height: 100%;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

#card-container {
    flex: 1;
    position: relative;
    perspective: 1200px;
}

.card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 24px;
    cursor: grab;
    transition: var(--transition);
    transform-style: preserve-3d;
    user-select: none;
    transform-origin: center center;
}

.card:active {
    cursor: grabbing;
}

.card-content {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    pointer-events: none;
}

.card-front, .card-back {
    position: absolute;
    inset: 0;
    background: var(--card-bg);
    border: 1px solid rgba(143, 163, 192, 0.18);
    border-radius: 24px;
    box-shadow: var(--glide-shadow);
    backface-visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-front {
    z-index: 2;
    transform: translateZ(1px);
}

.card-back {
    transform: rotateY(180deg) translateZ(1px);
    padding: 20px;
}

/* ---------- FRONT ---------- */

.photo-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--card-bg-2);
}

.player-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-photo.initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: 800;
    color: rgba(244, 247, 251, 0.25);
    letter-spacing: 2px;
}

.photo-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(13,27,46,0) 45%, rgba(13,27,46,0.55) 78%, #14243C 100%);
}

.elo-chip {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(13, 27, 46, 0.75);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(245, 200, 76, 0.5);
    color: var(--gold);
    font-weight: 700;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 999px;
}

.sport-chip {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(13, 27, 46, 0.75);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(143, 163, 192, 0.35);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 999px;
}

.front-info {
    padding: 4px 20px 16px;
}

.player-name {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 4px;
}

.player-location {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.level-badge {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 12px;
    border-radius: 999px;
    color: #0D1B2E;
    background: var(--glide-accent);
}

.flip-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* ---------- BACK ---------- */

.back-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(143, 163, 192, 0.18);
}

.back-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--card-bg-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    overflow: hidden;
}

.back-title {
    flex: 1;
    min-width: 0;
}

.back-title .name {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.back-title .sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.back-elo {
    color: var(--gold);
    font-weight: 800;
    font-size: 15px;
    white-space: nowrap;
}

.stats-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.stat-row .stat-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.stat-row .stat-top .label {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.stat-row .stat-top .value {
    font-weight: 700;
    font-size: 13px;
}

.stat-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(143, 163, 192, 0.15);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- CONTROLS ---------- */

#counter {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding-top: 12px;
    letter-spacing: 1px;
}

#controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px 0 4px;
}

.control-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid rgba(143, 163, 192, 0.25);
    background: var(--card-bg);
    box-shadow: var(--glide-shadow);
    color: var(--glide-accent);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

.control-btn:active {
    transform: scale(0.9);
}

.control-btn svg {
    width: 26px;
    height: 26px;
}

.main-btn {
    width: 70px;
    height: 70px;
}

.main-btn svg {
    width: 34px;
    height: 34px;
}

#empty-state {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
}

#empty-state.hidden {
    display: none;
}

#reset-btn {
    margin-top: 20px;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    background: var(--glide-accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#reset-btn:hover {
    opacity: 0.9;
}
