*,
*:before,
*:after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'VT323', monospace;
    background-color: #344c99;
}

#content {
    text-align: center;
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    bottom: 120px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.title-card {
    font-size: 3em;
    color: #f7d51d;
    text-shadow: 4px 4px 0px #000;
    margin-bottom: 10px;
}

.text-card {
    font-size: 1.5em;
    color: white;
    margin-bottom: 20px;
}

#game-output {
    border: 5px solid black;
    padding: 15px;
    background-color: #fffdd0;
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 10px;
    height: 100px;
    font-size: 1.2em;
    z-index: 100;
    display: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#game-output.game-output-fullheight {
    top: 10px;
    height: auto !important;
    bottom: 10px;
    overflow-y: auto;
}

.eightbit-btn {
    background: #92cd41;
    display: inline-block;
    position: relative;
    text-align: center;
    font-size: 20px;
    padding: 10px 20px;
    text-decoration: none;
    color: #333;
    box-shadow: inset -4px -4px 0px 0px #4aa52e;
    border: 4px solid black;
}

.eightbit-btn:hover {
    background: #76c442;
}

.game-area {
    position: relative;
    width: 320px;
    height: 320px;
    background: #5d72b5;
    border: 4px solid black;
    margin: 0 auto;
    overflow: hidden;
}

.item {
    position: absolute;
    cursor: pointer;
    font-size: 24px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    opacity: 0;
    transition: transform 0.1s, opacity 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
}

.item.romance-bg { background-color: #ff4d6d; }
.item.fun-bg { background-color: #f7d51d; }
.item.chaos-bg { background-color: #9c0b0b; }

.item.visible {
    opacity: 1;
}

.item:active {
    transform: scale(0.8);
}

.ui-overlay {
    margin-top: 10px;
    color: white;
    font-size: 1.2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 340px;
    margin-left: auto;
    margin-right: auto;
    gap: 10px;
}

.timer-display {
    font-size: 1.5em;
    color: #f7d51d;
    text-shadow: 2px 2px 0 #000;
}

.status-bars {
    width: 100%;
}

.bar-bg-single {
    width: 100%;
    height: 30px;
    background: #000;
    border: 3px solid #fff;
    display: flex;
    overflow: hidden;
    position: relative;
}

.bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6em;
    color: white;
    text-shadow: 1px 1px 0 #000;
    transition: width 0.3s;
    white-space: nowrap;
    overflow: hidden;
}

.romance { background: #ff4d6d; width: 33%; }
.fun { background: #f7d51d; width: 33%; }
.chaos { background: #9c0b0b; width: 34%; }

.ui-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 340px;
    margin: 5px auto 0;
    font-size: 0.8em;
}

.player-status {
    display: flex;
    gap: 5px;
}

.debug-tools {
    opacity: 0.5;
}

.p-icon {
    background: #000;
    padding: 2px 4px;
    border: 1px solid #fff;
    color: white;
    display: inline-block;
    font-size: 0.9em;
}

.mega-p-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(50px);
    font-size: 80px;
    background: #000;
    padding: 20px 40px;
    border: 8px solid #fff;
    color: white;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    opacity: 0;
    transition: transform 1s ease-out, opacity 1s;
}

.mega-p-icon.risen {
    transform: translate(-50%, -50%) translateY(0);
    opacity: 1;
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.item.success-pop {
    transform: scale(1.5);
    opacity: 0;
    transition: transform 0.4s, opacity 0.4s;
    pointer-events: none;
}

.item.failed {
    background-color: #888 !important;
    filter: grayscale(100%);
    transition: background-color 0.2s, filter 0.2s;
    border-color: rgba(0,0,0,0.4);
}

.item.fail-fall {
    transform: translateY(25px) rotate(45deg);
    opacity: 0;
    transition: transform 0.4s ease-in, opacity 0.4s ease-in;
    pointer-events: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.item.warning {
    animation: blink 0.3s infinite;
}

@keyframes float-up {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

.festive-heart {
    position: fixed;
    pointer-events: none;
    z-index: 200;
    font-size: 30px;
    animation: float-up 3s linear forwards;
}

@keyframes sparkle {
    0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0) rotate(360deg); opacity: 0; }
}

.sparkle {
    position: absolute;
    pointer-events: none;
    z-index: 120;
    font-size: 20px;
    animation: sparkle 0.6s ease-out forwards;
}

.p-icon.new-player {
    animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.arrow-down {
    position: absolute;
    right: 6px;
    bottom: 6px;
    border-top: 3px solid black;
    width: 12px;
    animation: bounce 2.5s infinite;
}

@keyframes bounce {
    0%, 100% { bottom: 6px; }
    50% { bottom: 12px; }
}

.stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.success-msg {
    font-size: 3em;
    color: #92cd41;
    text-shadow: 2px 2px 0 #000;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px; 
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

.final-heart {
    height: 80px;
    image-rendering: pixelated;
    transform: translateY(-100px);
}

.game-area.chaos-mode {
    animation: rumble-heavy 0.4s infinite;
    background: #7a1c1c;
    border-color: #ce372b;
}

@keyframes rumble-heavy {
    0% { transform: translate(0, 0); }
    25% { transform: translate(2px, -2px); }
    50% { transform: translate(-2px, 2px); }
    75% { transform: translate(2px, 2px); }
    100% { transform: translate(0, 0); }
}

.family-portrait {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    height: 100px;
    margin-bottom: 20px;
}

.family-member {
    font-size: 40px;
    height: 60px;
    animation: bounce 1s infinite;
}

.family-member img {
    height: 100%;
}

.family-member:nth-child(2) { animation-delay: 0.2s; }
.family-member:nth-child(3) { animation-delay: 0.4s; }
.family-member:nth-child(4) { animation-delay: 0.6s; }

.mega-unlocked {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 40px;
    background: #92cd41;
    color: #333;
    padding: 20px 40px;
    border: 6px solid #000;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    z-index: 150;
    text-align: center;
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    pointer-events: none;
}

.mega-unlocked.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.characters-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    z-index: 1;
    gap: 20px;
}

.image-character {
    height: 200px;
    display: none;
    position: relative;
}

.image-character.toddler {
    height: 150px;
    transform: scaleX(-1);
}

.image-character.baby {
    height: 50px;
}

.image-character.you {
    transform: scaleX(-1);
}

.dance {
    animation: bounce 1s infinite;
}

.delay {
    animation-delay: 0.3s;
}

.p4-unlock-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.p4-btn {
    background: #ce372b !important;
    color: white !important;
    box-shadow: inset -4px -4px 0px 0px #8c2022 !important;
    border: 4px solid #000 !important;
    font-size: 24px !important;
    animation: rumble 0.2s infinite;
    transform: translateY(100px);
    transition: transform 2s ease-out, opacity 2s !important;
}

@keyframes rumble {
    0% { transform: translate(0, 0) translateY(0); }
    25% { transform: translate(2px, 2px) translateY(0); }
    50% { transform: translate(-2px, -2px) translateY(0); }
    75% { transform: translate(2px, -2px) translateY(0); }
    100% { transform: translate(-2px, 2px) translateY(0); }
}

.p4-btn.risen {
    transform: translateY(0);
}
