/* =================全域變數與基礎================= */
:root {
    --primary: #6a11cb;
    --secondary: #2575fc;
    --accent: #ff6a00;
    --accent-hover: #ee0979;
    --bg-dark: #0f0f1b;
    --bg-light: #1c1c3c;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --radius: 20px;
    --font: 'Inter', 'Noto Sans TC', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0; font-family: var(--font);
    color: var(--text-main);
    background: radial-gradient(circle at top, var(--bg-light), var(--bg-dark));
    min-height: 100vh; display: flex; justify-content: center; align-items: flex-start;
    overflow-x: hidden; padding: 20px 10px;
}

#app { width: 100%; max-width: 1000px; display: flex; justify-content: center; }

/* =================通用排版工具================= */
.w-full { width: 100%; }
.max-w-lg { max-width: 700px; width: 100%; }
.max-w-md { max-width: 500px; width: 100%; }
.margin-auto { margin-left: auto; margin-right: auto; }
.relative { position: relative; }
.mt-5 { margin-top: 5px; } .mt-10 { margin-top: 10px; } .mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; } .mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; } .mb-15 { margin-bottom: 15px; } .mb-20 { margin-bottom: 20px; }
.text-left { text-align: left; } .text-center { text-align: center; }
.text-gray { color: var(--text-muted); }
.text-red { color: #ff4d4d !important; }
.border-red { border: 1px solid rgba(255, 77, 77, 0.4) !important; }
.border-sec { border: 1px solid rgba(37, 117, 252, 0.4) !important; }
.text-2xl { font-size: 26px; line-height: 1.4; } .text-xl { font-size: 20px; }
.font-bold { font-weight: bold; }
.flex-row { display: flex; gap: 10px; align-items: center; }
.flex-grow { flex-grow: 1; } .shrink-0 { flex-shrink: 0; }
.hidden { display: none !important; }

/* =================提示窗 Toast================= */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white; padding: 12px 25px; border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); z-index: 9999;
    font-weight: 600; font-size: 16px;
    animation: slideDown 0.3s ease-out;
}
@keyframes slideDown { from { top: -50px; opacity: 0; } to { top: 20px; opacity: 1; }}

/* =================卡片與進階 Grid 佈局================= */
.glass-card {
    background: var(--glass-bg); backdrop-filter: blur(20px); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow);
    text-align: center; width: 100%; max-width: 500px; animation: fadeIn 0.4s ease-out;
}
.full-card { max-width: 1000px; width: 100%; }

.dashboard-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: stretch; }
.editor-layout { display: grid; grid-template-columns: 5fr 4fr; gap: 25px; align-items: start; }

.box-panel { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border); border-radius: 15px; padding: 20px; }
.header-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--glass-border); padding-bottom: 15px; }
.header-bar h2, .header-bar h3 { margin: 0; }

.badge { display: inline-block; padding: 5px 12px; background: rgba(37, 117, 252, 0.2); border: 1px solid var(--secondary); border-radius: 20px; font-size: 14px; font-weight: bold; }

/* =================輸入控制元件================= */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
    padding: 12px 15px; border-radius: 10px; border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.4); color: #fff; font-size: 15px;
    outline: none; transition: border 0.3s; font-family: var(--font);
}
input:focus, textarea:focus, select:focus { border-color: var(--secondary); }
.small-input { padding: 8px 10px; font-size: 14px; }
.large-input { font-size: 18px; font-weight: 600; padding: 15px; }
.large-select { font-size: 16px; padding: 12px; }

/* =================按鈕================= */
button {
    padding: 12px 20px; border-radius: 12px; border: none; cursor: pointer;
    font-weight: 700; font-size: 15px; transition: transform 0.2s, background 0.3s, box-shadow 0.2s; color: #fff;
}
button:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
button:active { transform: scale(0.96); }
.primary-btn { background: linear-gradient(45deg, var(--primary), var(--secondary)); }
.secondary-btn { background: linear-gradient(45deg, var(--accent), var(--accent-hover)); }
.action-btn { background: rgba(255, 255, 255, 0.1); border: 1px solid var(--glass-border); }
.action-btn:hover { background: rgba(255, 255, 255, 0.2); }
.text-btn { background: transparent; color: var(--text-muted); padding: 5px 10px; font-size: 14px; }
.text-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.small-btn { padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.button-group { display: flex; gap: 15px; }

/* =================單選按鈕(Segment Control)================= */
.segment-control { display: flex; gap: 10px; }
.segment-control.block-segment { flex-direction: column; }
.segment-control label {
    flex: 1; cursor: pointer; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border);
    border-radius: 10px; padding: 10px; text-align: center; transition: 0.3s;
}
.segment-control input[type="radio"] { display: none; }
.segment-control input[type="radio"]:checked + span { color: #fff; font-weight: bold; }
.segment-control input[type="radio"]:checked ~ label, 
.segment-control label:has(input:checked) { background: var(--primary); border-color: var(--secondary); }

/* =================儀表板與清單================= */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.dashboard-item {
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 15px;
    padding: 20px 15px; cursor: pointer; transition: 0.3s;
}
.dashboard-item:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-3px); }
.dashboard-item .icon { font-size: 36px; margin-bottom: 5px; }
.dashboard-item h3 { margin: 0 0 5px 0; font-size: 16px; }
.dashboard-item p { margin: 0; font-size: 12px; color: var(--text-muted); }

