/* ==============================
   Muscle Battle Line - style.css
   ============================== */

/* --- CSS Variables --- */
:root {
    --bg: #0a0a0f;
    --surface: #16162a;
    --surface2: #1e1e3a;
    --pink: #ff6b9d;
    --cyan: #00d4ff;
    --gold: #ffd700;
    --text: #eee;
    --text-dim: #999;
    --danger: #ff4444;
    --success: #44ff88;
    --radius: 8px;
    --font: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* --- Screen Management --- */
.screen {
    display: none;
    width: 100%;
}
.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ========================
   Title Screen
   ======================== */
#title-screen {
    justify-content: center;
    min-height: 80vh;
    background: radial-gradient(ellipse at center, #1a0a2e 0%, var(--bg) 70%);
}
.title-content {
    text-align: center;
    padding: 2rem;
}
.game-title {
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    line-height: 1.2;
    margin-bottom: 0.3em;
}
.title-muscle {
    color: var(--pink);
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.6);
}
.title-battle {
    color: var(--cyan);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
}
.title-en {
    font-size: clamp(0.9rem, 3vw, 1.4rem);
    color: var(--text-dim);
    letter-spacing: 0.15em;
    margin-bottom: 1em;
}
.title-sub {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 2em;
}
.tap-start {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--gold);
    letter-spacing: 0.2em;
    cursor: pointer;
}

/* Blink Animation */
.blink {
    animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========================
   Home / Stage Select
   ======================== */
#stage-select {
    padding-top: 1rem;
    min-height: 80vh;
}
.home-header {
    width: 100%;
    max-width: 550px;
    text-align: right;
    padding: 0.5rem 1rem;
}
.mc-display {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--gold);
    background: var(--surface);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--gold);
}
.home-tabs {
    display: flex;
    gap: 0;
    width: 100%;
    max-width: 550px;
    padding: 0 0.5rem;
    margin-bottom: 1rem;
}
.tab-btn {
    flex: 1;
    padding: 0.65rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--surface2);
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.tab-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.tab-btn.active {
    background: var(--surface2);
    color: var(--cyan);
    border-color: var(--cyan);
}
.home-content {
    width: 100%;
    max-width: 550px;
    padding: 0 0.5rem;
    min-height: 400px;
    max-height: 60vh;
    overflow-y: auto;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-title {
    text-align: center;
    font-size: 1.5rem;
    color: var(--cyan);
    margin-bottom: 1.5rem;
}

/* ========================
   Upgrade UI
   ======================== */
.upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.upgrade-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
}
.upgrade-card-img {
    width: 40px;
    height: 54px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--pink);
    flex-shrink: 0;
}
.upgrade-card-emoji {
    font-size: 1.8rem;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}
.upgrade-card-info {
    flex: 1;
    min-width: 0;
}
.upgrade-card-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--pink);
    margin-bottom: 0.3rem;
}
.upgrade-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.upgrade-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    background: var(--surface2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}
.upgrade-stat-label {
    color: var(--text-dim);
}
.upgrade-stat-level {
    color: var(--cyan);
    font-weight: bold;
}
.upgrade-stat-btn {
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.1rem 0.35rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.upgrade-stat-btn:hover {
    background: #ffe44d;
    transform: scale(1.05);
}
.upgrade-stat-btn:active {
    transform: scale(0.95);
}
.upgrade-stat-btn.maxed {
    background: var(--text-dim);
    cursor: default;
    color: #666;
}
.upgrade-stat-btn.cant-afford {
    background: #555;
    color: #888;
    cursor: not-allowed;
}
.stage-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stage-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.2rem;
    background: var(--surface);
    border: 2px solid var(--surface2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.stage-btn:hover:not(.locked) {
    border-color: var(--cyan);
    background: var(--surface2);
    transform: translateX(4px);
}
.stage-btn:active:not(.locked) {
    transform: scale(0.97);
}
.stage-btn.locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.stage-btn .stage-num {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--gold);
    min-width: 2.5rem;
}
.stage-btn.locked .stage-num {
    color: var(--text-dim);
}

/* ========================
   Buttons (shared)
   ======================== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}
.btn:active {
    transform: scale(0.95);
}
.btn-primary {
    background: var(--pink);
    color: #fff;
}
.btn-primary:hover {
    background: #ff85b1;
}
.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--text-dim);
}
.btn-secondary:hover {
    background: #2a2a4a;
}
.save-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 550px;
    padding: 0.5rem 0.5rem 0;
}
.btn-save {
    flex: 1;
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--surface2);
    font-size: 0.8rem;
    padding: 0.5rem;
}
.btn-save:hover {
    border-color: var(--cyan);
    color: var(--text);
}
.btn-back {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--text-dim);
    width: 100%;
    max-width: 550px;
    margin: 0.5rem;
}
.btn-back:hover {
    color: var(--text);
    border-color: var(--text);
}
.btn-cta {
    background: linear-gradient(135deg, var(--pink), #ff3366);
    color: #fff;
    font-size: 1.1rem;
    padding: 0.9rem 2rem;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}
.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.6);
}

/* ========================
   Game Screen
   ======================== */
#game-screen {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 0;
}

