/* ========================================
   TAMAGOTCHI VALENTINE STYLES
   Device UI + Visual Novel — polished v3
   ======================================== */

/* ---- VISUAL NOVEL SCREEN ---- */
#intro-screen {
    background: var(--bg-dark);
    padding: 0;
    justify-content: flex-end;
}

#intro-screen .scene-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#scene-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.character-area {
    position: absolute;
    bottom: 160px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 2;
    pointer-events: none;
    align-items: flex-end;
}

#left-character,
#right-character {
    width: 160px;
    height: 260px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    transition: transform 0.3s, filter 0.3s, opacity 0.3s;
}

#left-character.speaking,
#right-character.speaking {
    transform: scale(1.05);
    filter: brightness(1.2);
    animation: charPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes charPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1.05); }
}

#left-character.inactive { filter: brightness(0.5); opacity: 0.6; }
#right-character.inactive { filter: brightness(0.5); opacity: 0.6; }

.dialogue-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.tap-hint {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 7px;
    color: rgba(255, 107, 157, 0.5);
    z-index: 3;
    animation: pulse 2s ease-in-out infinite;
}

/* ---- TAMAGOTCHI DEVICE SCREEN ---- */
#tamagotchi-screen {
    background: linear-gradient(180deg, #12051a 0%, #0f0f1a 40%, #1a0a2a 100%);
    padding: 0;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Ambient background decoration */
#tamagotchi-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 30% 15%, rgba(255, 107, 157, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 85%, rgba(232, 67, 147, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(100, 0, 150, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Floating hearts decoration */
#tamagotchi-screen::after {
    content: '\2665  \2665  \2665';
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    color: rgba(255, 107, 157, 0.15);
    letter-spacing: 20px;
    pointer-events: none;
    z-index: 0;
    animation: pulse 3s ease-in-out infinite;
}

.device-shell {
    width: 88%;
    max-width: 380px;
    background: linear-gradient(180deg, #ffb8d8 0%, #ff8ec4 12%, #ff6b9d 35%, #e84393 70%, #c44569 95%, #a0365a 100%);
    border-radius: 48% 48% 42% 42% / 28% 28% 22% 22%;
    padding: 24px 24px 36px;
    box-shadow:
        0 16px 50px rgba(255, 107, 157, 0.5),
        0 0 100px rgba(255, 107, 157, 0.12),
        inset 0 3px 8px rgba(255, 255, 255, 0.3),
        inset 0 -8px 16px rgba(0, 0, 0, 0.25),
        inset 3px 0 8px rgba(255, 255, 255, 0.08),
        inset -3px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* Highlight shine */
.device-shell::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 28%;
    width: 44%;
    height: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.05) 100%);
    border-radius: 50%;
    pointer-events: none;
}

/* Edge ring detail */
.device-shell::after {
    content: '';
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border-radius: inherit;
    border: 2px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.device-title {
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.4), 0 0 12px rgba(255,255,255,0.15);
    margin-bottom: 6px;
    letter-spacing: 3px;
    z-index: 1;
}

.device-hearts {
    font-size: 16px;
    margin-bottom: 10px;
    animation: heartbeat 2s ease-in-out infinite;
    color: #c44569;
    text-shadow: 0 0 8px rgba(196, 69, 105, 0.4);
    z-index: 1;
}

/* LCD Screen */
.lcd-frame {
    width: 100%;
    background: linear-gradient(180deg, #111 0%, #222 40%, #1a1a1a 100%);
    border-radius: 16px;
    padding: 10px;
    box-shadow:
        inset 0 4px 12px rgba(0, 0, 0, 0.9),
        inset 0 -2px 4px rgba(255, 255, 255, 0.03),
        0 2px 0 rgba(255, 255, 255, 0.08);
    z-index: 1;
}

.lcd-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 320 / 288;
    background: #9bbc0f;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.08),
        inset 0 0 4px rgba(0, 0, 0, 0.15);
}

#pet-canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

/* Scanline overlay */
.lcd-screen::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.025) 3px,
        rgba(0, 0, 0, 0.025) 6px
    );
    pointer-events: none;
    z-index: 2;
}

/* Dot-matrix overlay */
.lcd-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(circle, rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 4px 4px;
    pointer-events: none;
    z-index: 3;
}

/* Buttons */
.device-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    width: 100%;
    z-index: 1;
}

.btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.device-btn {
    min-width: 72px;
    height: 40px;
    padding: 0 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 30%, #e0e0e0 70%, #cccccc 100%);
    border: none;
    border-radius: 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 6.5px;
    color: #333;
    cursor: pointer;
    box-shadow:
        0 4px 0 #999,
        0 5px 2px rgba(0, 0, 0, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.2),
        inset 0 1px 2px rgba(255, 255, 255, 0.8),
        inset 0 -1px 2px rgba(0, 0, 0, 0.1);
    transition: transform 0.06s, box-shadow 0.06s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-transform: uppercase;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    letter-spacing: 0.5px;
}

.device-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 #999,
        0 2px 4px rgba(0, 0, 0, 0.15),
        inset 0 1px 2px rgba(255, 255, 255, 0.6),
        inset 0 -1px 2px rgba(0, 0, 0, 0.1);
}

.device-btn .btn-icon {
    font-size: 13px;
    line-height: 1;
}

