:root {
    --bamboo-color: #f7d54e;
    --bamboo-bg: #8cba51;
    --mushroom-color: #644129;
    --mushroom-bg: #ff8c69;
    --bg-dark: #1a1a2e;
    --text-light: #ffffff;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Zen Maru Gothic', sans-serif;
    color: var(--text-light);
    overflow-x: hidden;
    user-select: none;
    min-height: 100vh;
    position: relative;
}

#bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('/static/kinotake/kinotakehaikei.png');
    background-size: cover;
    background-position: center;
    transition: background 0.5s ease, filter 0.5s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    position: relative;
    z-index: 10;
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-family: 'Mochiy Pop One', sans-serif;
    font-size: 2.5rem;
    color: #ffcc00;
    text-shadow: 2px 2px 0px #ff0000;
}

.subtitle {
    display: block;
    font-size: 1rem;
    color: #ccc;
    margin-top: 0.5rem;
}

/* Referee */
.referee-area {
    position: relative;
    height: 200px;
    margin: 1rem 0;
}

.referee {
    height: 150px;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.speech-bubble {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(120%);
    background: white;
    color: black;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    border: 3px solid black;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: -10px;
    border-width: 10px 10px 10px 0;
    border-style: solid;
    border-color: transparent white transparent transparent;
}

/* Battle Arena */
.battle-arena {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    margin-bottom: 3rem;
    height: 400px;
    padding-bottom: 50px;
}

.team {
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

.vs {
    font-size: 3rem;
    font-family: 'Mochiy Pop One', sans-serif;
    color: red;
    z-index: 2;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.score {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.bar-container {
    width: 30px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    position: relative;
    overflow: visible;
    margin-bottom: 10px;
}

.bar {
    width: 100%;
    height: 0%;
    position: absolute;
    bottom: 0;
    transition: height 0.2s ease-out;
    border-radius: 15px;
}

#bamboo-bar {
    background: linear-gradient(to top, var(--bamboo-bg), #d4fc79);
    box-shadow: 0 0 10px var(--bamboo-bg);
}

#mushroom-bar {
    background: linear-gradient(to top, var(--mushroom-bg), #ffafbd);
    box-shadow: 0 0 10px var(--mushroom-bg);
}

.vote-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.5);
    transition: all 0.1s;
    background: white;
    color: black;
    position: relative;
}

.vote-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.5);
}

.vote-btn.pressing {
    animation: shake 0.1s infinite;
    background: #ffff00;
}

#btn-bamboo {
    border: 5px solid var(--bamboo-bg);
}

#btn-mushroom {
    border: 5px solid var(--mushroom-bg);
}

/* Electric Aura for Long Press */
.aura {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    border: 2px solid cyan;
    animation: spin 1s linear infinite;
    opacity: 0;
}

.real-panda {
    position: absolute;
    cursor: pointer;
    z-index: 10001;
    pointer-events: auto;
    animation: glitch-anim 0.2s infinite;
}

.nise-panda {
    position: absolute;
    width: 80px;
    height: 80px;
    cursor: pointer;
    z-index: 10000;
    /* filter: invert(1) hue-rotate(180deg) drop-shadow(0 0 5px red); */
    /* Removed color filters */
    filter: drop-shadow(0 0 5px red);
    animation: glitch-anim 0.2s infinite;
    pointer-events: auto;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Prettier Zone */
.prettier-zone {
    margin: 2rem 0;
    opacity: 0.7;
}

.mini-btn {
    background: #333;
    color: white;
    border: 1px solid #555;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Log Area */
.log-area {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 10px;
    text-align: left;
    max-height: 150px;
    overflow-y: hidden;
    font-family: monospace;
}

.log-area h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#log-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#log-list li {
    font-size: 0.85rem;
    margin-bottom: 3px;
    color: #aaa;
    border-bottom: 1px dotted #333;
}

/* Visual Exaggerations */
.bar.limit-break {
    position: fixed;
    bottom: 0;
    z-index: 100;
    width: 50px;
    border: 2px solid white;
}

.shake-screen {
    animation: shake 0.5s;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

/* Hidden Trigger */
#hidden-trigger {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    cursor: default;
    z-index: 5;
}

/* Hidden Cheat Input */
.input-area {
    display: none;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
}

/* VIM DUNGEON MODE */
/* VIM MODE */
body.vim-mode {
    overflow: hidden;
}

body.vim-mode #bg-layer {
    background: url('/static/kinotake/derarenai.png') no-repeat center center !important;
    background-size: cover !important;
    animation: glitch 0.5s infinite;
}