/* HUD */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    flex-wrap: wrap;
    gap: 0.3rem;
}
.hud-left, .hud-right {
    white-space: nowrap;
}
.hud-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.hud-label {
    color: var(--text-dim);
}
.hud-value {
    color: var(--gold);
    font-weight: bold;
    font-size: 1.1em;
}
.hud-hp-ally {
    color: var(--cyan);
    font-weight: bold;
}
.hud-hp-enemy {
    color: var(--danger);
    font-weight: bold;
}
.hud-vs {
    color: var(--text-dim);
    font-size: 0.8em;
}
.hud-stage {
    color: var(--pink);
    font-weight: bold;
}
.btn-bgm {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text);
    font-size: 1rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.btn-bgm:hover, .btn-home:hover {
    border-color: var(--cyan);
}
.btn-home {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text);
    font-size: 1rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.2rem;
    vertical-align: middle;
}

/* Canvas */
.canvas-wrap {
    width: 100%;
    background: #000;
    position: relative;
}
#game-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    background: #0a0a1a;
}

/* Unit Panel */
.unit-panel {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem;
    background: var(--surface);
    border-top: 1px solid var(--surface2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.unit-btn {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 80px;
    padding: 0.3rem 0.4rem;
    background: var(--surface2);
    border: 2px solid #333;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    gap: 0.1rem;
}
.unit-btn:hover {
    border-color: var(--cyan);
    background: #252550;
}
.unit-btn:active {
    transform: scale(0.92);
}
.unit-btn .unit-img {
    width: 36px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--pink);
}
.unit-btn .unit-name {
    font-size: 0.55rem;
    color: var(--cyan);
    white-space: nowrap;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unit-btn .unit-cost {
    color: var(--gold);
    font-weight: bold;
    font-size: 0.7rem;
}
.unit-btn .unit-key {
    color: var(--text-dim);
    font-size: 0.6rem;
}
.unit-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.unit-btn {
    position: relative;
    overflow: hidden;
}
.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    display: none;
    transition: height 0.1s linear;
}

/* ========================
   Result Screen
   ======================== */
#result-screen {
    justify-content: center;
    min-height: 70vh;
}
.result-content {
    text-align: center;
    padding: 2rem;
}
.result-title {
    font-size: clamp(2rem, 7vw, 3.5rem);
    margin-bottom: 0.5em;
}
.result-title.win {
    color: var(--gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}
.result-title.lose {
    color: var(--danger);
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.4);
}
.result-message {
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 1rem;
}
.result-content .btn {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 0.5rem auto;
}

/* ========================
   How to Play
   ======================== */
.how-to-play {
    width: 100%;
    max-width: 600px;
    margin: 2rem auto;
    padding: 0 1rem;
}
.how-to-play summary {
    cursor: pointer;
    color: var(--cyan);
    font-size: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--surface2);
    list-style: none;
}
.how-to-play summary::before {
    content: '▶ ';
}
.how-to-play[open] summary::before {
    content: '▼ ';
}
.how-to-play-body {
    padding: 1rem 0;
}
.how-to-play-body ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.how-to-play-body li {
    padding-left: 1.2em;
    text-indent: -1.2em;
    color: var(--text-dim);
    line-height: 1.6;
}
.how-to-play-body li::before {
    content: '💪 ';
}

/* ========================
   CTA Section
   ======================== */
.cta-section {
    text-align: center;
    padding: 2rem 1rem;
    margin: 1rem auto;
    max-width: 500px;
}
.cta-text {
    color: var(--text-dim);
    margin-bottom: 1rem;
}

/* ========================
   Footer
   ======================== */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    border-top: 1px solid var(--surface2);
    margin-top: 1rem;
}

/* ========================
   Responsive
   ======================== */
@media (max-width: 480px) {
    .hud {
        font-size: 0.7rem;
        padding: 0.4rem 0.5rem;
    }
    .unit-btn {
        min-width: 56px;
        min-height: 70px;
    }
    .unit-btn .unit-img {
        width: 30px;
        height: 40px;
    }
    .unit-btn .unit-name {
        font-size: 0.5rem;
    }
}
@media (min-width: 768px) {
    .hud {
        font-size: 0.95rem;
    }
    .unit-btn {
        min-width: 76px;
        min-height: 90px;
    }
    .unit-btn .unit-img {
        width: 42px;
        height: 56px;
    }
}
