:root {
    --ck-primary: #0284c7;
    --ck-primary-dark: #0369a1;
    --ck-accent: #facc15;
    --ck-accent-dark: #ca8a04;
    --ck-bg: #f0f9ff;
    --ck-surface: #ffffff;
    --ck-text: #0f172a;
    --ck-text-muted: #64748b;
    --ck-bubble-user: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    --ck-bubble-user-text: #ffffff;
    --ck-bubble-bot: #ffffff;
    --ck-bubble-bot-text: #0f172a;
    --ck-border: #e2e8f0;
    --ck-radius: 18px;
}

[data-theme="verde"] {
    --ck-primary: #16a34a;
    --ck-primary-dark: #15803d;
    --ck-accent: #facc15;
    --ck-bg: #f0fdf4;
    --ck-bubble-user: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

[data-theme="morado"] {
    --ck-primary: #9333ea;
    --ck-primary-dark: #7e22ce;
    --ck-accent: #facc15;
    --ck-bg: #faf5ff;
    --ck-bubble-user: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Comic Neue', 'Plus Jakarta Sans', sans-serif;
    background: var(--ck-bg);
    color: var(--ck-text);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ===== HEADER ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ck-primary);
    background: linear-gradient(135deg, var(--ck-primary) 0%, var(--ck-primary-dark) 100%);
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.robot-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.robot-head {
    position: relative;
    width: 34px;
    height: 30px;
    background: #ffffff;
    border-radius: 10px;
    margin: 4px auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.robot-eye {
    position: absolute;
    top: 10px;
    width: 6px;
    height: 6px;
    background: var(--ck-primary-dark);
    border-radius: 50%;
    animation: ckBlink 3.2s infinite;
}

.robot-eye.left-eye { left: 8px; }
.robot-eye.right-eye { right: 8px; }

.robot-mouth {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 4px;
    background: var(--ck-accent-dark);
    border-radius: 0 0 6px 6px;
}

@keyframes ckBlink {
    0%, 92%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.1); }
}

.logo-container h1 {
    font-family: 'Fredoka One', 'Comic Neue', sans-serif;
    font-size: 18px;
    margin: 0;
    letter-spacing: 0.3px;
}

.menu-buttons {
    display: flex;
    gap: 6px;
}

.menu-buttons button {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.18);
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
}

.menu-buttons button:hover {
    background: rgba(255,255,255,0.32);
    transform: translateY(-1px);
}

.menu-buttons button.hidden-btn {
    display: none;
}

/* ===== MAIN CHAT AREA ===== */
.main-content {
    flex: 1;
    min-height: 0;
    display: flex;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--ck-bg);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}
.chat-history::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

.ck-msg-row {
    display: flex;
    width: 100%;
}

.ck-msg-row.user {
    justify-content: flex-end;
}

.ck-msg-row.bot {
    justify-content: flex-start;
}

.ck-msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--ck-radius);
    font-size: 14.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.ck-msg-row.user .ck-msg-bubble {
    background: var(--ck-bubble-user);
    color: var(--ck-bubble-user-text);
    border-bottom-right-radius: 4px;
}

.ck-msg-row.bot .ck-msg-bubble {
    background: var(--ck-bubble-bot);
    color: var(--ck-bubble-bot-text);
    border: 1.5px solid var(--ck-border);
    border-bottom-left-radius: 4px;
}

.ck-msg-image {
    max-width: 200px;
    border-radius: 12px;
    display: block;
}

.ck-welcome {
    text-align: center;
    color: var(--ck-text-muted);
    font-size: 13.5px;
    padding: 20px 10px;
}

.ck-welcome strong {
    display: block;
    font-size: 16px;
    color: var(--ck-text);
    margin-bottom: 6px;
    font-family: 'Fredoka One', sans-serif;
}

/* typing indicator */
.ck-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.ck-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ck-primary);
    opacity: 0.5;
    animation: ckTypingDot 1.1s infinite ease-in-out;
}

.ck-typing span:nth-child(2) { animation-delay: 0.15s; }
.ck-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ckTypingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== INPUT AREA ===== */
.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--ck-surface);
    border-top: 1.5px solid var(--ck-border);
    flex-shrink: 0;
}

.input-area textarea {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--ck-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14.5px;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.15s ease;
}

.input-area textarea:focus {
    border-color: var(--ck-primary);
}

.input-area button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

#send-btn {
    background: var(--ck-primary);
    color: #ffffff;
}

#send-btn:hover {
    background: var(--ck-primary-dark);
    transform: translateY(-1px);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#mic-btn {
    background: #f1f5f9;
    color: var(--ck-text-muted);
}

#mic-btn:hover {
    background: #e2e8f0;
}

#mic-btn.recording {
    background: #ef4444;
    color: #ffffff;
    animation: ckPulse 1s infinite;
}

@keyframes ckPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 16px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--ck-surface);
    border-radius: 20px;
    max-width: 360px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 22px 20px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.modal-content h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 17px;
    margin: 0 0 14px 0;
    color: var(--ck-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 14px;
    border: none;
    background: #f1f5f9;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--ck-text-muted);
    line-height: 1;
}

.close-modal:hover {
    background: #e2e8f0;
}

.help-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 13.5px;
    color: var(--ck-text);
}

.help-item i {
    color: var(--ck-primary);
    margin-top: 2px;
    width: 18px;
    text-align: center;
}

.theme-swatches {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.theme-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.theme-swatch:hover {
    transform: scale(1.08);
}

.theme-swatch.active {
    border-color: var(--ck-text);
}

.theme-swatch.azul { background: linear-gradient(135deg, #0284c7, #0369a1); }
.theme-swatch.verde { background: linear-gradient(135deg, #16a34a, #15803d); }
.theme-swatch.morado { background: linear-gradient(135deg, #9333ea, #7e22ce); }

.games-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.game-card {
    background: #f8fafc;
    border: 1.5px solid var(--ck-border);
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.game-card:hover {
    transform: translateY(-2px);
    border-color: var(--ck-primary);
}

.game-icon {
    font-size: 24px;
    color: var(--ck-primary);
    margin-bottom: 6px;
}

.game-card h3 {
    font-size: 13.5px;
    margin: 4px 0;
}

.game-card p {
    font-size: 11px;
    color: var(--ck-text-muted);
    margin: 0;
}

/* ===== GAME PLAYER OVERLAY ===== */
.game-player-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.game-player-window {
    background: #000;
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 640px;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.game-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1e293b;
    color: #fff;
    font-size: 13px;
}

.game-player-actions {
    display: flex;
    gap: 6px;
}

.gp-btn {
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
}

.gp-btn:hover {
    background: rgba(255,255,255,0.22);
}

.game-player-body {
    flex: 1;
    min-height: 0;
}

.game-player-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== EMPTY / UPLOAD STATE ===== */
.ck-upload-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0f9ff;
    border: 1.5px solid var(--ck-primary);
    color: var(--ck-primary-dark);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    margin-bottom: 6px;
}

.ck-upload-preview button {
    border: none;
    background: none;
    color: var(--ck-primary-dark);
    cursor: pointer;
    font-size: 13px;
}
