/* ==========================================================================
   Ateliê de Tintas — Misturar Cores (js/tintas.js)
   Baldes desenhados em canvas, papel de tinta e prateleira de cores.
   ========================================================================== */

#game-colormix { background: linear-gradient(180deg, #6f5bd1, #33265e); }
#game-colorsandbox { background: linear-gradient(180deg, #6f5bd1, #33265e); }

.tin-area {
    justify-content: flex-start;
    padding: 6px 8px 10px;
    gap: 0;
}

/* ---------------------------------------------------------- barra de modos */
.tin-modos {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 4px 0 2px;
}
.tin-modo {
    border: 0;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    background: rgba(255, 255, 255, .18);
    cursor: pointer;
    min-height: 40px;
    transition: transform .12s ease, background .18s ease;
}
.tin-modo:active { transform: scale(.94); }
.tin-modo.ativo {
    background: #fff;
    color: #4a3aa0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}

/* ============================== MODO ADIVINHAR ============================ */
.tin-cena-wrap {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 180px;
}
.tin-cena { width: 100%; height: 100%; display: block; }

.tin-nome-resultado {
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%) scale(.6);
    opacity: 0;
    background: #fff;
    color: #33265e;
    font-weight: 900;
    font-size: 20px;
    padding: 6px 20px;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    pointer-events: none;
    white-space: nowrap;
}
.tin-nome-resultado.aparece {
    animation: tinNomePop .45s cubic-bezier(.2, 1.5, .4, 1) forwards;
}
@keyframes tinNomePop {
    from { opacity: 0; transform: translateX(-50%) scale(.6); }
    to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

.tin-opcoes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 4px 4px;
    width: 100%;
}
.tin-opcao {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 3px solid rgba(255, 255, 255, .35);
    border-radius: 18px;
    background: rgba(255, 255, 255, .12);
    padding: 6px 8px 4px;
    cursor: pointer;
    transition: transform .12s ease, border-color .18s ease, background .18s ease;
}
.tin-opcao:active { transform: scale(.94); }
.tin-opcao canvas { display: block; }
.tin-opcao-nome {
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.tin-opcao.certa {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, .28);
    animation: tinCerta .5s ease;
}
.tin-opcao.errada {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, .22);
    opacity: .55;
    animation: tinErrada .35s ease;
}
@keyframes tinCerta {
    0%, 100% { transform: scale(1); }
    45%      { transform: scale(1.12); }
}
@keyframes tinErrada {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-7px); }
    75%      { transform: translateX(7px); }
}

/* ================================= ATELIÊ ================================= */
.tin-area-atelie { justify-content: flex-start; }

.tin-papel-wrap {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 150px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
}
.tin-papel {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: crosshair;
}

/* Grão de papel por cima da tinta: sem ele a mistura fica com cara de
   aerógrafo. Fica no compositor (multiply), não no laço de desenho. */
.tin-grao {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: multiply;
    opacity: .34;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 140px 140px;
}

.tin-cor-atual {
    position: absolute;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 22, 60, .78);
    border-radius: 999px;
    padding: 5px 14px 5px 6px;
    pointer-events: none;
    max-width: 90%;
}
.tin-cor-bolha {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .8);
    flex: 0 0 auto;
    transition: background .2s ease;
}
.tin-cor-nome {
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tin-cor-atual.brilha { animation: tinBrilha .8s ease; }
@keyframes tinBrilha {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 214, 0, 0); transform: translateX(-50%) scale(1); }
    40%      { box-shadow: 0 0 22px rgba(255, 214, 0, .95); transform: translateX(-50%) scale(1.12); }
}

.tin-limpar {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: rgba(30, 22, 60, .78);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}
.tin-limpar:active { transform: scale(.9); }

