/* =========================================================
   TEAM & STEAM – Pixel Art Steampunk Theme
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg-dark: #1a120b;
    --bg-panel: #2a1f14;
    --bg-cell: #3d2b1a;
    --bg-walk: #4a3520;
    --bg-wall: #1c120a;
    --brass: #c9a227;
    --copper: #b87333;
    --rust: #8b4513;
    --steam: #d4c4a8;
    --danger: #c0392b;
    --success: #27ae60;
    --watt: #e74c3c;
    --steele: #3498db;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    image-rendering: pixelated;
}

body {
    font-family: 'Press Start 2P', monospace;
    background: var(--bg-dark);
    color: var(--steam);
    min-height: 100vh;
    font-size: 10px;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(201,162,39,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(184,115,51,0.06) 0%, transparent 40%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(0,0,0,0.03) 4px,
            rgba(0,0,0,0.03) 8px
        );
}

/* ========== MENU ========== */
body.menu {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0a06;
    background-image:
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a227' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.container {
    max-width: 540px;
    width: 95%;
    background: var(--bg-panel);
    border: 6px solid var(--brass);
    border-radius: 0;
    padding: 1.8rem;
    box-shadow:
        0 0 0 3px #5c4030,
        0 0 0 6px var(--brass),
        8px 8px 0 #0a0604,
        inset 0 0 40px rgba(0,0,0,0.4);
    position: relative;
}

.container::before {
    content: '';
    position: absolute;
    top: -12px; left: 20px; right: 20px;
    height: 8px;
    background: repeating-linear-gradient(90deg, var(--brass) 0 8px, var(--copper) 8px 16px);
    border: 2px solid #5c4030;
}

header h1 {
    font-size: 1.4rem;
    text-align: center;
    color: var(--brass);
    text-shadow: 3px 3px 0 #5c4030;
    letter-spacing: 1px;
    margin-bottom: 0.4rem;
}

.subtitle {
    text-align: center;
    color: var(--copper);
    font-size: 0.55rem;
    margin-bottom: 1rem;
}

.scenario {
    text-align: center;
    font-size: 0.55rem;
    margin-bottom: 1.2rem;
    line-height: 1.8;
    color: var(--steam);
    opacity: 0.9;
}

.lang-switch {
    text-align: center;
    margin-bottom: 1.2rem;
}
.lang-switch button {
    background: var(--bg-cell);
    border: 3px solid var(--brass);
    color: var(--steam);
    padding: 0.4rem 0.7rem;
    margin: 0 0.2rem;
    font-family: inherit;
    font-size: 0.55rem;
    cursor: pointer;
}
.lang-switch button.active {
    background: var(--brass);
    color: #1a120b;
}

.menu-box h2 {
    font-size: 0.65rem;
    margin-bottom: 0.5rem;
    color: var(--brass);
}

input[type="text"] {
    width: 100%;
    padding: 0.7rem;
    border: 3px solid var(--brass);
    background: #0f0a06;
    color: var(--steam);
    font-family: inherit;
    font-size: 0.6rem;
    margin-bottom: 0.7rem;
    outline: none;
}
input[type="text"]:focus {
    box-shadow: 0 0 0 2px var(--copper);
}

.btn {
    display: inline-block;
    padding: 0.7rem 1rem;
    border: 3px solid var(--brass);
    background: var(--bg-cell);
    color: var(--steam);
    font-family: inherit;
    font-size: 0.55rem;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 3px 3px 0 #0a0604;
}
.btn:hover {
    background: var(--brass);
    color: #1a120b;
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #0a0604;
}
.btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

