/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
    background: #0a0a1a;
    color: #fff;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    height: 100vh;
    height: 100dvh;
}

/* ===== Screens ===== */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* ===== Title Screen ===== */
#title-screen {
    background: linear-gradient(135deg, #0a0a2e 0%, #1a0a2e 50%, #0a1a2e 100%);
}

.title-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.game-title {
    margin-bottom: 1.5rem;
}

.title-jp {
    display: block;
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 900;
    background: linear-gradient(135deg, #ff6ec7, #00ffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255, 110, 199, 0.5));
    line-height: 1.2;
}

.title-en {
    display: block;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: #00ffff;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-top: 0.3rem;
}

.subtitle {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: #aaa;
    line-height: 1.8;
    margin-bottom: 2rem;
}

.tower-preview {
    font-size: 3rem;
    margin-bottom: 2rem;
    animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 250px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6ec7, #ff3399);
    color: #fff;
    box-shadow: 0 0 30px rgba(255, 110, 199, 0.4);
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255, 110, 199, 0.6);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-share {
    background: linear-gradient(135deg, #1a1a2e, #2a2a4e);
    color: #00ffff;
    border: 2px solid #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.btn-share:hover {
    background: #00ffff;
    color: #0a0a1a;
}

.btn-patreon {
    background: linear-gradient(135deg, #ff424d, #ff6b6b);
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 66, 77, 0.3);
    font-size: 1rem;
    padding: 0.8rem 2rem;
}

.btn-patreon:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 66, 77, 0.5);
}

.brand {
    margin-top: 2rem;
}

.brand-name {
    font-size: 1rem;
    color: #ff6ec7;
    letter-spacing: 0.2em;
    font-weight: 700;
}

/* ===== Game Screen ===== */
#game-screen {
    background: #0a0a1a;
    z-index: 5;
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.8rem 1rem;
    z-index: 20;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(10, 10, 26, 0.8) 0%, transparent 100%);
    padding-top: max(0.8rem, env(safe-area-inset-top));
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.hud-right {
    align-items: flex-end;
}

.floor-counter {
    font-size: 1.3rem;
    font-weight: 900;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

#floor-count {
    font-size: 2rem;
    margin: 0 0.2rem;
}

#floor-unit {
    font-size: 0.8rem;
    color: #aaa;
}

.perfect-counter, .streak-counter {
    font-size: 0.9rem;
    color: #ff6ec7;
    text-shadow: 0 0 8px rgba(255, 110, 199, 0.4);
}

.streak-counter {
    color: #ffaa00;
}

/* Perfect popup */
.popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffdd00;
    text-shadow: 0 0 20px rgba(255, 221, 0, 0.8), 0 0 40px rgba(255, 110, 199, 0.6);
    z-index: 25;
    pointer-events: none;
    animation: popupAnim 0.8s ease-out forwards;
}

.popup.hidden {
    display: none;
}

@keyframes popupAnim {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}

/* Tap hint */
.tap-hint {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    z-index: 25;
    pointer-events: none;
    animation: tapPulse 1s ease-in-out infinite;
}

.tap-hint.hidden {
    display: none;
}

@keyframes tapPulse {
    0%, 100% { opacity: 0.3; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.8; transform: translateX(-50%) scale(1.1); }
}

/* ===== Result Screen ===== */
#result-screen {
    background: linear-gradient(135deg, #0a0a2e 0%, #1a0a2e 50%, #0a1a2e 100%);
}

.result-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
}

.result-title {
    margin-bottom: 2rem;
}

.result-jp {
    display: block;
    font-size: clamp(1.8rem, 6vw, 2.5rem);
    font-weight: 900;
    color: #ff6ec7;
    text-shadow: 0 0 15px rgba(255, 110, 199, 0.5);
}

.result-en {
    display: block;
    font-size: 1rem;
    color: #aaa;
    margin-top: 0.3rem;
}

.result-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 110, 199, 0.2);
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stat-main {
    border-color: rgba(0, 255, 255, 0.4);
    background: rgba(0, 255, 255, 0.05);
}

.stat-label {
    font-size: 0.8rem;
    color: #aaa;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: #00ffff;
}

.stat-main .stat-value {
    font-size: 2.5rem;
}

.stat-suffix {
    font-size: 0.9rem;
    color: #aaa;
}

.result-rank {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    min-height: 2rem;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 2rem;
}

.patreon-cta {
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.patreon-cta p {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 1rem;
    line-height: 1.6;
}
