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

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

*, *::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 { display: none; width: 100%; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ========================
   Title Screen
   ======================== */
#title-screen {
    justify-content: center;
    min-height: 90vh;
    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.12em;
    margin-bottom: 1em;
}
.title-en b { color: var(--gold); letter-spacing: 0.2em; }
.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;
}
.title-note {
    margin-top: 2em; color: var(--text-dim); font-size: 0.9em; line-height: 1.6;
}
.blink { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ========================
   Stage Select
   ======================== */
#stage-select { padding: 1rem; gap: 1rem; min-height: 90vh; }
.home-header {
    width: 100%;
    max-width: 720px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.08);
}
.mc-display { color: var(--gold); font-weight: bold; }
.home-title { color: var(--cyan); font-weight: bold; }
.stage-list {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.stage-card {
    background: var(--surface2);
    border: 2px solid var(--cyan);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.12s;
}
.stage-card:hover { transform: translateY(-2px); }
.stage-card h3 { color: var(--pink); margin-bottom: 0.3em; }
.stage-card .stage-desc { color: var(--text-dim); font-size: 0.9em; }

/* ========================
   Game Screen
   ======================== */
#game-screen {
    padding: 0.4rem;
    gap: 0.4rem;
    min-height: 100vh;
    background: #07070d;
}

