/* ================================================================
   game.css — Player game UI styles
   Chat-bubble layout, mobile-first, dark by default
   ================================================================ */

/* ── Layout ───────────────────────────────────────────────────── */
.game-body {
    background-color: var(--bg-primary);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding-top: var(--safe-top);
}

.game-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 60%;
}

.game-timer {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.game-timer.text-danger { color: var(--accent-red) !important; }

.game-progress {
    height: 2px !important;
    border-radius: 0 !important;
    background-color: var(--border-color);
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Screens ──────────────────────────────────────────────────── */
.game-screen {
    flex: 1;
    min-height: 0;
}

#chatScreen {
    display: flex;
    flex-direction: column;
}

/* ── Bubble container (scrollable) ────────────────────────────── */
.bubble-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

/* ── Bubbles ──────────────────────────────────────────────────── */
.bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1.1rem;
    font-size: 0.95rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bubble-left {
    align-self: flex-start;
    width: 90%;
}

.bubble-right {
    align-self: flex-end;
    max-width: 75%;
}

/* Story / narrative bubble */
.bubble-story {
    background: #1e3a5f;
    color: #d4e4f0;
    border-bottom-left-radius: 0.3rem;
}

/* Question bubble */
.bubble-question {
    background: #3a3520;
    color: #f0e8c8;
    border-bottom-left-radius: 0.3rem;
}

/* Player answer bubble */
.bubble-answer {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 0.3rem;
    font-style: italic;
}

/* Default bubble (button, camera, etc.) */
.bubble-default {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-bottom-left-radius: 0.3rem;
}

/* Image bubble */
.bubble-image {
    padding: 0.3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 75%;
}

.bubble-img {
    width: 100%;
    max-width: 320px;
    border-radius: calc(var(--radius-lg) - 2px);
    display: block;
}

/* Admin message bubble */
.bubble-admin-msg {
    background: rgba(13, 110, 253, 0.12);
    border: 1px solid rgba(13, 110, 253, 0.3);
    color: var(--text-primary);
    align-self: flex-start;
    width: 90%;
}

/* Wrong answer bubble */
.bubble-answer-wrong {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-bottom-right-radius: 0.3rem;
    text-decoration: line-through;
    font-style: italic;
    opacity: 0.7;
}

/* Slide-in animation for new bubbles */
.bubble-new {
    animation: bubbleSlideIn 0.35s ease-out;
}

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

/* ── Input bar (sticky bottom) ────────────────────────────────── */
.input-bar {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    padding-bottom: calc(var(--safe-bottom) + 0.75rem);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

.input-bar .form-control-lg {
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* Shake animation for wrong answers */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* ── Hints ────────────────────────────────────────────────────── */
.hints-list .alert {
    border-radius: var(--radius-sm);
}

/* ── Camera ───────────────────────────────────────────────────── */
.camera-preview {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-surface);
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cameraVideo {
    border-radius: var(--radius-lg);
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: #000;
}

/* ── Complete card (inline in bubble flow) ─────────────────────── */
.bubble-complete {
    text-align: center;
    padding: 2rem 1.5rem;
    margin: 1rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    animation: bubbleSlideIn 0.5s ease-out;
}

.complete-stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

/* ── Rating stars ─────────────────────────────────────────────── */
.rating-star-btn {
    background: transparent;
    border: none;
    padding: 0.25rem;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: transform 0.1s ease;
}
.rating-star-btn:hover {
    transform: scale(1.15);
}
.rating-star-btn .text-warning {
    color: #ffc107 !important;
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

/* ── Loading spinner ──────────────────────────────────────────── */
#loadingScreen {
    background-color: var(--bg-primary);
}

/* ── Mobile refinements ───────────────────────────────────────── */
@media (max-width: 480px) {
    .bubble-container {
        padding: 0.75rem 0.75rem 0.5rem;
    }
    .bubble {
        font-size: 0.9rem;
    }
    .game-title {
        font-size: 0.8rem;
    }
}

/* ── Large screen centering ───────────────────────────────────── */
@media (min-width: 768px) {
    .bubble-container {
        padding: 1.5rem 0 0.5rem;
    }
}

/* ── Game modals ──────────────────────────────────────────────── */
.game-modal .modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
}
.game-modal .modal-header,
.game-modal .modal-footer {
    border-color: var(--border-color);
}
.game-modal .modal-title {
    color: var(--text-primary);
    font-size: 1rem;
}
.game-modal .modal-body {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ── Audio player bar ──────────────────────────────────────────── */
.audio-player-bar {
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 0.6rem 1rem;
}
#audioPlayer {
    color-scheme: dark;
    border-radius: var(--radius-sm);
}
html[data-bs-theme="light"] #audioPlayer {
    color-scheme: light;
}

/* ── Webhook repeat bar ────────────────────────────────────────── */
.webhook-repeat-bar {
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

/* ── Light mode bubble overrides ──────────────────────────────── */
@media (prefers-color-scheme: light) {
    .bubble-story {
        background: #c8dae8;
        color: #1a2a3a;
    }
    .bubble-question {
        background: #f5ecd0;
        color: #3a3520;
    }
    .bubble-answer {
        background: #e8eaed;
        color: #1a1a1a;
        border-color: #d0d0d0;
    }
    .bubble-default {
        background: #e0e0e0;
        color: #333;
    }
}

/* ── Manual theme — light (overrides media query) ─────────────── */
html[data-bs-theme="light"] .bubble-story {
    background: #c8dae8;
    color: #1a2a3a;
}
html[data-bs-theme="light"] .bubble-question {
    background: #f5ecd0;
    color: #3a3520;
}
html[data-bs-theme="light"] .bubble-answer {
    background: #e8eaed;
    color: #1a1a1a;
    border-color: #d0d0d0;
}
html[data-bs-theme="light"] .bubble-default {
    background: #e0e0e0;
    color: #333;
}

/* ── Manual theme — dark (overrides media query when system is light) ── */
html[data-bs-theme="dark"] .bubble-story {
    background: #1e3a5f;
    color: #d4e4f0;
}
html[data-bs-theme="dark"] .bubble-question {
    background: #3a3520;
    color: #f0e8c8;
}
html[data-bs-theme="dark"] .bubble-answer {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}
html[data-bs-theme="dark"] .bubble-default {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* ── Report-problem button (header) ─────────────────────────────── */
.report-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 4px 10px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(220, 53, 69, 0.55);
    background: rgba(220, 53, 69, 0.10);
    color: #dc3545;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    position: relative;
    white-space: nowrap;
}
.report-btn:hover,
.report-btn:focus-visible {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
    outline: none;
}
.report-btn:active {
    transform: scale(0.96);
}
.report-btn .bi-flag-fill {
    font-size: 0.85rem;
}
.report-btn-label {
    font-size: 0.78rem;
}
@media (max-width: 480px) {
    .report-btn-label { display: none; }
    .report-btn {
        padding: 0;
        width: 32px;
        height: 32px;
        justify-content: center;
        gap: 0;
    }
}
.report-btn-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ffc107;
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg-body, #0d0d0d);
}

html[data-bs-theme="dark"] .report-btn {
    background: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.5);
    color: #ff6b78;
}
html[data-bs-theme="dark"] .report-btn:hover,
html[data-bs-theme="dark"] .report-btn:focus-visible {
    background: #dc3545;
    color: #fff;
}

/* ── Problem-report modal: chat bubbles ─────────────────────────── */
.report-messages {
    background: var(--bg-surface, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.5rem;
    padding: 0.5rem;
}
.report-messages .report-msg > div {
    word-break: break-word;
}
html[data-bs-theme="dark"] .report-messages {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}
