:root {
    --space: #070912;
    --panel: #10162a;
    --text: #e8ecf7;
    --muted: #8e98b8;
    --jedi: #4fb8ff;
    --sith: #ff4538;
    --gold: #ffd34d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 500;
    background-color: var(--space);
    background-image:
        linear-gradient(rgba(7, 9, 18, 0.80), rgba(7, 9, 18, 0.92)),
        url('../assets/images/star_wars_jedi.jpeg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    background-size: cover;
}

/* ---------- header ---------- */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 16px 8px;
}

h1 {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 6vw, 3.6rem);
    letter-spacing: 0.08em;
    color: var(--gold);
    text-shadow: 0 0 24px rgba(255, 211, 77, 0.35);
    text-align: center;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px 16px 48px;
}

.stepTitle {
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    text-align: center;
    margin: 24px 0 16px;
}

/* ---------- buttons ---------- */
button {
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    cursor: pointer;
}

.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--muted);
    border-radius: 999px;
    padding: 6px 18px;
    font-size: 0.8rem;
}
.ghost:hover { color: var(--text); border-color: var(--text); }

.attackBtn {
    background: var(--sith);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 14px 40px;
    font-size: 1.1rem;
    letter-spacing: 0.06em;
    box-shadow: 0 0 22px rgba(255, 69, 56, 0.45);
    transition: transform 0.1s, box-shadow 0.1s;
}
.attackBtn:hover { box-shadow: 0 0 32px rgba(255, 69, 56, 0.75); }
.attackBtn:active { transform: scale(0.96); }

.restart {
    display: none;
    background: var(--gold);
    color: #1a1500;
    box-shadow: 0 0 22px rgba(255, 211, 77, 0.45);
}
.restart:hover { box-shadow: 0 0 32px rgba(255, 211, 77, 0.75); }

button:focus-visible, .firstRow:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- character cards ---------- */
.row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

.firstRow {
    width: 190px;
    padding: 12px;
    text-align: center;
    background: var(--panel);
    border: 2px solid var(--edge);
    border-radius: 10px;
    box-shadow: 0 0 18px var(--glow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.firstRow.jedi { --edge: var(--jedi); --glow: rgba(79, 184, 255, 0.25); }
.firstRow.sith { --edge: var(--sith); --glow: rgba(255, 69, 56, 0.25); }
.firstRow:hover { transform: translateY(-4px); box-shadow: 0 0 28px var(--edge); }

.firstRow img {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: top;
    border-radius: 6px;
}

.charName {
    margin: 10px 0 8px;
    font-weight: 700;
    font-size: 1.15rem;
}

.bar {
    height: 10px;
    background: #050710;
    border: 1px solid #2a3355;
    border-radius: 999px;
    overflow: hidden;
}
.bar span {
    display: block;
    height: 100%;
    width: 100%;
    background: #3ddc84;
    transition: width 0.4s ease, background-color 0.4s;
}
.bar span[data-low="true"] { background: var(--sith); }

.HP {
    margin: 6px 0 0;
    font-weight: 700;
    color: var(--muted);
}

.hit { animation: hit 0.35s; }
@keyframes hit {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    60% { transform: translateX(8px); }
}

/* ---------- which sections show when ---------- */
#enemySection, #arena { display: none; }
body[data-phase="pickEnemy"] #enemySection { display: block; }
body[data-phase="pickEnemy"] #arena,
body[data-phase="fight"] #arena,
body[data-phase="over"] #arena { display: grid; }

/* ---------- arena ---------- */
#arena {
    grid-template-columns: 1fr minmax(220px, 1.1fr) 1fr;
    gap: 24px;
    align-items: start;
    margin-top: 32px;
    padding-top: 8px;
    border-top: 1px solid #2a3355;
}

.side h3 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    color: var(--muted);
    margin: 14px 0 12px;
}

.hero, .villian {
    display: flex;
    justify-content: center;
    min-height: 330px;
    border: 2px dashed #2a3355;
    border-radius: 12px;
    padding: 8px;
}
.hero:not(:empty), .villian:not(:empty) { border: 2px solid transparent; }
.hero:empty::before, .villian:empty::before {
    align-self: center;
    color: var(--muted);
    text-align: center;
}
.villian:empty::before { content: "Pick an opponent above"; }
.hero:empty::before { content: "Your fighter"; }

.centre {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 70px;
    text-align: center;
}

.log { min-height: 120px; width: 100%; }
.log p { margin: 0 0 8px; }
.youAttacked { color: var(--jedi); }
.attackedBack { color: var(--sith); }
.youDefeated { color: var(--gold); font-weight: 700; }
.youWon { color: var(--gold); font-family: 'Orbitron', sans-serif; font-size: 1.4rem; }
.youLose { color: var(--sith); font-family: 'Orbitron', sans-serif; font-size: 1.4rem; }
.noEnemy { color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
    #arena { grid-template-columns: 1fr; }
    .centre { padding-top: 0; order: 3; }
    .firstRow { width: 150px; }
    .firstRow img { height: 150px; }
    .hero, .villian { min-height: 250px; }
}

@media (prefers-reduced-motion: reduce) {
    .hit { animation: none; }
    .firstRow, .bar span { transition: none; }
}