/* SHONBORI MODE (Prettier x32) */
body.shonbori-mode {
    filter: grayscale(100%);
    transition: filter 2s ease;
}

body.shonbori-mode #bg-layer {
    background: url('/static/kinotake/shonbori.png') no-repeat center center !important;
    background-size: cover !important;
}

/* OTOKO MODE (Festival) */
body.otoko-mode #bg-layer {
    background: url('/static/kinotake/otoko.png') no-repeat center center !important;
    background-size: cover !important;
    animation: pulse-bg 0.5s infinite;
}

@keyframes pulse-bg {
    0% {
        transform: scale(1.0);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1.0);
    }
}

/* KAGYOHA MODE */
body.kagyoha-mode #bg-layer {
    background: url('/static/kinotake/kagyoha.png') no-repeat center center !important;
    background-size: cover !important;
    animation: wobble-bg 2s infinite ease-in-out;
}

@keyframes wobble-bg {
    0% {
        transform: rotate(0deg) scale(1.0);
    }

    25% {
        transform: rotate(1deg) scale(1.05);
    }

    75% {
        transform: rotate(-1deg) scale(1.05);
    }

    100% {
        transform: rotate(0deg) scale(1.0);
    }
}

/* TIME SLIP MODE (Meiji) */
body.time-slip-mode {
    filter: sepia(1.0) contrast(1.2) brightness(0.9);
}

body.time-slip-mode #bg-layer {
    background: url('/static/kinotake/meiji.png') no-repeat center center !important;
    background-size: cover !important;
}

#time-slip-date {
    display: none;
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    font-family: "Zen Old Mincho", serif;
    font-weight: bold;
    color: #3e2723;
    text-shadow: 2px 2px 0px burlywood;
    z-index: 10000;
    pointer-events: none;
    white-space: nowrap;
    animation: fadeInSlow 3s forwards;
}

.troubled-panda {
    animation: panic-shake 0.5s infinite;
}

@keyframes panic-shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

@keyframes fadeInSlow {
    0% {
        opacity: 0;
        transform: translate(-50%, -60%);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

body.vim-mode .container {
    filter: invert(1) hue-rotate(180deg) blur(1px);
    transition: filter 2s;
}

/* Teiou Mode */
body.teiou-mode #bg-layer {
    background: linear-gradient(135deg, #1a0033, #4b0082) !important;
    /* Deep Space Purple */
    filter: contrast(1.5) brightness(0.8);
}

body.teiou-mode .bar {
    transition: height 3s cubic-bezier(0.68, -0.6, 0.32, 1.6);
    /* Elastic explosion */
}

/* Graph Break Effect */
body.graph-break .bar-container {
    overflow: visible !important;
    /* Allow bars to stick out */
}

body.graph-break .bar {
    height: 53000% !important;
    /* Force massive height */
    box-shadow: 0 0 100px 20px cyan;
    /* Energy aura */
    animation: shake-hard 0.5s infinite;
}

body.graph-break #referee-img {
    animation: spin-chaos 1s infinite linear;
    /* Panda spins in chaos */
}

@keyframes shake-hard {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(10px, 10px) rotate(5deg);
    }

    50% {
        transform: translate(-10px, -10px) rotate(-5deg);
    }

    75% {
        transform: translate(10px, -10px) rotate(5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

@keyframes spin-chaos {
    0% {
        transform: rotate(0deg) scale(1.5);
    }

    100% {
        transform: rotate(360deg) scale(1.5);
    }
}

@keyframes glitch {
    0% {
        transform: translate(0)
    }

    20% {
        transform: translate(-2px, 2px)
    }

    40% {
        transform: translate(-2px, -2px)
    }

    60% {
        transform: translate(2px, 2px)
    }

    80% {
        transform: translate(2px, -2px)
    }

    100% {
        transform: translate(0)
    }
}

#vim-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: #0f0;
    /* Matrix Green */
    font-family: 'Courier New', Courier, monospace;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
}

#vim-overlay h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #0f0;
}

#vim-overlay p {
    font-size: 1.5rem;
    margin-bottom: 40px;
}

