@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Noto+Sans+TC:wght@300;400;500;700;900&display=swap');

:root {
    --bg-primary: #F0EDE0; /* Soft Linen */
    --bg-glass: rgba(255, 255, 255, 0.7); /* Light semi-transparent card */
    --border-glass: rgba(35, 15, 12, 0.08); /* Coffee Bean border outline */
    --bg-glass-active: rgba(255, 255, 255, 0.9);
    --border-glass-active: rgba(35, 15, 12, 0.16);
    
    --text-primary: #230F0C; /* Coffee Bean */
    --text-secondary: #5E4D45; /* Deeper Ash Brown for accessibility */
    --text-muted: #8C7D75; /* Soft Muted Brown */
    
    --color-a: #230F0C; /* Coffee Bean */
    --color-b: #C03523; /* Flag Red */
    --color-c: #D16A43; /* Spicy Paprika */
    --color-d: #735F55; /* Ash Brown */
    
    --grad-a: linear-gradient(135deg, #230F0C 0%, #3D231E 100%);
    --grad-b: linear-gradient(135deg, #C03523 0%, #E04E3B 100%);
    --grad-c: linear-gradient(135deg, #D16A43 0%, #E8835B 100%);
    --grad-d: linear-gradient(135deg, #735F55 0%, #917C71 100%);
    
    --shadow-neon-a: 0 6px 15px rgba(35, 15, 12, 0.15);
    --shadow-neon-b: 0 6px 15px rgba(192, 53, 35, 0.2);
    --shadow-neon-c: 0 6px 15px rgba(209, 106, 67, 0.2);
    --shadow-neon-d: 0 6px 15px rgba(115, 95, 85, 0.15);
    
    --font-outfit: 'Outfit', 'Noto Sans TC', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: var(--font-outfit);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Background animated bubbles */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.bg-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(209, 106, 67, 0.04) 0%, rgba(209, 106, 67, 0) 70%);
    filter: blur(40px);
    animation: float 20s infinite ease-in-out;
}

.bg-bubble:nth-child(1) {
    width: 400px;
    height: 400px;
    top: -100px;
    left: -100px;
}

.bg-bubble:nth-child(2) {
    width: 500px;
    height: 500px;
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
    background: radial-gradient(circle, rgba(192, 53, 35, 0.03) 0%, rgba(192, 53, 35, 0) 70%);
}

.bg-bubble:nth-child(3) {
    width: 300px;
    height: 300px;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 25s;
    background: radial-gradient(circle, rgba(210, 150, 124, 0.04) 0%, rgba(210, 150, 124, 0) 70%);
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.1); }
}

/* Container & Header layout */
header {
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    font-style: italic;
}

.connection-badge {
    background: rgba(0, 230, 118, 0.15);
    border: 1px solid rgba(0, 230, 118, 0.3);
    color: var(--color-d);
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.connection-badge.disconnected {
    background: rgba(255, 51, 102, 0.15);
    border: 1px solid rgba(255, 51, 102, 0.3);
    color: var(--color-a);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.connection-dot.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
}

/* Glass Card */
.glass-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2.5rem;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Buttons */
.btn {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.9rem 1.8rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #D16A43 0%, #C03523 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(192, 53, 35, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(192, 53, 35, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass-active);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(239, 68, 68, 0.45);
}

.btn:active {
    transform: translateY(1px);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.input-text {
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-smooth);
}

.input-text::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.input-text:focus {
    border-color: #D16A43;
    box-shadow: 0 0 12px rgba(209, 106, 67, 0.25);
    background: #ffffff;
}

/* Portal Page / index.html */
.portal-title {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
    font-weight: 800;
}

.portal-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.portal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.portal-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.portal-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass-active);
    transform: translateY(-5px);
}

.portal-card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.portal-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.portal-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Student / Client layout */
.client-container {
    width: 100%;
    max-width: 500px;
}

.client-status-card {
    text-align: center;
    padding: 3rem 2rem;
}

.pulse-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    animation: breathe 2s infinite ease-in-out;
    display: inline-block;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

.client-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
}

.client-option-btn {
    min-height: 80px;
    height: auto;
    border-radius: 16px;
    border: none;
    font-family: var(--font-outfit);
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 1.25rem;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    text-align: left;
}

.client-option-btn:hover {
    transform: translateY(-3px) scale(1.01);
}

.client-option-btn.opt-a { background: var(--grad-a); }
.client-option-btn.opt-a:hover { box-shadow: var(--shadow-neon-a); }
.client-option-btn.opt-b { background: var(--grad-b); }
.client-option-btn.opt-b:hover { box-shadow: var(--shadow-neon-b); }
.client-option-btn.opt-c { background: var(--grad-c); }
.client-option-btn.opt-c:hover { box-shadow: var(--shadow-neon-c); }
.client-option-btn.opt-d { background: var(--grad-d); }
.client-option-btn.opt-d:hover { box-shadow: var(--shadow-neon-d); }