/* Pet name display */
.pet-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 8px 0;
    z-index: 1;
}

.pet-name {
    font-size: 9px;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}

.pet-age {
    font-size: 8px;
    color: rgba(255,255,255,0.65);
}

/* ---- STATS OVERLAY ---- */
#stats-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 4, 12, 0.97);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    z-index: 50;
    animation: fadeIn 0.25s ease-out;
}

#stats-overlay.active { display: flex; }

.stats-title {
    font-size: 16px;
    color: var(--pixel-yellow);
    margin-bottom: 28px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
    letter-spacing: 2px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 300px;
    margin-bottom: 16px;
}

.stat-label {
    font-size: 9px;
    color: var(--primary-pink);
    min-width: 100px;
}

.stat-bar { display: flex; gap: 5px; }

.stat-pip {
    width: 22px;
    height: 14px;
    background: #151525;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.stat-pip.filled {
    background: linear-gradient(180deg, #7cc45c 0%, #5a9a3a 100%);
    border-color: #5a9a4a;
    box-shadow: 0 0 8px rgba(106, 176, 76, 0.35);
}

.stat-pip.low {
    background: linear-gradient(180deg, #eb4d4b 0%, #c0392b 100%);
    border-color: #bb3a3a;
    box-shadow: 0 0 8px rgba(235, 77, 75, 0.5);
    animation: pulse 1s ease-in-out infinite;
}

.stat-value {
    font-size: 9px;
    color: var(--text-white);
    min-width: 50px;
    text-align: right;
}

.stats-close {
    margin-top: 28px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--primary-pink);
    background: none;
    border: 3px solid var(--primary-pink);
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 3px 0 rgba(196, 69, 105, 0.4);
}

.stats-close:hover { background: rgba(255, 107, 157, 0.12); }
.stats-close:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(196, 69, 105, 0.4); }

/* ---- FEED / DISCIPLINE OVERLAYS ---- */
#feed-overlay,
#discipline-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 4, 12, 0.97);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    z-index: 50;
    animation: fadeIn 0.25s ease-out;
}

#feed-overlay.active,
#discipline-overlay.active { display: flex; }

.overlay-title {
    font-size: 14px;
    color: var(--pixel-yellow);
    margin-bottom: 12px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    letter-spacing: 2px;
}

.choice-btn {
    width: 240px;
    padding: 18px 22px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--text-white);
    background: linear-gradient(180deg, #1e1e35 0%, #121220 100%);
    border: 3px solid var(--primary-pink);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    line-height: 1.8;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 4px 0 rgba(196, 69, 105, 0.5), 0 6px 20px rgba(0, 0, 0, 0.3);
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(196, 69, 105, 0.5), 0 10px 30px rgba(255, 107, 157, 0.15);
    border-color: #ffb8d0;
}

.choice-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(196, 69, 105, 0.5);
}

.choice-btn .choice-desc {
    display: block;
    font-size: 7px;
    color: var(--primary-pink);
    opacity: 0.55;
    margin-top: 6px;
}

.cancel-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #555;
    background: none;
    border: none;
    cursor: pointer;
    margin-top: 10px;
    transition: color 0.2s;
}

.cancel-btn:hover { color: #888; }

/* ---- DEATH SCREEN ---- */
#death-screen {
    background: radial-gradient(ellipse at center, #1a0808 0%, #050505 100%);
}

.death-content {
    text-align: center;
    animation: fadeIn 1.5s ease-out;
}

.death-icon {
    font-size: 64px;
    margin-bottom: 28px;
    animation: ghostFloat 3s ease-in-out infinite;
}

@keyframes ghostFloat {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(-12px); opacity: 1; }
}

.death-title {
    font-size: 16px;
    color: #555;
    margin-bottom: 14px;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 2px;
}

.death-message {
    font-size: 9px;
    color: #3a3a3a;
    line-height: 2.4;
    margin-bottom: 40px;
    max-width: 300px;
}

.restart-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: var(--primary-pink);
    background: none;
    border: 3px solid var(--primary-pink);
    padding: 16px 32px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 4px 0 rgba(196, 69, 105, 0.4);
}

.restart-btn:hover { background: rgba(255, 107, 157, 0.1); transform: translateY(-2px); }
.restart-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(196, 69, 105, 0.4); }

/* ---- RESPONSIVE ---- */
@media (max-height: 700px) {
    .device-shell { padding: 18px 20px 28px; }
    .device-buttons { margin-top: 12px; gap: 8px; }
    .device-btn { height: 36px; min-width: 64px; font-size: 6px; }
    .device-title { font-size: 9px; margin-bottom: 4px; }
    .device-hearts { font-size: 14px; margin-bottom: 6px; }
    .lcd-frame { padding: 8px; }
}

@media (max-height: 600px) {
    .device-shell { padding: 14px 16px 22px; }
    .device-buttons { margin-top: 8px; gap: 6px; }
    .device-btn { height: 32px; min-width: 56px; font-size: 5.5px; }
    .lcd-frame { padding: 6px; border-radius: 12px; }
}

@media (max-width: 360px) {
    .device-shell { width: 95%; }
    .device-btn { min-width: 58px; }
    #left-character, #right-character { width: 120px; height: 200px; }
    .character-area { padding: 0 15px; }
}
