@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;900&family=Press+Start+2P&display=swap');

:root {
    --bg-dark: #040508;
    --card-bg: rgba(10, 15, 26, 0.75);
    --card-border: rgba(255, 144, 82, 0.2);
    --border-hover: rgba(255, 209, 102, 0.55);
    --accent-orange: #ff9052;
    --accent-glow: rgba(255, 144, 82, 0.35);
    --accent-yellow: #ffd166;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --success-green: #10b981;
    --error-red: #ef4444;
}

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

body.wolf-dungeon-body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Atmosphere background effects */
.wolf-dungeon-atmosphere {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.08;
}

.orb-1 {
    top: -10%;
    left: 10%;
    width: 500px;
    height: 500px;
    background: var(--accent-orange);
}

.orb-2 {
    bottom: -10%;
    right: 15%;
    width: 600px;
    height: 600px;
    background: var(--accent-yellow);
}

.dungeon-grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 144, 82, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 144, 82, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.6;
}

/* Shell & Container Layout */
.wolf-dungeon-shell {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 20px;
    flex: 1;
    z-index: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Header */
.wolf-dungeon-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 15px;
}

.wolf-dungeon-kicker {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--accent-orange);
    text-shadow: 0 0 10px var(--accent-glow);
    margin-bottom: 6px;
}

.wolf-dungeon-header h1 {
    font-size: 2.3rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-light) 30%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.wolf-dungeon-copy {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 600px;
    line-height: 1.5;
}

.wolf-dungeon-backlink {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    align-self: flex-end;
}

.wolf-dungeon-backlink:hover {
    color: var(--text-light);
    border-color: var(--accent-orange);
    background: rgba(255, 144, 82, 0.05);
    box-shadow: 0 0 15px rgba(255, 144, 82, 0.15);
}

/* Stage Area (EJS Container) */
.wolf-dungeon-stage-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

/* Main Game Window */
.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 800 / 450;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 144, 82, 0.08);
    background: #020203;
    overflow: hidden;
}

#dungeonCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #0d0c11;
}

/* Overlay Screen Styles */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(4, 5, 8, 0.88);
    backdrop-filter: blur(8px);
    transition: opacity 0.4s ease;
    opacity: 0;
}

.overlay-screen.active {
    display: flex;
    opacity: 1;
}

/* Card inside Setup overlay */
.setup-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 12px 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 95%;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.setup-header {
    margin-bottom: 10px;
}

.setup-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(255, 144, 82, 0.1);
    color: var(--accent-orange);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 144, 82, 0.15);
}

.setup-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--text-light);
}

.setup-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.runner-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Form controls styling */
.select-wrap {
    position: relative;
    width: 100%;
}

.select-wrap select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(5, 7, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s;
}

.select-wrap select:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(255, 144, 82, 0.15);
}

.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--accent-orange);
    font-size: 0.72rem;
}

.input-wrap {
    position: relative;
    width: 100%;
}

.input-wrap input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(5, 7, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

.input-wrap input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(255, 144, 82, 0.15);
}

.verify-status {
    margin-top: 14px;
    font-size: 0.85rem;
    min-height: 20px;
    transition: all 0.3s;
}

.verify-status.status-error {
    color: var(--error-red);
}

.verify-status.status-success {
    color: var(--success-green);
}

/* General button */
.dungeon-btn {
    width: 100%;
    padding: 9px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.dungeon-btn-primary {
    background: var(--accent-orange);
    color: #040508;
    box-shadow: 0 4px 14px rgba(255, 144, 82, 0.3);
}

.dungeon-btn-primary:hover:not(:disabled) {
    background: #ffab7b;
    box-shadow: 0 4px 20px rgba(255, 144, 82, 0.5);
    transform: translateY(-2px);
}

.dungeon-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* HUD Overlay Styles */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    z-index: 5;
    display: none; /* Only show when game starts */
    justify-content: space-between;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(4, 5, 8, 0.85) 0%, rgba(4, 5, 8, 0.5) 50%, transparent 100%);
}

.hud-overlay.active {
    display: flex;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

#hudAvatar {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    border: 1px solid rgba(255, 144, 82, 0.3);
    background: rgba(0,0,0,0.4);
    object-fit: cover;
}

.hud-name-wrapper {
    display: flex;
    flex-direction: column;
}

.hud-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
}

.hud-distance {
    font-size: 0.72rem;
    color: var(--accent-yellow);
    font-weight: 600;
}