.btn.primary {
    background: var(--brass);
    color: #1a120b;
    width: 100%;
}
.btn.primary:hover { background: #e0b83a; }

.btn.watt {
    background: #8b1a1a;
    border-color: var(--watt);
    color: #fff;
}
.btn.steele {
    background: #1a3a5c;
    border-color: var(--steele);
    color: #fff;
}

.role-choice {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}
.role-choice .btn { flex: 1; }

hr {
    border: none;
    height: 3px;
    background: repeating-linear-gradient(90deg, var(--brass) 0 6px, transparent 6px 12px);
    margin: 1.3rem 0;
}

.rules {
    margin-top: 1.2rem;
    font-size: 0.5rem;
    color: var(--steam);
    opacity: 0.85;
}
.rules h3 {
    color: var(--brass);
    margin-bottom: 0.5rem;
    font-size: 0.6rem;
}
.rules ul { padding-left: 1rem; }
.rules li { margin-bottom: 0.35rem; }

/* ========== GAME UI ========== */
body.game {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--bg-panel);
    border-bottom: 4px solid var(--brass);
    box-shadow: 0 4px 0 #0a0604;
}

.topbar .player-name {
    font-size: 0.8rem;
    text-shadow: 2px 2px 0 #000;
}
.topbar .player-name.watt { color: var(--watt); }
.topbar .player-name.steele { color: var(--steele); }

.hud {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.55rem;
}