.vim-option {
    border: 1px solid #0f0;
    padding: 15px 30px;
    margin: 10px;
    cursor: pointer;
    background: black;
    color: #0f0;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.vim-option:hover {
    background: #0f0;
    color: black;
}

/* VIM BOSS */
#vim-boss {
    font-size: 5rem;
    color: red;
    font-weight: bold;
    text-shadow: 0 0 20px red;
    display: none;
    /* Hidden by default */
    animation: boss-breath 2s infinite;
    margin: 20px 0;
}

@keyframes boss-breath {

    0%,
    100% {
        transform: scale(1);
        text-shadow: 0 0 20px red;
    }

    50% {
        transform: scale(1.1);
        text-shadow: 0 0 40px red;
    }
}

/* QTE Display */
#qte-display {
    font-size: 2rem;
    color: #0f0;
    margin-top: 20px;
    display: none;
    font-family: monospace;
    flex-direction: row;
    justify-content: center;
}

.qte-seq {
    display: inline-block;
    padding: 0 10px;
    border: 1px solid #0f0;
    margin: 0 10px;
    opacity: 0.3;
}

.qte-seq.completed {
    opacity: 1;
    background: #0f0;
    color: black;
    box-shadow: 0 0 10px #0f0;
}

/* Shatter Effect */
#shatter-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('/static/kinotake/pari-n.jpg') no-repeat center center / cover;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    display: none;
}

.shatter-anim {
    animation: shatter-flash 1.5s ease-out forwards;
}

@keyframes shatter-flash {
    0% {
        opacity: 1;
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Panda Intense Mode */
.referee.intense {
    filter: sepia(1) hue-rotate(-50deg) saturate(5) invert(1);
    /* Red/Angry/Evil */
    animation: bounce 0.05s infinite !important;
}

#vim-msg {
    color: red;
    font-weight: bold;
    display: none;
    margin-top: 10px;
}

/* Certificate Modal */
#certificate-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    text-align: center;
    color: white;
}

#certificate-preview {
    max-width: 90%;
    max-height: 60vh;
    border: 5px solid gold;
    box-shadow: 0 0 20px gold;
    margin: 20px 0;
}

#input-controls,
#download-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
    align-items: center;
}

.cert-btn {
    padding: 10px 25px;
    font-size: 1.2rem;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    font-family: 'Mochiy Pop One', sans-serif;
    color: white;
}

#btn-generate {
    background: #FF5722;
}

#btn-download {
    background: #4CAF50;
}

#btn-share {
    background: #000;
    border: 1px solid #333;
}

#btn-back {
    background: #555;
}

#cert-name-input {
    padding: 15px;
    font-size: 1.5rem;
    border-radius: 5px;
    width: 300px;
    text-align: center;
}

#cert-instruction {
    font-size: 2rem;
    color: gold;
    text-shadow: 0 0 10px orange;
}

/* Game Clear Credits Scroll */
#gameclear-credits {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 700px;
    z-index: 9000;
    pointer-events: none;
    overflow: hidden;
    height: 100vh;
}

#gameclear-credits-inner {
    position: absolute;
    bottom: -100%;
    width: 100%;
    text-align: center;
    animation: creditsScroll 20s linear forwards;
}

@keyframes creditsScroll {
    0%   { bottom: -100%; }
    100% { bottom: 130%; }
}

#gameclear-credits-inner p {
    margin: 0.6em 0;
    font-family: 'Zen Maru Gothic', sans-serif;
    text-shadow: 0 0 12px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.9);
    line-height: 1.6;
}

.credits-main {
    font-size: 1.6rem;
    color: #ffffff;
}

.credits-quote {
    font-size: 1.9rem;
    color: #FFD700;
    font-weight: bold;
}

.credits-staff {
    font-size: 1.2rem;
    color: #cccccc;
}

.credits-thanks {
    font-size: 2rem;
    color: #FFD700;
    font-weight: bold;
}