body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #1a1a1a;
    width: 100vw;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', sans-serif;
    touch-action: none;
    position: relative;
}

/* BACKGROUND FULLSCREEN */
body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
	background: #FFBF55;
    background-image: url('img/background.png'); 
    background-size: cover;
    background-position: bottom center;
    background-repeat: no-repeat;
    z-index: -1;
}

#game-container {
    position: relative;
    background: #fffbe6b0;
	border: 4px solid #fff;
	border-radius: 20px;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    overflow: hidden;
    max-width: 360px;
    max-height: 640px;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#toasty-guy {
    position: fixed; /* Fixa na tela, independente do scroll ou do jogo */
    bottom: 0;
    right: 0;
    z-index: 9999; /* Garante que fique acima do jogo */
    
    /* Estado inicial: escondido para baixo e para direita */
    transform: translateX(100%); 
    
    /* Animação suave de entrada e saída */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    
    /* Evita que o jogador clique nele sem querer */
    pointer-events: none; 
}

#toasty-guy img {
    width: 320px;
    height: 400px;
    display: block;
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    #toasty-guy img {
        width: 240px;
        height: 300px;
    }
}

/* Classe que ativa a aparição */
#toasty-guy.appear {
    transform: translateX(0); /* Traz para a posição visível */
}

/* LOADING SCREEN */
#loading-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #222;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #555;
    border-top: 4px solid #FA0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* UI ELEMENTS */
#ui-layer {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.9);
    padding: 8px;
    border-radius: 12px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
    z-index: 10;
}

#ui-label { font-size: 10px; color: #555; font-weight: 800; letter-spacing: 0.5px; }

#next-fruit-display {
    width: 35px;
    height: 35px;
    margin-top: 5px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#score-board {
    position: absolute;
    top: 15px;
    left: 20px;
    pointer-events: none;
    z-index: 10;
}

#score-label { font-size: 11px; color: #999; font-weight: bold; display: block; }
#score-val { font-size: 36px; font-weight: 900; color: #444; line-height: 1; text-shadow: 2px 2px 0 #fff; }

#game-over {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(30,30,30,0.96);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10000;
	pointer-events: auto;
}

#game-over button {
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    background: #ffcc00;
    color: #222;
    border: none;
    border-radius: 50px;
    text-transform: uppercase;
}

/* --- TELA INICIAL (START SCREEN) --- */
#start-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    /* Um fundo ligeiramente mais opaco que o game over para focar no texto */
    background: rgba(26, 26, 26, 0.98); 
    color: #fff;
    display: flex; /* Começa visível (flex) */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Z-index alto para ficar acima do jogo, mas abaixo do loading */
    z-index: 9000; 
    padding: 30px;
    text-align: center;
    transition: opacity 0.5s ease-out;
    opacity: 1;
}

/* Logo pequeno */
.start-logo {
    max-width: 150px; /* Ajuste conforme necessário */
    height: auto;
    margin-bottom: 20px;
}

/* Título */
.start-title {
    font-size: 2.5rem;
    margin: 0 0 15px 0;
    color: #ffcc00; /* Amarelo EnsinE */
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Texto de descrição */
.start-text {
    font-size: 1.1rem;
    line-height: 1.5;
    max-width: 400px;
    margin-bottom: 35px;
    color: #e0e0e0;
}

/* Botão Iniciar Maior */
#start-btn {
    padding: 18px 60px;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    background: #ffcc00;
    color: #1a1a1a;
    border: none;
    border-radius: 50px;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(255, 204, 0, 0.3);
    transition: transform 0.1s, background 0.2s;
    margin-bottom: 30px;
}

#start-btn:active {
    transform: scale(0.98);
    background: #e6b800;
}

.btn-reset-record {
	position: absolute; top: 20px; right: 20px;
	background: none; border: none; font-size: 1.5rem;
	cursor: pointer; opacity: 0.4; transition: 0.3s;
	filter: grayscale(1);
}

.btn-reset-record:hover {
	opacity: 1;
	filter: grayscale(0);
	transform: scale(1.1);
}

/* Link inferior */
.start-link {
    font-size: 0.85rem;
    color: #aaa;
    max-width: 300px;
}

.start-link a {
    color: #ffcc00;
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dotted #ffcc00;
}

/* --- TELA DE NOVO RECORDE --- */
#new-record-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Fundo escuro levemente transparente */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Acima de tudo */
    color: #fff;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.record-title {
    font-size: 2.2rem;
    color: #ffcc00;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 0px #d35400;
    animation: pulse 1s infinite alternate;
}

.record-msg {
    font-size: 1rem;
    color: #ddd;
    margin-bottom: 5px;
}

.record-score-display {
    font-size: 3rem;
    font-weight: bold;
    color: #fff;
    margin: 10px 0 30px 0;
}

/* Estilo do Input igual ao Data Stacker */
.input-group {
    display: flex;
    flex-direction: column;
    width: 80%;
    margin-bottom: 20px;
}

.input-group label {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #ffcc00;
    font-weight: bold;
}

#player-name {
    padding: 15px;
    font-size: 1.2rem;
    text-align: center;
    border: 3px solid #ffcc00;
    border-radius: 10px;
    background: #fff;
    color: #333;
    font-weight: bold;
    text-transform: uppercase; /* Visualmente em caixa alta */
    outline: none;
}

#save-record-btn {
    background: #27ae60; /* Verde sucesso */
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 0 #1e8449;
    transition: transform 0.1s;
}

#save-record-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}
