/* 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

/* 開始畫面 */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.start-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.start-content {
    text-align: center;
}

.start-content h1 {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(90deg, #ffd700, #ff6b6b, #ffd700);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    margin-bottom: 10px;
}

.start-content p {
    font-size: 1.5rem;
    color: #aaa;
    margin-bottom: 40px;
}

.start-btn {
    padding: 20px 60px;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    background: linear-gradient(90deg, #ffd700, #ff6b6b);
    color: #1a1a2e;
    box-shadow: 0 5px 30px rgba(255, 215, 0, 0.5);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.start-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.7);
}

.start-btn:active {
    transform: translateY(0) scale(1);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

/* 標題 */
.title {
    font-size: 3.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #ffd700, #ff6b6b, #ffd700);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 30px;
}

@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* 剩餘次數 */
.remaining {
    font-size: 1.1rem;
    color: #88d9e6;
    margin-bottom: 30px;
}

#remaining-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

/* 中獎者姓名 */
.winner-name {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.winner-name.show {
    animation: nameReveal 0.5s ease-out;
}

@keyframes nameReveal {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 老虎機區域 */
.slot-machine {
    background: linear-gradient(180deg, #2a2a4a 0%, #1a1a3a 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    margin-bottom: 30px;
}

.slot-container {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.slot {
    width: 100px;
    height: 120px;
    background: linear-gradient(180deg, #0d0d1a 0%, #1a1a2e 100%);
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        inset 0 5px 20px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(255, 215, 0, 0.2);
    border: 3px solid #333;
    position: relative;
}

.slot::before,
.slot::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 30px;
    pointer-events: none;
    z-index: 10;
}

.slot::before {
    top: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
}

.slot::after {
    bottom: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, transparent 100%);
}

.slot-window {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.slot-reel {
    position: absolute;
    width: 100%;
}

.slot-number {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* 停止時的高亮效果 */
.slot.stopped {
    border-color: #ffd700;
    box-shadow:
        inset 0 5px 20px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(255, 215, 0, 0.6);
}

.slot.stopped .slot-number {
    animation: pulse 0.5s ease-in-out;
}

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

/* 最終完成的華麗效果 */
.slot.final {
    animation: finalGlow 1s ease-in-out infinite alternate;
}

@keyframes finalGlow {
    0% {
        box-shadow:
            inset 0 5px 20px rgba(0, 0, 0, 0.8),
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 107, 107, 0.4);
    }
    100% {
        box-shadow:
            inset 0 5px 20px rgba(0, 0, 0, 0.8),
            0 0 50px rgba(255, 215, 0, 0.8),
            0 0 100px rgba(255, 107, 107, 0.6);
    }
}

/* 按鈕 */
.buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary {
    background: linear-gradient(90deg, #ffd700, #ff6b6b);
    color: #1a1a2e;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #666;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    color: #aaa;
    border: 2px solid #444;
}

.btn-secondary:hover:not(:disabled) {
    border-color: #888;
    color: #fff;
}

.btn-secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 歷史紀錄 */
.history-section {
    text-align: left;
}

.history-section h2 {
    font-size: 1.3rem;
    color: #88d9e6;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-index {
    width: 30px;
    height: 30px;
    background: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #888;
    margin-right: 15px;
    flex-shrink: 0;
}

.history-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    margin-right: 15px;
    min-width: 80px;
}

.history-numbers {
    display: flex;
    gap: 10px;
}

.history-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2a2a4a, #1a1a3a);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffd700;
    border: 1px solid #444;
}

.history-item:first-child {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.history-item:first-child .history-number {
    color: #fff;
    background: linear-gradient(135deg, #ffd700, #ff6b6b);
}

/* 煙火容器 */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

/* 煙火粒子 */
.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

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

/* 彩帶 */
.confetti {
    position: absolute;
    width: 10px;
    height: 20px;
    animation: fall 3s ease-in-out forwards;
}

@keyframes fall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 空狀態 */
.empty-history {
    text-align: center;
    color: #666;
    padding: 30px;
    font-style: italic;
}

/* 結束訊息 */
.end-message {
    text-align: center;
    padding: 20px;
    background: rgba(255, 107, 107, 0.2);
    border-radius: 10px;
    color: #ff6b6b;
    margin-top: 20px;
}

/* 響應式 */
@media (max-width: 500px) {
    .title {
        font-size: 2.5rem;
    }

    .slot {
        width: 70px;
        height: 90px;
    }

    .slot-number {
        height: 90px;
        font-size: 2rem;
    }

    .btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .history-number {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* 滾動條樣式 */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* 中獎者特效遮罩 */
.winner-overlay {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    height: 200px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.winner-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    animation: overlayFadeIn 0.5s ease-out forwards;
}

.winner-overlay.hide {
    opacity: 1;
    visibility: visible;
    background: rgba(0, 0, 0, 0.9);
    animation: overlayFadeOut 0.4s ease-out 0.5s forwards;
}

@keyframes overlayFadeIn {
    0% {
        background: rgba(0, 0, 0, 0);
    }
    100% {
        background: rgba(0, 0, 0, 0.9);
    }
}

@keyframes overlayFadeOut {
    0% {
        background: rgba(0, 0, 0, 0.9);
        opacity: 1;
    }
    100% {
        background: rgba(0, 0, 0, 0);
        opacity: 0;
    }
}

/* Winner 標題 */
.winner-title {
    position: absolute;
    top: 10px;
    left: 10%;
    font-size: 2.5rem;
    font-weight: bold;
    color: rgba(255, 215, 0, 0.9);
    letter-spacing: 10px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateX(100vw);
}

.winner-overlay.show .winner-title {
    animation: titleSlideIn 0.5s ease-out 0.3s forwards;
}

.winner-overlay.hide .winner-title {
    animation: titleSlideOut 0.5s ease-in forwards;
}

@keyframes titleSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100vw);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes titleSlideOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-100vw);
    }
}

/* 中獎者姓名顯示 */
.winner-name-display {
    font-size: 5rem;
    font-weight: bold;
    color: #fff;
    text-shadow:
        0 0 30px rgba(255, 215, 0, 0.8),
        0 0 60px rgba(255, 215, 0, 0.5),
        0 0 100px rgba(255, 107, 107, 0.4);
    opacity: 0;
    transform: translateX(-100vw);
}

.winner-overlay.show .winner-name-display {
    animation: nameSlideIn 0.5s ease-out 0.3s forwards;
}

.winner-overlay.hide .winner-name-display {
    animation: nameSlideOut 0.5s ease-in forwards;
}

@keyframes nameSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-100vw);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes nameSlideOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(100vw);
    }
}

/* 手機版調整 */
@media (max-width: 500px) {
    .winner-overlay {
        height: 150px;
    }

    .winner-name-display {
        font-size: 2.5rem;
    }

    .winner-title {
        font-size: 1.8rem;
        letter-spacing: 6px;
    }
}

/* 名單按鈕 */
.list-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.list-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

/* Modal 通用樣式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(180deg, #2a2a4a 0%, #1a1a3a 100%);
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-large {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}

.modal-header h3 {
    margin: 0;
    color: #ffd700;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body input[type="password"],
.modal-body input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid #333;
    border-radius: 8px;
    background: #1a1a2e;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.modal-body input:focus {
    border-color: #ffd700;
}

.error-msg {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 10px;
    min-height: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #333;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-primary {
    background: linear-gradient(90deg, #ffd700, #ff6b6b);
    color: #1a1a2e;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.modal-btn-secondary {
    background: transparent;
    color: #aaa;
    border: 1px solid #444;
}

.modal-btn-secondary:hover {
    border-color: #888;
    color: #fff;
}

/* 編輯器工具列 */
.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.toolbar-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #4a4a6a;
    color: #fff;
    transition: background 0.2s;
}

.toolbar-btn:hover {
    background: #5a5a7a;
}

.employee-count {
    color: #888;
    font-size: 0.9rem;
}

/* 員工清單 */
.employee-list {
    max-height: 400px;
    overflow-y: auto;
}

.employee-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.employee-item input {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.95rem;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1a1a2e;
    color: #fff;
    outline: none;
}

.employee-item input:focus {
    border-color: #ffd700;
}

.employee-item .name-input {
    flex: 1.5;
}

.employee-item .number-input {
    width: 50px;
    text-align: center;
}

.employee-item .delete-btn {
    padding: 6px 10px;
    font-size: 1rem;
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.employee-item .delete-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}

/* 員工清單滾動條 */
.employee-list::-webkit-scrollbar {
    width: 6px;
}

.employee-list::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 3px;
}

.employee-list::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.employee-list::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* 手機版 Modal 調整 */
@media (max-width: 500px) {
    .modal-large {
        max-height: 90vh;
    }

    .employee-item {
        flex-wrap: wrap;
    }

    .employee-item .name-input {
        flex: 1 1 100%;
        margin-bottom: 8px;
    }

    .employee-item .number-input {
        width: 45px;
    }
}

/* Toast 通知 */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 20000;
}

.toast {
    background: linear-gradient(135deg, #2a2a4a 0%, #1a1a3a 100%);
    border: 1px solid #ffd700;
    border-radius: 10px;
    padding: 15px 25px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    color: #ffd700;
    font-size: 1.3rem;
}

.toast-message {
    color: #fff;
}

/* 錯誤樣式 */
.toast.error {
    border-color: #ff6b6b;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 107, 107, 0.2);
}

.toast.error .toast-icon {
    color: #ff6b6b;
}

@media (max-width: 500px) {
    .toast-container {
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    .toast {
        width: 100%;
        justify-content: center;
    }
}
