@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700;900&display=swap');

:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --card-back: linear-gradient(135deg, #1e293b, #0f172a);
    --card-border: rgba(255, 255, 255, 0.05);
    
    --card-elimination: #fda4af; /* Pastel Red for 탈락 */
    --card-low: #86efac; /* Pastel Green for Low */
    --card-number: #cbd5e1; /* Silver/White for regular numbers */
    --card-highest: #93c5fd; /* Pastel Blue for the highest number (20) */
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
}

.container {
    display: flex;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 350px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
    z-index: 10;
}

.game-title {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.highlight {
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.status-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
}

.status-box p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Button */
.select-button {
    position: relative;
    padding: 20px 0;
    width: 100%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    border-radius: 16px;
    color: white;
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.5);
}

.select-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -5px rgba(59, 130, 246, 0.6);
}

.select-button:active:not(:disabled) {
    transform: translateY(2px);
}

.select-button:disabled {
    background: #475569;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

.select-button span {
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.select-button .glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    z-index: 1;
    transition: 0.5s;
}

.select-button:hover:not(:disabled) .glow {
    left: 100%;
    transition: 0.5s;
}

/* Right Panel */
.right-panel {
    flex: 1;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 15px;
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 750px;
    perspective: 1000px;
}

/* Card Styles */
.card {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: default;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--card-border);
}

.card-front {
    background: var(--card-back);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255,255,255,0.03) 10px,
        rgba(255,255,255,0.03) 20px
    );
}

.card-name-input {
    width: 80%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: 0.3s;
    z-index: 2;
}

.card-name-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    background: rgba(0, 0, 0, 0.7);
}

.card-name-input:disabled {
    opacity: 0.5;
    background: transparent;
    border-color: transparent;
}

.card-back {
    background: #1e293b;
    transform: rotateY(180deg);
    text-align: center;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.card-name-display {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 1.2rem;
}

/* In pastel mode, the name text needs to be darker on colored cards */
.card.is-lowest .card-back .card-name-display,
.card.is-highest .card-back .card-name-display {
    color: rgba(15, 23, 42, 0.7);
}

.card-value-display {
    font-size: 1.8rem;
    line-height: 1;
}

/* Card Type Variants */
.card.is-lowest .card-back {
    background: var(--card-low);
    color: #0f172a;
    border-color: var(--card-low);
    box-shadow: 0 4px 15px rgba(134, 239, 172, 0.3);
}

.card-back.card-number {
    background: #1e293b;
    color: var(--card-number);
    border-color: rgba(203, 213, 225, 0.3);
}

.card.is-highest .card-back {
    background: var(--card-highest);
    color: #0f172a;
    border-color: var(--card-highest);
    box-shadow: 0 4px 15px rgba(147, 197, 253, 0.3);
}

.rank-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 900;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.first-place {
    background: #eab308;
    color: #fff;
}

.second-place {
    background: #10b981;
    color: #fff;
}

/* Animations */
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.card {
    animation: popIn 0.5s ease-out backwards;
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: 95vh;
    }
    
    .left-panel {
        width: 100%;
        height: auto;
        padding: 20px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
    }
    
    .subtitle { margin-bottom: 0; display: none; }
    .status-box { margin-bottom: 0; display: flex; gap: 20px; }
    .select-button { width: 200px; padding: 15px 0; }
    
    .cards-grid {
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
        height: auto;
        max-height: none;
    }
    .card {
        min-height: 130px;
    }
    .card-name-input {
        font-size: 1rem;
        padding: 10px;
        width: 90%;
    }
    .left-panel {
        flex-wrap: wrap;
        justify-content: center;
    }
    .status-box { width: 100%; justify-content: center; }
    .select-button { width: 100%; }
}
