/* 기본 설정 및 리셋 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #FFB6C1 0%, #DDA0DD 50%, #87CEEB 100%);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* 게임 컨테이너 */
.game-container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 1s ease-out;
}

.game-header h1 {
    font-size: 2.5rem;
    color: #8B4513;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

.game-header .subtitle {
    font-size: 1.2rem;
    color: #654321;
    font-weight: 500;
}

/* 마법의 꽃밭 메인 영역 */
.flower-garden {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    padding: 40px 20px;
    margin-bottom: 20px;
    min-height: 500px;
}

/* 배경 애니메이션 요소들 */
.background-elements {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.butterfly {
    position: absolute;
    font-size: 2rem;
    animation: butterfly-fly 8s infinite ease-in-out;
}

.butterfly-1 {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.butterfly-2 {
    top: 60%;
    right: 15%;
    animation-delay: 4s;
}

/* 꽃들 컨테이너 */
.flowers-container {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
    max-width: 600px;
}

.flowers-container .flower:nth-child(1) { grid-column: 2; }
.flowers-container .flower:nth-child(2) { grid-column: 1; grid-row: 2; }
.flowers-container .flower:nth-child(3) { grid-column: 3; grid-row: 2; }
.flowers-container .flower:nth-child(4) { grid-column: 1; grid-row: 3; }
.flowers-container .flower:nth-child(5) { grid-column: 2; grid-row: 3; }
.flowers-container .flower:nth-child(6) { grid-column: 3; grid-row: 3; }
.flowers-container .flower:nth-child(7) { grid-column: 2; grid-row: 4; }

/* 꽃 스타일 */
.flower {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform-origin: center;
    transition: all 0.3s ease;
}

.flower:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.flower:active {
    transform: scale(0.95);
}

.flower-bud {
    font-size: 4rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6));
    transition: all 0.5s ease;
    z-index: 2;
}

.flower-bloom {
    position: absolute;
    font-size: 6rem;
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    z-index: 1;
}

.flower.blooming .flower-bud {
    opacity: 0;
    transform: scale(0);
}

.flower.blooming .flower-bloom {
    opacity: 1;
    transform: scale(1) rotate(360deg);
    animation: bloom 2s ease-out;
}

.table-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #8B4513;
    font-size: 2.5rem;
    font-weight: bold;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    z-index: 3;
    animation: sparkle 1s infinite;
}

.table-number.hidden {
    display: none;
}

/* 게임 안내 */
.game-instruction {
    position: relative;
    z-index: 2;
    text-align: center;
}

.game-instruction p {
    font-size: 1.5rem;
    color: #8B4513;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    animation: glow 2s infinite alternate;
}

/* 정보 패널 */
.info-panel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.remaining-count {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.3rem;
    font-weight: bold;
}

.remaining-count .label {
    color: #8B4513;
}

.remaining-count .count {
    color: #FF6347;
    font-size: 1.5rem;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    text-align: center;
}

.table-grid .table-info:nth-child(n+5) {
    grid-column: span 1;
}

.table-grid .table-info:nth-child(5) {
    grid-column: 1;
}

.table-grid .table-info:nth-child(6) {
    grid-column: 2;
}

.table-grid .table-info:nth-child(7) {
    grid-column: 3;
}

.table-info {
    background: linear-gradient(135deg, #FFE4E1, #FFF0F5);
    border: 2px solid #DDA0DD;
    border-radius: 10px;
    padding: 8px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.table-info.full {
    background: linear-gradient(135deg, #FFB6C1, #DDA0DD);
    opacity: 0.6;
}

.table-info.priority {
    background: linear-gradient(135deg, #FFE4B5, #FFFF99);
    border-color: #FFA500;
    animation: pulse-priority 2s infinite;
}

@keyframes pulse-priority {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 15px rgba(255, 165, 0, 0.8);
    }
}

.table-num {
    display: block;
    color: #8B4513;
    font-size: 1rem;
}

.table-count {
    display: block;
    color: #FF6347;
    font-size: 0.9rem;
}

/* 결과 모달 */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.result-modal.hidden {
    display: none;
}

.result-content {
    background: linear-gradient(135deg, #FFE4E1, #FFF0F5);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.5s ease-out;
}

.magic-circle {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotate 2s linear infinite;
}

.result-title {
    color: #8B4513;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.table-result {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    animation: pulse 1s infinite;
}

.result-number {
    font-size: 4rem;
    font-weight: bold;
    color: #8B4513;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.result-text {
    font-size: 2rem;
    font-weight: bold;
    color: #8B4513;
    margin-left: 10px;
}

.result-message {
    color: #654321;
    font-size: 1.2rem;
    font-weight: 500;
}

/* 게임 컨트롤 */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.reset-btn, .admin-btn {
    background: linear-gradient(135deg, #FFE4E1, #DDA0DD);
    border: 2px solid #8B4513;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    color: #8B4513;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.reset-btn:hover, .admin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #DDA0DD, #FFE4E1);
}

.reset-btn:active, .admin-btn:active {
    transform: translateY(0);
}

/* 파티클 컨테이너 */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, #FFD700, #FFA500);
    border-radius: 50%;
    pointer-events: none;
    animation: float 3s infinite ease-in-out;
}

/* 애니메이션 키프레임 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes butterfly-fly {
    0% { transform: translateX(0) translateY(0) rotate(0deg); }
    25% { transform: translateX(100px) translateY(-50px) rotate(90deg); }
    50% { transform: translateX(200px) translateY(20px) rotate(180deg); }
    75% { transform: translateX(150px) translateY(-30px) rotate(270deg); }
    100% { transform: translateX(0) translateY(0) rotate(360deg); }
}

@keyframes bloom {
    0% { 
        transform: scale(0.3) rotate(0deg);
        opacity: 0.5;
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
    }
    50% { 
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
        filter: drop-shadow(0 0 25px rgba(255, 255, 255, 1));
    }
    100% { 
        transform: scale(1) rotate(360deg);
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    }
}

@keyframes sparkle {
    0%, 100% { 
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(0.9);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
    50% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 30px rgba(255, 215, 0, 1);
    }
}

@keyframes glow {
    from { text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8); }
    to { text-shadow: 1px 1px 10px rgba(255, 255, 255, 1), 0 0 20px rgba(255, 215, 0, 0.5); }
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

@keyframes float {
    0%, 100% { 
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 1; }
    90% { opacity: 1; }
    50% { 
        transform: translateY(-20px) rotate(180deg);
        opacity: 1;
    }
}

/* 태블릿 최적화 */
@media (max-width: 1024px) {
    .game-header h1 {
        font-size: 2rem;
    }
    
    .flowers-container {
        gap: 20px;
        max-width: 500px;
    }
    
    .flower {
        width: 100px;
        height: 100px;
    }
    
    .flower-bud {
        font-size: 3rem;
    }
    
    .flower-bloom {
        font-size: 5rem;
    }
    
    .table-number {
        font-size: 2rem;
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }
    
    .flowers-container {
        gap: 15px;
        max-width: 400px;
    }
    
    .flower {
        width: 80px;
        height: 80px;
    }
    
    .flower-bud {
        font-size: 2.5rem;
    }
    
    .flower-bloom {
        font-size: 4rem;
    }
    
    .table-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .table-grid .table-info:nth-child(7) {
        grid-column: 2;
    }
}

/* 터치 장치 최적화 */
@media (hover: none) and (pointer: coarse) {
    .flower:hover {
        transform: none;
        filter: none;
    }
    
    .flower:active {
        transform: scale(0.9);
        filter: brightness(1.2);
    }
}
