:root {
    --bg-color: #0a0a12;
    --card-bg: #161622;
    --primary-color: #7000ff;
    --primary-hover: #8a2be2;
    --accent-color: #00e5ff;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --danger-color: #ff2a6d;
    --success-color: #05d5aa;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Outfit', sans-serif;
    --border-radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 900px;
    background: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

@media (min-width: 500px) {
    .app-container {
        height: 90vh;
        border-radius: 20px;
        border: 1px solid #333;
    }
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
}

.game-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(112, 0, 255, 0.5);
    margin-bottom: 1rem;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 300;
    letter-spacing: 2px;
}

.intro-text {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    padding: 1rem;
    border-radius: var(--border-radius);
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    border: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 15px rgba(112, 0, 255, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(112, 0, 255, 0.5);
}

.secondary-btn {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-muted);
}

.secondary-btn:hover {
    border-color: var(--text-color);
    color: var(--text-color);
}

/* Game Screen */
#game-screen {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-header {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#player-name-display {
    font-family: var(--font-heading);
    color: var(--accent-color);
}

.stats-row {
    display: flex;
    gap: 0.5rem;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.weapon-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-top: 1px solid #333;
    padding-top: 0.5rem;
}

.weapon-name {
    color: var(--success-color);
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0,0,0,0.3);
    min-height: 0;
}

.visual-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 0;
}

.battle-stage {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 10px;
}

.character-container {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.entity-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s;
}

.hero-container .entity-img {
    transform: scaleX(-1);
}

.vs-badge {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--danger-color);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 42, 109, 0.5);
    z-index: 10;
}

.entity-info {
    position: absolute;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
}

#monster-name {
    font-family: var(--font-heading);
    color: var(--danger-color);
    font-size: 1rem;
}

.log-area {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-color);
    min-height: 50px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

#game-message {
    font-size: 0.9rem;
    line-height: 1.3;
}

.game-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.8rem;
    margin-top: auto;
    flex-shrink: 0;
    padding-top: 1rem;
}

.action-btn {
    padding: 0.8rem 0.5rem;
    font-size: 0.9rem;
}

.action-btn.attack {
    background: linear-gradient(45deg, #ff2a6d, #d60045);
    color: white;
    border: none;
}

.action-btn.info {
    background: #333;
    color: white;
    border: none;
}

.action-btn.flee {
    background: transparent;
    border: 1px solid #ff2a6d;
    color: #ff2a6d;
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 85%;
    max-width: 350px;
    text-align: center;
    border: 1px solid #444;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    font-family: var(--font-heading);
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
}

/* Reward Modal */
.reward-content {
    border: 2px solid var(--success-color);
    box-shadow: 0 0 30px rgba(5, 213, 170, 0.3);
}

.reward-title {
    color: var(--success-color);
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

.reward-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.reward-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.reward-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.reward-item .value {
    font-size: 1.2rem;
    color: white;
    font-weight: bold;
}

.stat-boost {
    color: var(--success-color);
    font-weight: bold;
}

.status-list {
    list-style: none;
    text-align: left;
    margin-bottom: 1.5rem;
}

.status-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #333;
}

.content-box {
    width: 100%;
    max-width: 400px;
}

#end-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
}

#end-screen .content-box {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

#end-title {
    margin-bottom: 0;
}

#end-message {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Animations */
@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes flash {
    0% {
        opacity: 1;
        filter: brightness(1);
    }

    50% {
        opacity: 0.5;
        filter: brightness(5) sepia(1) hue-rotate(-50deg) saturate(5);
    }

    100% {
        opacity: 1;
        filter: brightness(1);
    }
}

.flash {
    animation: flash 0.3s;
}

@keyframes attack-right {
    0% {
        transform: scaleX(-1) translateX(0);
    }

    50% {
        transform: scaleX(-1) translateX(50px);
    }

    100% {
        transform: scaleX(-1) translateX(0);
    }
}

.attack-anim {
    animation: attack-right 0.3s ease-in-out;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Small Mobile Devices (max 480px) */
@media (max-width: 480px) {
    .screen {
        padding: 1rem;
    }

    .game-title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .intro-text {
        font-size: 0.9rem;
    }

    .game-header {
        margin-bottom: 0.75rem;
    }

    #player-name-display {
        font-size: 1.2rem;
    }

    .stat-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    .weapon-info {
        font-size: 0.8rem;
    }

    .visual-area {
        min-height: 200px;
    }

    .vs-badge {
        font-size: 1.2rem;
    }

    #monster-name {
        font-size: 0.9rem;
    }

    .log-area {
        padding: 0.6rem;
        min-height: 40px;
    }

    #game-message {
        font-size: 0.8rem;
    }

    .game-actions {
        gap: 0.5rem;
        padding-top: 0.5rem;
    }

    .action-btn {
        padding: 0.7rem 0.3rem;
        font-size: 0.8rem;
    }

    .modal-content {
        width: 90%;
        padding: 1.5rem;
        max-height: 80vh;
        overflow-y: auto;
    }

    .modal-content h3 {
        font-size: 1.3rem;
    }

    .reward-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .reward-item .label {
        font-size: 0.7rem;
    }

    .reward-item .value {
        font-size: 1rem;
    }

    .status-list {
        font-size: 0.9rem;
    }

    .status-list li {
        padding: 0.4rem 0;
    }

    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    input {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    #attack-input {
        padding: 0.8rem;
        font-size: 1rem;
    }

    #attack-range {
        font-size: 0.9rem;
    }

    #end-title {
        font-size: 2rem;
    }

    #end-message {
        font-size: 1rem;
    }
}

/* Tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .app-container {
        max-width: 600px;
    }

    .screen {
        padding: 1.5rem;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .visual-area {
        min-height: 250px;
    }

    .modal-content {
        width: 80%;
        max-width: 450px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        max-height: 100vh;
    }

    .screen {
        padding: 0.5rem;
    }

    .game-header {
        margin-bottom: 0.5rem;
    }

    .visual-area {
        min-height: 150px;
    }

    .log-area {
        min-height: 30px;
        padding: 0.5rem;
    }

    .game-actions {
        padding-top: 0.5rem;
        gap: 0.5rem;
    }

    .action-btn {
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        padding: 1rem;
    }

    .game-title {
        font-size: 1.8rem;
    }

    .reward-title {
        font-size: 1.3rem;
    }
}

/* Large Tablets and Desktops (769px+) */
@media (min-width: 769px) {
    .app-container {
        max-width: 480px;
        height: 90vh;
    }

    .modal-content {
        width: 85%;
        max-width: 400px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .action-btn {
        min-height: 44px;
    }

    input {
        min-height: 44px;
    }

    .btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:active {
        transform: scale(0.95);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .entity-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .app-container {
        box-shadow: none;
        border: 1px solid #000;
    }

    .btn {
        border: 1px solid #000;
    }
}