.hud-energy-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.energy-bar {
    width: 130px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.energy-fill {
    height: 100%;
    background: linear-gradient(to right, var(--accent-orange), var(--accent-yellow));
    box-shadow: 0 0 8px var(--accent-glow);
    transition: width 0.1s linear;
}

.energy-fill.danger {
    background: linear-gradient(to right, var(--error-red), #ff7b7b);
    animation: flash-energy 0.5s infinite alternate;
}

@keyframes flash-energy {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.hud-right {
    display: flex;
    gap: 15px;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.hud-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.95rem;
    color: var(--text-light);
    margin-top: 3px;
}

.font-neon {
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

/* Screen 2: Game Over Screen details */
.game-over-card {
    background: rgba(10, 12, 18, 0.92);
    border: 1px solid var(--error-red);
    padding: 35px 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(239, 68, 68, 0.15);
    text-align: center;
    animation: fade-up 0.4s ease-out;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-over-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--error-red);
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.game-over-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
}

.stat-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.82rem;
    color: var(--text-light);
}

#finalScore {
    color: var(--accent-yellow);
}

.dungeon-btn-accent {
    background: transparent;
    color: var(--accent-yellow);
    border: 1px solid var(--accent-yellow);
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.1);
}

.dungeon-btn-accent:hover {
    background: rgba(255, 209, 102, 0.08);
    box-shadow: 0 0 15px rgba(255, 209, 102, 0.25);
    border-color: #ffe08a;
    transform: translateY(-2px);
}

/* Keyboard Guide Panel */
.controls-guide-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-top: 15px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-family: monospace;
    font-weight: 800;
    color: var(--bg-dark);
    background: var(--text-muted);
    border-radius: 4px;
    box-shadow: 0 2px 0 #475569;
}

/* Shake animation for input errors */
.shake {
    animation: shake-anim 0.35s ease;
}

@keyframes shake-anim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Footer styling */
.wolf-dungeon-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-soft);
    font-size: 0.82rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 40px;
}

/* Character Selector Enhancements */
.input-wrap-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.setup-form-row {
    display: flex;
    gap: 15px;
    align-items: stretch;
    width: 100%;
}

.setup-fields-col {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fighter-preview-box {
    flex: 0.9;
    margin-top: 0;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: auto;
}

.fighter-preview-box img {
    width: 55px;
    height: 55px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(255, 144, 82, 0.2);
    transition: opacity 0.2s;
}

.preview-name {
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-yellow);
    text-transform: uppercase;
}

.dungeon-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dungeon-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 144, 82, 0.1);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.preview-spinner {
    position: absolute;
    width: 25px;
    height: 25px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--accent-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   MOBILE TOUCH CONTROLS BELOW GAME SCREEN
   ========================================== */
.dungeon-touch-controls {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.dungeon-touch-controls.active-touch-controls {
    display: flex;
}

.dungeon-touch-btn {
    flex: 1;
    min-width: 70px;
    max-width: 140px;
    padding: 12px 6px;
    font-size: 0.82rem;
    font-weight: 900;
    font-family: inherit;
    text-transform: uppercase;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(10, 15, 26, 0.82);
    border: 2px solid transparent;
    color: var(--text-light);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: opacity 0.15s ease, background 0.1s, transform 0.1s, box-shadow 0.1s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    text-align: center;
    opacity: 0.5;
}

.dungeon-touch-btn:hover {
    opacity: 0.85;
}

.dungeon-touch-btn:active,
.dungeon-touch-btn.btn-active {
    transform: scale(0.95);
    opacity: 1;
}

.dungeon-touch-btn.btn-jump {
    border-color: var(--accent-orange);
}

.dungeon-touch-btn.btn-jump:active,
.dungeon-touch-btn.btn-jump.btn-active {
    background: var(--accent-orange);
    color: #040508;
    box-shadow: 0 0 15px var(--accent-glow);
}

.dungeon-touch-btn.btn-block {
    border-color: #3b82f6;
}

.dungeon-touch-btn.btn-block:active,
.dungeon-touch-btn.btn-block.btn-active {
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
}

.dungeon-touch-btn.btn-attack {
    border-color: #f43f5e;
}

.dungeon-touch-btn.btn-attack:active,
.dungeon-touch-btn.btn-attack.btn-active {
    background: #f43f5e;
    color: #fff;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.6);
}