.hud .timer {
    background: #0f0a06;
    padding: 0.35rem 0.6rem;
    border: 2px solid var(--brass);
    font-variant-numeric: tabular-nums;
    color: var(--brass);
}
.hud .timer.warning { color: #f39c12; border-color: #f39c12; }
.hud .timer.danger {
    color: var(--danger);
    border-color: var(--danger);
    animation: blink 0.8s steps(2) infinite;
}

@keyframes blink {
    50% { opacity: 0.3; }
}

.hud button {
    background: var(--bg-cell);
    border: 2px solid var(--brass);
    color: var(--steam);
    font-family: inherit;
    font-size: 0.5rem;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
}

.main {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 0;
    overflow: hidden;
}

.grid-area {
    padding: 1rem;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grid {
    display: grid;
    gap: 0;
    background: #0a0604;
    padding: 6px;
    border: 4px solid var(--brass);
    box-shadow:
        0 0 0 2px #5c4030,
        6px 6px 0 #0a0604,
        inset 0 0 20px rgba(0,0,0,0.5);
}

.cell {
    width: 48px;
    height: 52px;
    background: var(--bg-cell);
    border: 1px solid #2a1c10;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    font-size: 0.5rem;
    color: #6b5344;
    image-rendering: pixelated;
}

.cell:hover { filter: brightness(1.15); }
.cell.walkable { background: var(--bg-walk); }
.cell.wall {
    background: var(--bg-wall);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(0,0,0,0.3) 3px,
        rgba(0,0,0,0.3) 6px
    );
    cursor: default;
}
.cell.bush { background: #1e3a1a; }
.cell.door { background: #4a2f1a; }
.cell.special { background: #3a2a18; }

.cell.player {
    background: #5a2a2a;
    z-index: 5;
    box-shadow: inset 0 0 0 2px var(--brass);
    animation: pulse-player 1.2s steps(2) infinite;
}
.cell.player.steele { background: #1a3a5a; }
.cell.player svg {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
}

@keyframes pulse-player {
    50% { filter: brightness(1.2); }
}

.cell svg {
    width: 26px;
    height: 26px;
    image-rendering: pixelated;
}

.sidebar {
    background: var(--bg-panel);
    border-left: 4px solid var(--brass);
    padding: 0.8rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: inset 4px 0 0 #0a0604;
}

.sidebar h3 {
    font-size: 0.55rem;
    color: var(--brass);
    border-bottom: 2px solid #5c4030;
    padding-bottom: 0.3rem;
    text-transform: uppercase;
}

.inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.inv-item {
    background: #0f0a06;
    border: 2px solid var(--copper);
    padding: 0.25rem 0.4rem;
    font-size: 0.45rem;
    color: var(--steam);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.actions button {
    width: 100%;
    padding: 0.55rem 0.4rem;
    border: 2px solid var(--brass);
    background: var(--bg-cell);
    color: var(--steam);
    font-family: inherit;
    font-size: 0.48rem;
    cursor: pointer;
    text-align: left;
    box-shadow: 2px 2px 0 #0a0604;
}
.actions button:hover:not(:disabled) {
    background: var(--brass);
    color: #1a120b;
}
.actions button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #5c4030;
}

.log {
    flex: 1;
    overflow-y: auto;
    font-size: 0.45rem;
    color: #a09080;
    max-height: 180px;
    line-height: 1.7;
}
.log p {
    margin-bottom: 0.25rem;
    border-left: 2px solid var(--copper);
    padding-left: 0.4rem;
}

.footer {
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border-top: 4px solid var(--brass);
    text-align: center;
    font-size: 0.45rem;
    color: #8a7a6a;
}

/* Mini-jeu */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 4, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.overlay.active { display: flex; }

.minigame-box {
    background: var(--bg-panel);
    border: 6px solid var(--brass);
    padding: 1.5rem;
    text-align: center;
    max-width: 380px;
    box-shadow: 0 0 0 3px #5c4030, 8px 8px 0 #0a0604;
}
.minigame-box h2 {
    color: var(--brass);
    font-size: 0.75rem;
    margin-bottom: 0.8rem;
}
.minigame-box p { font-size: 0.5rem; margin-bottom: 0.5rem; }

.timing-bar {
    width: 100%;
    height: 36px;
    background: #0f0a06;
    border: 3px solid var(--brass);
    position: relative;
    overflow: hidden;
    margin: 1.2rem 0;
}
.timing-target {
    position: absolute;
    top: 0; bottom: 0;
    width: 48px;
    background: var(--success);
    left: 50%;
    transform: translateX(-50%);
    box-shadow: inset 0 0 0 2px #1e8449;
}
.timing-cursor {
    position: absolute;
    top: 0; bottom: 0;
    width: 6px;
    background: var(--danger);
    left: 0;
    box-shadow: 0 0 6px var(--danger);
}

.status-banner {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    border-top: 4px solid var(--brass);
}
.status-banner.victory { background: #1a4a2a; color: #2ecc71; }
.status-banner.defeat { background: #4a1a1a; color: #e74c3c; }

.kbd-hint {
    margin-top: 0.6rem;
    font-size: 0.45rem;
    color: #7a6a5a;
    text-align: center;
}
.kbd-hint kbd {
    display: inline-block;
    background: #0f0a06;
    border: 2px solid var(--brass);
    padding: 0.15rem 0.35rem;
    margin: 0 0.1rem;
    font-family: inherit;
    font-size: 0.45rem;
}

@media (max-width: 800px) {
    .main { grid-template-columns: 1fr; }
    .sidebar { border-left: none; border-top: 4px solid var(--brass); }
    .cell { width: 36px; height: 36px; }
}


/* Context interaction prompt */
.context-prompt {
    margin-top: 0.8rem;
    min-height: 1.4rem;
    font-size: 0.55rem;
    color: var(--brass);
    text-align: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.context-prompt.visible {
    opacity: 1;
}
.context-prompt kbd {
    display: inline-block;
    background: #0f0a06;
    border: 2px solid var(--brass);
    padding: 0.15rem 0.4rem;
    margin-right: 0.3rem;
    font-family: inherit;
    font-size: 0.5rem;
    color: var(--steam);
}
.context-prompt strong {
    color: var(--steam);
}

/* Better bush cells */
.cell.bush {
    background: #1a3018;
}
.cell.special {
    background: #2a2218;
}


.btn-restart {
    background: var(--bg-cell);
    border: 2px solid var(--brass);
    color: var(--brass);
    font-family: inherit;
    font-size: 0.5rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    box-shadow: 2px 2px 0 #0a0604;
}
.btn-restart:hover {
    background: var(--brass);
    color: #1a120b;
}
.status-banner .btn-restart {
    font-size: 0.55rem;
    margin-left: 0.8rem;
    vertical-align: middle;
}


/* Character sprites from reference art */
.cell.player {
    background: transparent !important;
    box-shadow: none !important;
    animation: none !important;
    overflow: visible;
}
.cell.player img.sprite,
img.sprite {
    width: 40px;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    position: relative;
    z-index: 6;
    filter: drop-shadow(1px 1px 0 #0008);
    pointer-events: none;
}
.cell.player.steele {
    background: transparent !important;
}
