:root {
    --primary-color: #d42426; /* Christmas Red */
    --secondary-color: #165b33; /* Christmas Green */
    --accent-color: #f8b229; /* Gold */
    --bg-color: #0f2027; /* Dark Night */
    --text-color: #333;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.9);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    /* Mặc định load file background.jpg cùng thư mục */
    background: url('./background.jpg') center/cover no-repeat fixed, linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
    background-blend-mode: normal; 
    color: var(--text-color);
    height: 100vh;
    overflow: hidden; /* Prevent scroll on game screen */
    position: relative;
}

/* Fallback nếu không có ảnh background.jpg thì hiện màu tối */
body:before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
    z-index: -1;
    display: none; /* Chỉ hiện khi ảnh lỗi, xử lý bằng JS nếu cần, hoặc để CSS này làm backup */
}

/* --- Snow Effect --- */
#snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.snowflake {
    position: absolute;
    top: -10px;
    color: #fff;
    user-select: none;
    z-index: 1;
    animation-name: fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes fall {
    to { transform: translateY(105vh); }
}

/* --- Music Button --- */
.music-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 9999; /* Max Z-index */
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

.music-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: flex;
}

/* --- UI Components --- */
.card {
    background: var(--glass-bg);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 2px solid var(--accent-color);
}

.glass-effect {
    backdrop-filter: blur(10px);
}

.title {
    font-family: 'Mountains of Christmas', cursive;
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    margin-bottom: 20px;
    color: #555;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--secondary-color);
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 5px rgba(22, 91, 51, 0.3);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 50px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
}

.btn-text {
    background: none;
    border: none;
    color: #666;
    text-decoration: underline;
    margin-top: 15px;
    cursor: pointer;
}

.error-msg {
    color: red;
    font-size: 14px;
    margin-bottom: 10px;
    height: 20px;
}

/* --- Game Screen --- */
.game-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 40px;
}

.game-header {
    margin-top: 20px;
    color: var(--white);
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    font-family: 'Mountains of Christmas', cursive;
    z-index: 5;
    text-align: center;
}

.turn-counter {
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    color: var(--accent-color);
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 15px;
    margin-top: 5px;
}

.scene {
    position: relative;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.tree {
    max-width: 80%;
    max-height: 60vh;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
    transition: transform 0.1s;
    z-index: 2;
}

.gift-container {
    position: absolute;
    top: 50%; /* Center start */
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.gift-box {
    width: 100px;
    height: 100px;
}

.hidden {
    display: none;
}

.controls {
    text-align: center;
    z-index: 5;
}

.instruction {
    color: var(--white);
    margin-bottom: 15px;
    font-size: 1.1rem;
    text-shadow: 0 2px 2px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.3);
    padding: 10px 20px;
    border-radius: 20px;
}

/* Animations */
.shake-anim {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both infinite;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0) rotate(-1deg); }
    20%, 80% { transform: translate3d(2px, 0, 0) rotate(2deg); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0) rotate(-4deg); }
    40%, 60% { transform: translate3d(4px, 0, 0) rotate(4deg); }
}

.drop-anim {
    animation: drop 1s ease-out forwards;
}

@keyframes drop {
    0% { top: -200px; opacity: 0; }
    60% { top: 60%; opacity: 1; }
    80% { top: 45%; }
    100% { top: 50%; }
}

/* --- Result Screen --- */
.result-card {
    background: rgba(255,255,255, 0.95);
    border: 4px solid var(--primary-color);
}

.congrats {
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.gift-reveal {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gift-opened {
    width: 150px;
    transition: all 0.5s ease;
}

.prize-actual-img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin-top: -30px; /* Chồng lên hộp quà xíu cho đẹp */
    z-index: 2;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
    animation: zoomIn 0.8s ease-out;
}

/* Style cho giải thưởng là văn bản (Câu chúc) */
.prize-text {
    font-family: 'Mountains of Christmas', cursive;
    font-size: 2.2rem;
    color: var(--primary-color);
    text-align: center;
    padding: 20px;
    margin-top: 10px;
    animation: zoomIn 0.8s ease-out;
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

@keyframes pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes zoomIn {
    0% { transform: scale(0.5) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.gift-name {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    margin-top: 10px;
}

.wish-box {
    font-style: italic;
    color: #666;
    margin-bottom: 30px;
    padding: 10px;
    border-top: 1px dashed #ccc;
    border-bottom: 1px dashed #ccc;
}

/* --- Admin Styles --- */
#screen-admin-dashboard {
    display: none;
    background: #f4f6f8;
    color: #333;
    overflow-y: auto;
    padding: 0;
}
#screen-admin-dashboard.active {
    display: block;
}

.admin-layout {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

.admin-header {
    background: #333;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: #eee;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.tab-btn.active {
    background: white;
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 20px;
}
.tab-content.active {
    display: block;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

th {
    background-color: #f8f8f8;
}

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.gift-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    border: 1px solid #eee;
    padding: 10px;
    background: #fff;
    flex-wrap: wrap;
}
.gift-row input {
    flex: 1;
    min-width: 80px;
}
.btn-small {
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    background: #ccc;
}
.btn-danger {
    background: #ff4d4f;
    color: white;
}