.tin-desfazer {
    position: absolute;
    right: 10px;
    top: 62px;
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: #ffd400;
    color: #33265e;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}
.tin-desfazer.some { animation: tinSome 5s ease forwards; }
@keyframes tinSome {
    0%, 80% { opacity: 1; transform: translateY(0); }
    100%    { opacity: 0; transform: translateY(-6px); }
}

.tin-dica {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    background: rgba(30, 22, 60, .8);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    padding: 7px 16px;
    border-radius: 999px;
    pointer-events: none;
    max-width: 92%;
    text-align: center;
    transition: opacity .4s ease;
}
.tin-dica.sumiu { opacity: 0; }

.tin-ferramentas {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 8px 0 4px;
    width: 100%;
}
.tin-ferr {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 46px;
    border: 3px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    padding: 4px 16px;
    cursor: pointer;
}
.tin-ferr span { font-size: 14px; }
.tin-ferr:active { transform: scale(.94); }
.tin-ferr.ativo {
    background: #fff;
    color: #33265e;
    border-color: #fff;
}

/* ------------------------------------------------------------ prateleira */
.tin-familias {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 2px 4px;
    flex-wrap: wrap;
}
.tin-familia-aba {
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 800;
    color: rgba(255, 255, 255, .82);
    background: rgba(255, 255, 255, .13);
    cursor: pointer;
    min-height: 32px;
}
.tin-familia-aba.ativa {
    background: #ffd400;
    color: #33265e;
}

.tin-prateleira {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 4px;
    width: 100%;
    padding: 4px 2px 2px;
}
.tin-balde {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 3px solid transparent;
    border-radius: 14px;
    background: rgba(255, 255, 255, .10);
    padding: 2px 3px 1px;
    cursor: pointer;
    width: 70px;
}
.tin-balde canvas { display: block; }
.tin-balde-nome {
    font-size: 9.5px;
    font-weight: 700;
    color: rgba(255, 255, 255, .92);
    width: 100%;
    line-height: 1.05;
    min-height: 20px;
    word-break: break-word;
    text-align: center;
}
.tin-balde.ativo {
    border-color: #ffd400;
    background: rgba(255, 255, 255, .26);
    box-shadow: 0 0 14px rgba(255, 212, 0, .6);
}
.tin-balde:active { transform: scale(.94); }

/* -------------------------------------------------------------- galeria */
.tin-galeria {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 8px;
    bottom: 8px;
    background: #191233;
    border-radius: 18px;
    padding: 12px;
    overflow-y: auto;
    z-index: 5;
}
.tin-galeria[hidden] { display: none; }
.tin-galeria-tit {
    color: #fff;
    font-weight: 900;
    font-size: 16px;
    text-align: center;
    margin-bottom: 10px;
}
.tin-galeria-grade {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 8px;
}
.tin-galeria-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.tin-galeria-bolha {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .6);
    font-weight: 900;
}
.tin-galeria-nome {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, .88);
    text-align: center;
    line-height: 1.15;
}
.tin-galeria-item.faltando .tin-galeria-nome { color: rgba(255, 255, 255, .45); }

.tin-controles {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 0 0 auto;
}

/* Celular deitado: papel de um lado, tintas do outro — empilhado, a prateleira
   ficava cortada pela base. */
@media (orientation: landscape) and (max-height: 520px) {
    .tin-area-atelie { flex-direction: row; align-items: stretch; gap: 8px; }
    .tin-papel-wrap { flex: 1 1 auto; min-height: 0; height: auto; }
    .tin-controles {
        width: 46%;
        max-width: 330px;
        overflow-y: auto;
        justify-content: flex-start;
    }
    .tin-dica {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    background: rgba(30, 22, 60, .8);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    padding: 7px 16px;
    border-radius: 999px;
    pointer-events: none;
    max-width: 92%;
    text-align: center;
    transition: opacity .4s ease;
}
.tin-dica.sumiu { opacity: 0; }

.tin-ferramentas { padding: 2px 0; }
    .tin-prateleira { padding-bottom: 8px; }
    /* cabeçalho do jogo come metade da tela deitada: comprime o que é nosso */
    .tin-modos { padding: 1px 0; }
    .tin-modo { padding: 4px 12px; min-height: 32px; font-size: 12px; }
    #game-colormix .game-instruction,
    #game-colorsandbox .game-instruction { font-size: 13px; padding: 2px 8px; }
}

/* Telas baixas (celular deitado / aparelho pequeno): encolhe o rodapé para o
   papel não sumir. */
@media (max-height: 620px) {
    .tin-balde { width: 56px; }
    .tin-balde canvas { width: 40px !important; height: 40px !important; }
    .tin-familia-aba { font-size: 11px; padding: 4px 10px; min-height: 28px; }
    .tin-ferr { min-height: 40px; font-size: 18px; }
    .tin-papel-wrap { min-height: 120px; }
}