.list-container { background: rgba(0, 0, 0, 0.2); border-radius: 10px; border: 1px solid var(--glass-border); padding: 5px; }
.scrollable-list { max-height: 50vh; overflow-y: auto; }
.list-clear { background: transparent; border: none; padding: 0; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: 1px solid var(--glass-border); }
.list-item:last-child { border-bottom: none; }
.list-columns li { display: inline-block; width: 48%; margin-bottom: 10px; }

/* =================大廳與宮格================= */
.mega-grid { display: grid; gap: 10px; margin: 0 auto; max-width: 450px; width: 100%; }
.mega-grid.grid-9 { grid-template-columns: repeat(3, 1fr); aspect-ratio: 1; }
.mega-grid.grid-16 { grid-template-columns: repeat(4, 1fr); aspect-ratio: 1; }
.grid-item {
    background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border); border-radius: 12px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    cursor: pointer; transition: 0.3s; font-size: 20px; font-weight: bold; position: relative; overflow: hidden; padding: 5px; text-align: center;
}
.grid-item:hover { background: rgba(255, 255, 255, 0.15); transform: scale(1.05); }
.grid-item.completed { background: linear-gradient(135deg, rgba(82,10,156,0.6), rgba(30,95,206,0.6)); cursor: default; }
.grid-item.completed:hover { transform: none; }
.winner-badge { font-size: 11px; background: var(--accent); padding: 2px 6px; border-radius: 10px; position: absolute; bottom: 8px; }

.grid-item.bingo { box-shadow: 0 0 15px #ff6a00 inset; border: 2px solid #ff6a00; animation: bingoPulse 1s infinite alternate; }
@keyframes bingoPulse { from { transform: scale(1); } to { transform: scale(1.05); } }

/* =================遊戲進行================= */
.game-container { text-align: center; }
.game-header { position: relative; display: flex; flex-direction: column; align-items: center; }
#timer-bar { width: 100%; height: 12px; background: rgba(0,0,0,0.6); border-radius: 10px; overflow: hidden; }
#timer-progress { width: 100%; height: 100%; background: linear-gradient(90deg, #ff6a00, #ee0979); transition: width 0.1s linear; }
.time-badge { font-size: 24px; font-weight: 800; background: var(--accent); padding: 5px 20px; border-radius: 20px; margin-top: 10px; display: inline-block; box-shadow: 0 4px 10px rgba(0,0,0,0.4); }

.media-container { width: 100%; border-radius: 20px; overflow: hidden; background: #000; display: flex; justify-content: center; align-items: center; }
.shadow-glow { box-shadow: 0 5px 25px rgba(255,255,255,0.05); }
.media-container iframe { width: 100%; aspect-ratio: 16/9; border: none; }
.media-container img { max-width: 100%; max-height: 40vh; object-fit: contain; }

.current-q-box { background: rgba(0,0,0,0.3); padding: 25px 20px; border-radius: 20px; border: 1px solid var(--glass-border); width: 100%; margin: 15px 0; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.option-item {
    padding: 30px 20px; border-radius: 20px; background: rgba(255,255,255,0.05); color: #fff;
    cursor: pointer; font-weight: 800; font-size: 18px; border: 3px solid transparent; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; min-height: 100px; line-height: 1.3;
}
.option-item:hover { background: rgba(255,255,255,0.15); transform: translateY(-4px) scale(1.02); box-shadow: 0 10px 20px rgba(0,0,0,0.3); }
.option-item:active { transform: scale(0.95); }
.option-item.disabled { pointer-events: none; opacity: 0.5; filter: grayscale(1); }
.option-item:nth-child(1) { border-top-color: #e21b3c; background: linear-gradient(180deg, rgba(226,27,60,0.1) 0%, transparent 100%); }
.option-item:nth-child(2) { border-top-color: #1368ce; background: linear-gradient(180deg, rgba(19,104,206,0.1) 0%, transparent 100%); }
.option-item:nth-child(3) { border-top-color: #d89e00; background: linear-gradient(180deg, rgba(216,158,0,0.1) 0%, transparent 100%); }
.option-item:nth-child(4) { border-top-color: #26890c; background: linear-gradient(180deg, rgba(38,137,12,0.1) 0%, transparent 100%); }

/* =================動畫================= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.highlight { color: #ff6a00; font-size: 1.2em; font-weight: bold; }
.ux-tip { font-size: 12px; color: var(--text-muted); text-align: left; display: block; margin-bottom: 5px; }
.winner-anim { font-size: 32px; font-weight: 800; color: #ff6a00; margin: 20px 0; animation: celebrate 1s infinite alternate; }
@keyframes celebrate { from { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255,106,0,0.5)); } to { transform: scale(1.1); filter: drop-shadow(0 0 15px rgba(255,106,0,0.9)); } }
.pulse-anim { animation: timePulse 1s infinite alternate; }
@keyframes timePulse { from { transform: scale(1); } to { transform: scale(1.05); box-shadow: 0 0 15px #ff6a00; } }

/* =================RWD ================= */
@media screen and (max-width: 768px) {
    .dashboard-layout, .editor-layout, .options-grid { grid-template-columns: 1fr; }
    .glass-card { padding: 20px; }
    .button-group, .flex-row { flex-direction: column; align-items: stretch; }
    .header-bar { flex-direction: column; gap: 10px; align-items: flex-start; }
    .header-bar button { align-self: flex-end; }
    .list-columns li { width: 100%; }
    .option-item { min-height: 80px; padding: 15px; font-size: 16px; }
}
