:root {
    --bg-gradient: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-color: #ffffff;
    --accent: #00e5ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Jua', 'Noto Sans KR', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    padding: 3rem 2rem;
}

.screen.active {
    display: flex;
}

/* Setup Screen */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 800px;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: fadeIn 0.8s ease-out;
}

.glass-panel h1 {
    font-size: 2.8rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.6);
    letter-spacing: 2px;
}

.glass-panel p {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    color: #e0e0e0;
}

.input-group {
    margin-bottom: 2rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.8rem;
    font-size: 1.3rem;
    color: #a8e6cf;
}

textarea, input[type="text"], input[type="number"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: #ffffff;
    padding: 1.2rem;
    font-size: 1.4rem;
    font-family: 'Noto Sans KR', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}

textarea::placeholder, input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

textarea {
    height: 180px;
    resize: none;
    line-height: 1.5;
}

textarea:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
    background: rgba(0, 0, 0, 0.8);
}

.glow-btn {
    background: linear-gradient(45deg, #ff00cc, #333399);
    border: none;
    border-radius: 50px;
    color: white;
    padding: 1.2rem 3.5rem;
    font-size: 1.8rem;
    font-family: 'Jua', sans-serif;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 0, 204, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    margin-top: 1rem;
}

.glow-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 0, 204, 0.8);
}

.glow-btn:active {
    transform: translateY(2px) scale(0.98);
}

.glow-btn.small {
    padding: 0.8rem 2rem;
    font-size: 1.4rem;
    margin-top: 3rem;
    background: linear-gradient(45deg, #11998e, #38ef7d);
    box-shadow: 0 0 20px rgba(56, 239, 125, 0.5);
}

/* Game Screen */
#game-screen .header {
    text-align: center;
    margin-bottom: 3rem;
    animation: slideDown 0.6s ease-out;
}

#game-screen h1 {
    font-size: 3rem;
    text-shadow: 0 0 20px rgba(255,255,255,0.4);
}

.team-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.team-badge {
    padding: 0.6rem 1.5rem;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    animation: popIn 0.5s ease backwards;
}

.names-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    max-width: 1000px;
    margin-bottom: 2rem;
}

.name-card {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem 2.5rem;
    font-size: 2.2rem;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: popIn 0.6s ease backwards;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 160px;
    min-height: 120px;
    user-select: none;
}

.name-card:hover {
    transform: translateY(-12px) scale(1.1);
    background: rgba(255, 255, 255, 0.25);
    border-color: #ffd700;
    box-shadow: 0 15px 40px rgba(255, 215, 0, 0.5);
    color: #ffd700;
}

.name-card.selected {
    pointer-events: none;
    opacity: 0.9;
    transform: scale(0.95);
    animation: bounce 0.6s;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
    border-color: #ffd700;
    color: #ffd700;
}

.name-card .team-name {
    font-size: 1.2rem;
    margin-top: 0.5rem;
    opacity: 0.9;
}

/* Modal and FIFA Card Animation */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: all;
}

/* Card Container */
.fifa-card-container {
    position: relative;
    width: 320px;
    height: 480px;
    perspective: 1200px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: scale(0.5);
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.show .fifa-card-container {
    transform: scale(1);
}

/* The 3D Card */
.fifa-card {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    transform-style: preserve-3d;
}

.fifa-card.flip {
    transform: rotateY(180deg);
}

/* Back and Front base styling */
.card-back, .card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

/* Card Back (Before flip) */
.card-back {
    background: linear-gradient(135deg, #111, #333);
    border: 6px solid #d4af37;
    transform: rotateY(0deg);
}

.mystery-box {
    position: relative;
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mystery-box span {
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ffaa00;
    animation: float 2s ease-in-out infinite, pulseGlow 1.5s alternate infinite;
    z-index: 10;
}

.mystery-box .ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid #ffd700;
    border-radius: 50%;
    animation: expandRing 2s linear infinite;
    box-shadow: 0 0 20px #ffd700, inset 0 0 20px #ffd700;
}

.mystery-box .ring.delay {
    animation-delay: -1s;
    border-color: #ffaa00;
    box-shadow: 0 0 20px #ffaa00, inset 0 0 20px #ffaa00;
}

/* Card Front (After flip) */
.card-front {
    background: radial-gradient(circle at center top, #2b5876 0%, #4e4376 100%);
    border: 6px solid #fff; /* Handled by JS */
    transform: rotateY(180deg);
    overflow: hidden;
    position: relative;
}

/* Player Image */
.player-photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5;
}

.player-photo.walkout {
    animation: walkoutAnim 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Card Info (Team and Name) */
.card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 20;
    text-align: center;
    width: 100%;
    padding: 60px 10px 20px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
}

#modal-team {
    font-size: 3.5rem;
    margin: 0;
    font-weight: 900;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#modal-name {
    font-size: 3rem;
    color: #fff;
    margin-top: 5px;
    font-weight: 900;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* Spotlight Effect */
.spotlight {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(255,255,255,0.4) 30deg, transparent 60deg, transparent 180deg, rgba(255,255,255,0.4) 210deg, transparent 240deg);
    z-index: -1;
    animation: rotateSpotlight 6s linear infinite;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes popIn {
    from { opacity: 0; transform: scale(0.4); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.1); }
    100% { transform: scale(0.95); }
}

@keyframes zoomIn {
    0% { opacity: 0; transform: scale(0.1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes pulseGlow {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.5); }
}

@keyframes expandRing {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes walkoutAnim {
    0% { transform: translateY(100%) scale(0.7); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

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

/* Responsive */
@media (max-width: 600px) {
    .glass-panel { padding: 2rem 1.5rem; }
    .glass-panel h1 { font-size: 2.2rem; }
    #game-screen h1 { font-size: 2.2rem; }
    .name-card { font-size: 1.8rem; min-width: 120px; padding: 1rem; }
    .fifa-card-container { width: 280px; height: 420px; }
    #modal-team { font-size: 2.8rem; }
    #modal-name { font-size: 2.2rem; }
}