.client-option-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.client-option-btn.selected-choice {
    opacity: 1 !important;
    border: 3px solid white;
    transform: scale(1.02);
}

.choice-shape-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-shape-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.choice-text {
    flex-grow: 1;
    line-height: 1.4;
}

/* Host Panel Layout */
.host-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
}

@media (min-width: 900px) {
    .host-layout {
        grid-template-columns: 3fr 1fr;
        align-items: start;
    }
}

.host-main-panel {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2rem;
}

.host-sidebar {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.question-control-box {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.host-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.host-stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.host-stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-b);
}

.host-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.player-list-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 5px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.player-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.kick-btn {
    background: none;
    border: none;
    color: var(--color-a);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    transition: var(--transition-smooth);
}

.kick-btn:hover {
    background: rgba(255, 51, 102, 0.15);
}

/* Projection / Stats Screen Layout */
.stats-layout {
    width: 100%;
    max-width: 1300px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    min-height: 75vh;
}

.stats-lobby-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    width: 100%;
    align-items: center;
}

@media (min-width: 850px) {
    .stats-lobby-container {
        grid-template-columns: 4.5fr 5.5fr;
    }
}

.qr-code-card {
    background: white;
    padding: 2rem;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4), 0 0 40px rgba(209, 106, 67, 0.15);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.qr-placeholder {
    width: 250px;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 12px;
}

.qr-text-info {
    margin-top: 1.5rem;
    text-align: center;
    color: #230F0C; /* Coffee Bean */
}

.qr-url {
    font-size: 1.4rem;
    font-weight: 800;
    color: #C03523; /* Flag Red */
    margin-top: 0.5rem;
    word-break: break-all;
}

.lobby-players-box {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 2.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.lobby-players-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-players-count {
    background: rgba(209, 106, 67, 0.2); /* Spicy Paprika */
    border: 1px solid rgba(209, 106, 67, 0.3);
    color: var(--color-c); /* Toasted Almond */
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
}

.lobby-players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    align-content: start;
    overflow-y: auto;
    flex-grow: 1;
    max-height: 380px;
    padding-right: 5px;
}

.lobby-player-bubble {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 0.75rem;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes scaleIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Question Banner (Projection) */
.question-projection-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.stats-question-num {
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-b); /* Spicy Paprika */
    margin-bottom: 1rem;
}

.stats-question-text {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.4;
    white-space: pre-line;
    word-break: break-all;
}

/* Voting Progress screen */
.voting-status-box {
    text-align: center;
    padding: 3rem;
}

.voting-status-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(209, 106, 67, 0.08); /* Spicy Paprika */
    border: 3px dashed rgba(209, 106, 67, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    animation: rotateDashed 20s linear infinite;
    position: relative;
}

.voting-status-circle-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

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

.voting-count-num {
    font-size: 3.5rem;
    font-weight: 800;
    color: white;
}

.voting-count-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Chart Styles */
.chart-container {
    width: 100%;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-bar-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-glass);
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(35, 15, 12, 0.02);
    position: relative;
    overflow: visible;
}

.chart-bar-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chart-bar-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    flex-grow: 1;
    text-align: left;
}

.chart-bar-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.chart-bar-shape {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-bar-shape.opt-a { background: var(--grad-a); }
.chart-bar-shape.opt-b { background: var(--grad-b); }
.chart-bar-shape.opt-c { background: var(--grad-c); }
.chart-bar-shape.opt-d { background: var(--grad-d); }

.chart-bar-shape svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.chart-bar-track {
    flex-grow: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    width: 0; /* Dynamic */
    transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 6px;
}

.chart-bar-fill.opt-a { background: var(--grad-a); box-shadow: var(--shadow-neon-a); }
.chart-bar-fill.opt-b { background: var(--grad-b); box-shadow: var(--shadow-neon-b); }
.chart-bar-fill.opt-c { background: var(--grad-c); box-shadow: var(--shadow-neon-c); }
.chart-bar-fill.opt-d { background: var(--grad-d); box-shadow: var(--shadow-neon-d); }

.chart-label-text {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: white;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 1rem;
}

.chart-bar-votes {
    width: 80px;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: right;
}

.chart-bar-votes.opt-a { color: var(--color-a); }
.chart-bar-votes.opt-b { color: var(--color-b); }
.chart-bar-votes.opt-c { color: var(--color-c); }
.chart-bar-votes.opt-d { color: var(--color-d); }

/* Custom SVGs for standard shape usage */
.icon-svg {
    width: 100%;
    height: 100%;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(239, 68, 68, 0.9);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: white;
    padding: 0.8rem 1.6rem;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.toast-success {
    background: rgba(16, 185, 129, 0.9);
    border-color: rgba(16, 185, 129, 0.2);
}

/* Game Over Card */
.game-over-card {
    text-align: center;
    padding: 3.5rem 2.5rem;
}

.game-over-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.game-over-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.game-over-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