.hud {
    width: 100%;
    max-width: 900px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border: 1px solid rgba(255,255,255,0.08);
}
.hud-hp-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.hp-block {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8em;
}
.hp-label { min-width: 44px; }
.hp-bar {
    flex: 1;
    height: 14px;
    background: #222;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.hp-fill { height: 100%; transition: width 0.25s ease-out; }
.hp-fill-ally { background: linear-gradient(90deg, var(--cyan), var(--success)); }
.hp-fill-enemy { background: linear-gradient(90deg, var(--danger), var(--orange)); }
.hp-pct { min-width: 40px; text-align: right; font-size: 0.85em; }
.hud-vs { color: var(--gold); font-weight: bold; padding: 0 0.3rem; }

.hud-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82em;
}
.protein-wallet {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.wallet-label { color: var(--gold); }
.wallet-bar {
    flex: 1;
    height: 10px;
    background: #222;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,215,0,0.3);
}
.wallet-fill {
    height: 100%;
    background: linear-gradient(90deg, #b8860b, var(--gold));
    transition: width 0.1s linear;
}
.wallet-value { min-width: 80px; text-align: right; color: var(--gold); }
.ally-cap { color: var(--cyan); }
.hud-stage { color: var(--text-dim); }

.btn-bgm, .btn-home, .btn-inspect {
    background: var(--surface2);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}
.btn-inspect.active {
    background: var(--cyan);
    color: #000;
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0,212,255,0.6);
}

.canvas-wrap {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 2 / 1;
    background: #111;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--surface2);
    position: relative;
}
#game-canvas { width: 100%; height: 100%; display: block; }

/* ========================
   Inspect Panel (Sprint2)
   ======================== */
.canvas-wrap.inspect-on { cursor: crosshair; }
.inspect-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 260px;
    max-width: 45%;
    background: rgba(12, 14, 28, 0.94);
    color: var(--text);
    border: 2px solid var(--cyan);
    border-radius: var(--radius);
    padding: 0.7em 0.8em 0.8em;
    font-size: 0.82em;
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: inspect-in 0.18s ease-out;
}
.inspect-panel[hidden] { display: none; }
@keyframes inspect-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.inspect-close {
    position: absolute;
    top: 4px; right: 6px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.3em;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.inspect-close:hover { color: var(--danger); }
.inspect-head {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 0.4em;
}
.inspect-emoji { font-size: 1.8em; }
.inspect-name { color: var(--pink); font-weight: bold; font-size: 1.05em; }
.inspect-side { color: var(--text-dim); font-size: 0.85em; }
.inspect-hpbar {
    position: relative;
    height: 14px;
    background: #222;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    overflow: hidden;
    margin-bottom: 0.5em;
}
.inspect-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger), var(--success));
    transition: width 0.2s;
}
.inspect-hp-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85em; font-weight: bold; color: #fff;
    text-shadow: 1px 1px 2px #000;
}
.inspect-stats {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 3px 8px;
    font-size: 0.92em;
    margin-bottom: 0.4em;
}
.inspect-stats dt { color: var(--text-dim); }
.inspect-stats dd { color: var(--text); font-weight: bold; }
.inspect-tags {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-bottom: 0.4em;
}
.inspect-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: bold;
    background: #333;
    color: #fff;
}
.inspect-tag.tag-red    { background: #c04040; }
.inspect-tag.tag-black  { background: #333; border: 1px solid #888; }
.inspect-tag.tag-float  { background: #6090d0; }
.inspect-tag.tag-metal  { background: #9a9aa5; color: #222; }
.inspect-tag.tag-ally   { background: var(--cyan); color: #000; }
.inspect-tag.tag-castle { background: var(--gold); color: #000; }
.inspect-tag.trait {
    background: transparent;
    border: 1px solid var(--pink);
    color: var(--pink);
}
.inspect-effects {
    font-size: 0.85em;
    color: var(--orange);
    min-height: 1.2em;
    margin-bottom: 0.3em;
}
.inspect-effects:empty { display: none; }
.inspect-effect-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(255, 153, 68, 0.2);
    border: 1px solid var(--orange);
    margin: 2px 2px 0 0;
    font-size: 0.9em;
}
.inspect-info {
    font-size: 0.82em;
    color: var(--text-dim);
    line-height: 1.5;
    padding-top: 0.3em;
    border-top: 1px dashed rgba(255,255,255,0.12);
}
@media (max-width: 500px) {
    .inspect-panel {
        width: 200px;
        font-size: 0.75em;
        padding: 0.5em 0.6em 0.6em;
    }
}

.unit-panel {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);   /* Sprint3: 3→5列 */
    gap: 0.4rem;
}
@media (max-width: 500px) {
    .unit-panel { grid-template-columns: repeat(5, 1fr); gap: 0.25rem; }
}
.unit-btn {
    position: relative;
    background: var(--surface2);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 0.5rem 0.3rem;
    cursor: pointer;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2em;
    overflow: hidden;
    min-height: 74px;
    transition: transform 0.08s, border-color 0.12s;
}
.unit-btn:active { transform: scale(0.96); }
.unit-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.unit-btn.ready { border-color: var(--cyan); }
.unit-btn img { width: 38px; height: 38px; object-fit: contain; }
.unit-btn .u-name { font-size: 0.7em; color: var(--pink); }
.unit-btn .u-cost { font-size: 0.75em; color: var(--gold); }
.unit-btn .cd-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    pointer-events: none;
    clip-path: inset(0 0 0 0);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold); font-weight: bold;
    font-size: 1.1em;
}
.unit-btn.ready .cd-overlay { display: none; }

/* ========================
   Result Screen
   ======================== */
#result-screen { min-height: 90vh; justify-content: center; padding: 1rem; }
.result-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 500px;
    width: 100%;
    border: 2px solid var(--cyan);
}
.result-title { font-size: 2.5em; margin-bottom: 0.4em; }
.result-title.win { color: var(--gold); text-shadow: 0 0 20px rgba(255,215,0,0.5); }
.result-title.lose { color: var(--danger); }
.result-message { margin-bottom: 1.5em; color: var(--text-dim); }

/* ========================
   Buttons
   ======================== */
.btn {
    display: inline-block;
    padding: 0.6em 1.2em;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.95em;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s, border-color 0.12s;
    margin: 0.25em;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--pink); color: #111; }
.btn-secondary { background: var(--surface2); border-color: var(--cyan); }
.btn-back {
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--text-dim); margin-top: 1em;
}

/* ========================
   How to play / Footer
   ======================== */
.how-to-play {
    width: 100%;
    max-width: 720px;
    margin: 1rem auto;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.8em 1em;
}
.how-to-play summary {
    color: var(--cyan); cursor: pointer; font-weight: bold;
}
.how-to-play-body { margin-top: 0.8em; font-size: 0.9em; line-height: 1.7; color: var(--text-dim); }
.how-to-play-body ul { padding-left: 1.4em; }

.footer {
    text-align: center;
    padding: 1.5em 1em 2em;
    color: var(--text-dim);
    font-size: 0.85em;
}

/* ========================
   Responsive
   ======================== */
@media (max-width: 500px) {
    .hud-meta-row { flex-wrap: wrap; }
    .unit-btn .u-name { font-size: 0.62em; }
    .unit-btn img { width: 32px; height: 32px; }
    .home-title { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
    #game-screen { padding: 0.2rem; }
    .canvas-wrap { max-width: 720px; aspect-ratio: 2.4 / 1; }
}
