@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

:root {
    --bg-dark: #2a1f14;
    --bg-medium: #3d2e1c;
    --bg-light: #4a3728;
    --bg-panel: #1e1610;
    --accent: #c9a227;
    --accent-light: #e0b830;
    --accent-green: #5a8a3c;
    --accent-green-light: #7aaa55;
    --text: #e8d5b0;
    --text-dim: #a89070;
    --text-light: #fff8e8;
    --text-dark: #1a1208;
    --hp-color: #c44040;
    --hp-dark: #8a2020;
    --mana-color: #4080c4;
    --mana-dark: #2a5580;
    --gold-color: #f0c040;
    --success: #5a8a3c;
    --danger: #b83030;
    --card-bg: rgba(30, 22, 16, 0.7);
    --card-border: rgba(201, 162, 39, 0.4);
    --border-wood: #6b4c2a;
    --shadow: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'MedievalSharp', 'Georgia', serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    image-rendering: pixelated;
}

#app {
    width: 100%;
    max-width: 420px;
    height: 100vh;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    background: var(--bg-medium);
    border-left: 3px solid var(--border-wood);
    border-right: 3px solid var(--border-wood);
}

/* ===== ЭКРАНЫ ===== */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

#screen-loading {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #3d2e1c, #1a1208);
}

.loading-content { text-align: center; }

.loading-content h1 {
    font-size: 2.8rem;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(201, 162, 39, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 1rem;
    letter-spacing: 3px;
}

.loading-content p {
    color: var(--text-dim);
    font-size: 1.1rem;
    letter-spacing: 2px;
}

/* ===== АВТОРИЗАЦИЯ ===== */
#screen-auth {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #3d2e1c, #1a1208);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 320px;
}

.auth-container h1 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--accent);
    text-shadow: 0 0 15px rgba(201, 162, 39, 0.4), 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 2rem;
    letter-spacing: 3px;
}

.auth-form {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    border: 2px solid var(--border-wood);
    box-shadow: 0 5px 20px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.auth-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 12px;
    border: 2px solid var(--border-wood);
    border-radius: 6px;
    background: rgba(0,0,0,0.4);
    color: var(--text);
    font-size: 1rem;
    font-family: 'MedievalSharp', serif;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.3);
}

.auth-input::placeholder {
    color: var(--text-dim);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--accent);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--accent), #a88520);
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.auth-btn:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
    box-shadow: 0 0 15px rgba(201, 162, 39, 0.4);
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-dim);
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}

.auth-link a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

.error-text {
    color: var(--danger);
    text-align: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
    min-height: 1.2em;
}

.hidden {
    display: none !important;
}

/* ===== РЕГИСТРАЦИЯ: ВЫБОР РАСЫ (ШАГ 2) ===== */
.race-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 15px 0;
}

.race-card {
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--border-wood);
    border-radius: 10px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.race-card:hover {
    border-color: var(--accent);
    background: rgba(201, 162, 39, 0.15);
    transform: translateY(-2px);
}

.race-card-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-bottom: 4px;
}

.race-card-name {
    font-weight: bold;
    color: var(--text);
    font-size: 12px;
}

.race-card-tag {
    color: var(--text-dim);
    font-size: 10px;
    margin-top: 2px;
}

/* ===== РЕГИСТРАЦИЯ: ДЕТАЛИ РАСЫ (ШАГ 3) ===== */
.race-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}

.race-detail-preview {
    text-align: center;
    margin-bottom: 10px;
}

.race-detail-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    image-rendering: pixelated;
    border: 2px solid var(--accent);
    border-radius: 10px;
    background: rgba(0,0,0,0.3);
    padding: 8px;
}

.gender-toggle {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
}

.gender-btn {
    padding: 8px 16px;
    border: 2px solid var(--border-wood);
    background: rgba(0,0,0,0.3);
    color: var(--text-dim);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'MedievalSharp', serif;
    transition: all 0.2s;
}

.gender-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(201, 162, 39, 0.15);
}

.race-detail-info {
    width: 100%;
    text-align: center;
}

.race-detail-info h3 {
    color: var(--accent);
    margin: 0 0 6px 0;
    font-size: 1.2rem;
}

.race-detail-info p {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.race-abilities {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    text-align: left;
}

.race-ability {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-wood);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text);
}

.ability-tag {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    margin-right: 4px;
    vertical-align: middle;
}

.ability-tag.perk { background: #2a5c2a; color: #7fff7f; }
.ability-tag.passive { background: #2a3d5c; color: #7fb3ff; }
.ability-tag.active { background: #5c2a2a; color: #ff7f7f; }

.back-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: linear-gradient(180deg, var(--accent), #a88520);
    color: var(--text-dark);
    border: 2px solid var(--accent);
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.back-btn:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
}

.confirm-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: linear-gradient(180deg, var(--accent), #a88520);
    color: var(--text-dark);
    border: 2px solid var(--accent);
    border-radius: 6px;
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.confirm-btn:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
    box-shadow: 0 0 15px rgba(201, 162, 39, 0.4);
}

/* ===== ИГРОВОЙ ЭКРАН ===== */
#screen-game { background: var(--bg-medium); }

/* === ВЕРХНЯЯ ПАНЕЛЬ === */
#top-panel {
    padding: 8px 12px;
    background: linear-gradient(to bottom, var(--bg-panel), var(--bg-dark));
    border-bottom: 3px solid var(--border-wood);
    box-shadow: 0 3px 10px var(--shadow);
}

.player-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.bar {
    height: 22px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--border-wood);
}

.bar-fill { height: 100%; transition: width 0.3s; }
.hp-bar .bar-fill { background: linear-gradient(90deg, var(--hp-dark), var(--hp-color)); }
.mana-bar .bar-fill { background: linear-gradient(90deg, var(--mana-dark), var(--mana-color)); }

/* XP бар */
.xp-bar { height: 14px; }
.xp-bar .bar-fill {
    background: linear-gradient(90deg, #806020, var(--accent));
}
.xp-bar span { font-size: 0.6rem; }

.bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-light);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    letter-spacing: 1px;
}

.player-info {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text);
    padding: 4px 0 0;
}

#player-name {
    color: var(--accent);
}

#player-level {
    color: var(--text-dim);
    margin-left: 8px;
}

#player-gold {
    color: var(--gold-color);
    margin-left: auto;
}

/* === ОСНОВНАЯ ОБЛАСТЬ === */
#main-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    display: none !important;
    width: 100%;
    height: 100%;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
}

.view.active {
    display: flex !important;
}

/* === ЛОКАЦИЯ === */
#location-view {
    background: var(--bg-light);
    position: relative;
    width: 100%;
    height: 100%;
}

#location-bg {
    padding: 15px;
    background: linear-gradient(to bottom, rgba(30, 22, 16, 0.9), rgba(30, 22, 16, 0.3));
}

#location-name {
    font-size: 1.4rem;
    margin-bottom: 4px;
    color: var(--accent);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    letter-spacing: 1px;
}

#location-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
}

#location-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}

#travel-buttons {
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    background: linear-gradient(to top, rgba(30, 22, 16, 0.9), transparent);
}

/* === ENTITY ITEMS === */
.entity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-wood);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.entity-item:hover {
    border-color: var(--accent);
    background: rgba(201, 162, 39, 0.1);
    transform: translateX(4px);
}

.entity-emoji { font-size: 2rem; }
.entity-info { flex: 1; }
.entity-name { font-weight: bold; font-size: 1rem; color: var(--text); }
.entity-desc { font-size: 0.8rem; color: var(--text-dim); }
.entity-level { font-size: 0.8rem; color: var(--accent); font-weight: bold; }
.attack-hint { font-size: 0.75rem; color: var(--danger); font-weight: bold; }

/* === БОЙ === */
#battle-view {
    background: #111;
    flex-direction: column;
}

#battle-view.active {
    display: flex !important;
}

#battle-canvas {
    width: 100%;
    height: 300px;
    display: block;
    border-bottom: 3px solid var(--border-wood);
    background: #0a0a0a;
}

#battle-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    max-height: 100px;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.6);
    color: var(--text-dim);
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.log-damage { color: #e85050; }
.log-heal { color: #50c850; }
.log-mana { color: #50a0e8; }

#battle-skills {
    display: flex;
    gap: 8px;
    padding: 10px;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--bg-panel);
    border-top: 2px solid var(--border-wood);
}

.skill-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: linear-gradient(180deg, #3a3020, #252018);
    border: 2px solid var(--border-wood);
    border-radius: 8px;
    cursor: pointer;
    min-width: 65px;
    transition: all 0.15s;
}

.skill-btn:hover {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.3);
}

.skill-btn:active {
    transform: scale(0.95);
    border-color: var(--accent-light);
}

.skill-btn.on-cooldown {
    opacity: 0.4;
    pointer-events: none;
}

.skill-icon-img {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    border-radius: 4px;
}

.skill-emoji { font-size: 1.6rem; }

.skill-name {
    font-size: 9px;
    color: var(--text-dim);
    text-align: center;
    font-family: 'MedievalSharp', serif;
}

.cooldown-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 14px;
    font-weight: bold;
}

#btn-flee, #btn-surrender { margin: 8px 15px 12px; }

.btn-danger {
    padding: 12px 25px;
    border: 2px solid var(--danger);
    border-radius: 6px;
    background: linear-gradient(180deg, #c44040, #8a2020);
    color: var(--text-light);
    font-size: 1rem;
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-danger:hover {
    background: linear-gradient(180deg, #d45050, #a03030);
}

.btn-success {
    padding: 12px 25px;
    border: 2px solid var(--success);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--accent-green-light), var(--accent-green));
    color: var(--text-light);
    font-size: 1rem;
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    letter-spacing: 1px;
}

/* === PVP === */
#pvp-view { background: var(--bg-light); }

#pvp-opponent {
    padding: 20px;
    text-align: center;
    background: linear-gradient(to bottom, var(--bg-panel), transparent);
}

#pvp-opponent-image { width: 100px; height: 100px; object-fit: contain; border-radius: 10px; }
#pvp-opponent-name { margin: 10px 0; font-size: 1.2rem; color: var(--accent); }

.opponent-hp-bar { width: 200px; height: 20px; margin: 0 auto; }
.opponent-hp-bar .bar-fill { background: linear-gradient(90deg, var(--hp-dark), var(--hp-color)); }

#pvp-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.3);
    margin: 8px;
    border-radius: 6px;
}

#pvp-skills {
    display: flex;
    gap: 8px;
    padding: 10px;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--bg-panel);
}

/* === ПУТЕШЕСТВИЕ === */
#travel-view {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, var(--bg-light), var(--bg-dark));
}

.travel-content {
    text-align: center;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--border-wood);
    margin: 20px;
    box-shadow: 0 5px 20px var(--shadow);
}

.travel-content h2 {
    margin-bottom: 15px;
    color: var(--accent);
    letter-spacing: 1px;
}

#travel-destination {
    font-size: 1.2rem;
    color: var(--accent-light);
    font-weight: bold;
    margin-bottom: 20px;
}

#travel-progress {
    width: 250px;
    height: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 5px;
    margin: 0 auto 15px;
    overflow: hidden;
    border: 2px solid var(--border-wood);
}

#travel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    width: 0%;
    transition: width 0.1s linear;
}

#travel-time { color: var(--text-dim); }

/* ===== НИЖНЯЯ ПАНЕЛЬ ===== */
#bottom-panel {
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    background: linear-gradient(to top, var(--bg-panel), var(--bg-dark));
    border-top: 3px solid var(--border-wood);
    box-shadow: 0 -3px 10px var(--shadow);
}

.nav-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-wood);
    border-radius: 10px;
    background: linear-gradient(180deg, #3a3020, #252018);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.nav-btn:hover, .nav-btn.active {
    background: linear-gradient(180deg, var(--accent), #a88520);
    border-color: var(--accent-light);
    box-shadow: 0 0 10px rgba(201, 162, 39, 0.4);
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
#modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 8, 5, 0.85);
    z-index: 100;
}

.modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 380px;
    max-height: 80%;
    background: var(--bg-light);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 3px solid var(--border-wood);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 20px rgba(201, 162, 39, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(to bottom, var(--bg-panel), var(--bg-dark));
    border-bottom: 2px solid var(--border-wood);
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.modal-close {
    width: 30px; height: 30px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    background: linear-gradient(180deg, #c44040, #8a2020);
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg-light);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* === ПЕРСОНАЖ === */
#char-avatar {
    width: 100px; height: 100px;
    margin: 0 auto 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    border: 2px solid var(--border-wood);
    display: flex;
    align-items: center;
    justify-content: center;
}

#char-info { text-align: center; margin-bottom: 20px; }
#char-info p { margin: 5px 0; color: var(--text); }
#char-name { color: var(--accent); font-size: 1.2rem; }

#char-stats h4 { margin-bottom: 10px; color: var(--accent); }
#stat-points { color: var(--accent-light); font-weight: bold; }

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid rgba(107, 76, 42, 0.3);
    background: var(--card-bg);
    margin-bottom: 4px;
    border-radius: 6px;
    border: 1px solid var(--border-wood);
}

.btn-stat {
    width: 30px; height: 30px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: linear-gradient(180deg, var(--accent), #a88520);
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
}

.btn-stat:disabled {
    background: rgba(0,0,0,0.3);
    border-color: rgba(107, 76, 42, 0.3);
    color: var(--text-dim);
    cursor: not-allowed;
}

#char-race-info { margin-top: 20px; }
#char-race-info h4 { margin-bottom: 10px; color: var(--accent); }
#char-race-info div {
    padding: 12px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-wood);
    color: var(--text);
}

/* === ПАРАМЕТРЫ ПЕРСОНАЖА === */
#char-params {
    margin-top: 15px;
    margin-bottom: 15px;
}

#char-params h4 {
    margin-bottom: 10px;
    color: var(--accent);
}

.param-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.85rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 2px;
    border-radius: 4px;
}

.param-row span {
    color: var(--accent-light);
    font-weight: bold;
}
/* === ИНВЕНТАРЬ === */
#equipment-slots {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.equip-slot {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 2px solid var(--border-wood);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.inv-slot {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 2px solid var(--border-wood);
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inv-slot.empty { background: rgba(0,0,0,0.2); }
.inv-slot.has-item:hover { border-color: var(--accent); }

.inv-slot .quantity {
    position: absolute;
    bottom: 1px; right: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text-light);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}

.inv-slot-actions {
    position: absolute;
    bottom: 2px;
    right: 2px;
}

.inv-equip-btn, .inv-use-btn {
    width: 20px;
    height: 20px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: rgba(201, 162, 39, 0.3);
    font-size: 10px;
    cursor: pointer;
    padding: 0;
    line-height: 20px;
}

.inv-equip-btn:hover, .inv-use-btn:hover {
    background: var(--accent);
}

.inv-item-icon {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    pointer-events: none;
}

.item-emoji { font-size: 1.3rem; }

/* === НАВЫКИ === */
#skills-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skill-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-wood);
    border-radius: 8px;
}

.skill-icon-wrap {
    width: 50px; height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    border: 2px solid var(--border-wood);
}

.skill-emoji-big { font-size: 1.8rem; }
.skill-details h4 { margin-bottom: 4px; color: var(--accent); }
.skill-details p { font-size: 0.8rem; color: var(--text-dim); }
.skill-stats { font-size: 0.75rem; color: var(--accent-green-light) !important; margin-top: 4px; }

/* === ЧАТ === */
#chat-messages {
    height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    margin-bottom: 10px;
    border: 2px solid var(--border-wood);
}

.chat-msg { margin-bottom: 8px; font-size: 0.9rem; color: var(--text); }
.chat-msg .author { color: var(--accent); font-weight: bold; }

#chat-input-area { display: flex; gap: 8px; }

#chat-input {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-wood);
    border-radius: 6px;
    background: rgba(0,0,0,0.4);
    color: var(--text);
    font-size: 1rem;
    font-family: 'MedievalSharp', serif;
}

#chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.3);
}

#btn-send-chat {
    width: 50px;
    border: 2px solid var(--accent);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--accent), #a88520);
    color: var(--text-dark);
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: bold;
}

#btn-send-chat:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
}

/* ===== КАРТА МИРА ===== */
#world-wrapper {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: #1a1a2e;
    position: relative;
}

#world-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
}

#world-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#explore-btn {
    display: none !important;
}

#explore-btn:hover {
    opacity: 1;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 8px rgba(201, 162, 39, 0.3);
}

#explore-btn:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(201, 162, 39, 0.5);
}

.explore-btn.portal-btn {
    background: linear-gradient(135deg, var(--accent), #a88520) !important;
    border-color: var(--gold-color) !important;
}

.explore-btn.npc-btn {
    background: linear-gradient(135deg, #4488ff, #3366cc);
}

.explore-btn.mob-btn {
    background: linear-gradient(135deg, #cc4444, #aa2222);
}

#city-wrapper {
    display: block;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-light);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

#world-canvas.shake { animation: shake 0.3s ease-in-out; }

/* ===== NPC ДИАЛОГ ===== */
#npc-dialog-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 80px;
}

.npc-dialog-box {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid var(--accent);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    padding: 16px;
    color: #fff;
    box-shadow: 0 0 20px rgba(200, 168, 78, 0.3);
}

.npc-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.npc-dialog-name {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--accent);
}

.npc-dialog-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2em;
    cursor: pointer;
}

.npc-dialog-text {
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 16px;
    min-height: 50px;
}

.npc-dialog-footer { text-align: right; }

.npc-dialog-btn {
    background: linear-gradient(135deg, var(--accent), #a88a3e);
    border: none;
    color: var(--text-dark);
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95em;
    font-family: 'MedievalSharp', serif;
}

.npc-dialog-btn:active { transform: scale(0.95); }

/* ===== КВЕСТЫ ===== */
.quest-offer {
    background: rgba(201, 162, 39, 0.1);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
}

.quest-offer-title {
    font-size: 1.05em;
    font-weight: bold;
    color: var(--gold-color);
    margin-bottom: 6px;
}

.quest-offer-desc {
    font-size: 0.85em;
    color: #ccc;
    margin-bottom: 8px;
    line-height: 1.4;
}

.quest-offer-rewards { margin-bottom: 10px; }

.reward-list {
    font-size: 0.85em;
    color: var(--accent-green-light);
    font-weight: bold;
}

.quest-offer-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.quest-accept {
    background: linear-gradient(135deg, var(--accent-green), #4a7a2c) !important;
    color: #fff !important;
    border: 2px solid var(--accent-green-light) !important;
    padding: 10px 24px !important;
    border-radius: 6px !important;
    font-weight: bold;
    cursor: pointer;
    font-family: 'MedievalSharp', serif;
    font-size: 0.95em;
}

.quest-accept:hover {
    background: linear-gradient(135deg, var(--accent-green-light), var(--accent-green)) !important;
    box-shadow: 0 0 10px rgba(122, 170, 85, 0.4);
}

.quest-decline {
    background: linear-gradient(135deg, #8a2020, #6a1515) !important;
    color: #fff !important;
    border: 2px solid var(--danger) !important;
    padding: 10px 24px !important;
    border-radius: 6px !important;
    font-weight: bold;
    cursor: pointer;
    font-family: 'MedievalSharp', serif;
    font-size: 0.95em;
}

.quest-decline:hover {
    background: linear-gradient(135deg, var(--danger), #8a2020) !important;
}

.quest-progress-info {
    background: rgba(201, 162, 39, 0.1);
    border: 2px solid var(--border-wood);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.quest-progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
    border: 1px solid var(--border-wood);
}

.quest-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 4px;
    transition: width 0.3s;
}

.quest-progress-text {
    font-size: 0.85em;
    color: var(--accent);
    font-weight: bold;
    text-align: center;
}

.notification.quest {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--accent);
}

/* ===== УВЕДОМЛЕНИЯ ===== */
#notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    padding: 12px 20px;
    border-radius: 8px;
    color: var(--text-light);
    font-weight: bold;
    font-family: 'MedievalSharp', serif;
    animation: slideIn 0.3s ease;
    max-width: 300px;
    border: 2px solid;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.notification.info { background: var(--mana-dark); border-color: var(--mana-color); }
.notification.success { background: #2a5520; border-color: var(--success); }
.notification.error { background: #5a1818; border-color: var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== СКРОЛЛБАР ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--border-wood); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 500px) {
    .race-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .race-card { padding: 6px 2px; }
    .race-card-img { width: 40px; height: 40px; }
    .race-card-name { font-size: 11px; }
    .race-card-tag { font-size: 9px; }
    .race-detail-img { width: 80px; height: 80px; }
    .gender-btn { padding: 6px 12px; font-size: 12px; }
}
#screen-game.active {
    display: flex !important;
    flex-direction: column;
}

#main-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

#location-view.active {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

#world-wrapper {
    flex: 1;
    min-height: 0;
}

/* === ТУЛТИП ПРЕДМЕТА === */
#item-tooltip-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-tooltip {
    background: linear-gradient(135deg, var(--bg-panel), var(--bg-dark));
    border: 2px solid var(--border-wood);
    border-radius: 10px;
    padding: 16px;
    width: 260px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.7), 0 0 15px rgba(201, 162, 39, 0.15);
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-wood);
}

.tooltip-icon {
    width: 44px;
    height: 44px;
    image-rendering: pixelated;
    border-radius: 6px;
    border: 2px solid var(--border-wood);
    background: rgba(0,0,0,0.3);
    padding: 4px;
}

.tooltip-name {
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--accent);
}

.tooltip-type {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.tooltip-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 10px;
    line-height: 1.4;
}

.tooltip-stats {
    margin-bottom: 10px;
}

.tooltip-stat {
    font-size: 0.85rem;
    color: var(--accent-green-light);
    padding: 2px 0;
}

.tooltip-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-wood);
}

.tooltip-btn {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    font-family: 'MedievalSharp', serif;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid;
    text-align: center;
    letter-spacing: 0.5px;
}

.tooltip-btn-equip {
    background: linear-gradient(180deg, var(--accent), #a88520);
    border-color: var(--accent);
    color: var(--text-dark);
}

.tooltip-btn-equip:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
}

.tooltip-btn-use {
    background: linear-gradient(180deg, var(--accent-green-light), var(--accent-green));
    border-color: var(--accent-green);
    color: var(--text-light);
}

.tooltip-btn-use:hover {
    background: linear-gradient(180deg, #8aba65, var(--accent-green-light));
}

.tooltip-btn-delete {
    background: linear-gradient(180deg, #c44040, #8a2020);
    border-color: var(--danger);
    color: var(--text-light);
}

.tooltip-btn-delete:hover {
    background: linear-gradient(180deg, #d45050, #a03030);
}

.tooltip-btn-close {
    background: linear-gradient(180deg, #3a3020, #252018);
    border-color: var(--border-wood);
    color: var(--text-dim);
}

.tooltip-btn-close:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* === ЭКИПИРОВАННЫЕ ИКОНКИ === */
.equip-slot-icon {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    pointer-events: none;
}

/* ============================================
   ВЕРХНЯЯ ПАНЕЛЬ — НОВЫЙ ДИЗАЙН
   ============================================ */

#top-panel {
    display: flex;
    align-items: flex-start;
    padding: 6px 8px 0 8px;
    background: linear-gradient(180deg, rgba(15,15,30,0.95) 0%, rgba(15,15,30,0.8) 100%);
    border-bottom: 1px solid rgba(201,162,39,0.3);
    position: relative;
    flex-wrap: wrap;
    gap: 0;
    z-index: 100;
}

/* === ЛЕВАЯ ЧАСТЬ === */
.tp-left {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

/* Аватар */
.tp-avatar-wrap {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.tp-avatar-wrap img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid #4a9e4a;
    object-fit: cover;
    background: #1a1a2e;
}

#tp-level-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: linear-gradient(135deg, #c9a227, #a8841a);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #1a1a2e;
    line-height: 1;
}

/* Инфо блок */
.tp-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 1px;
}

.tp-name-row {
    display: flex;
    align-items: center;
}

#tp-name {
    font-weight: bold;
    font-size: 12px;
    color: #c9a227;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === БАРЫ HP / MP / FOOD === */
.tp-bar {
    position: relative;
    height: 10px;
    background: #1a1a1a;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.tp-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.tp-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px #000, 0 0 3px #000;
    white-space: nowrap;
    line-height: 1;
}

/* HP — красный */
.tp-bar.hp .tp-bar-fill {
    background: linear-gradient(90deg, #8a2020, #c44040);
}

/* MP — синий */
.tp-bar.mp .tp-bar-fill {
    background: linear-gradient(90deg, #2a5580, #4080c4);
}

/* Сытость — зелёный */
.tp-bar.food .tp-bar-fill {
    background: linear-gradient(90deg, #2a7a2a, #4a9e4a);
}

/* Баффы */
#tp-buffs {
    display: flex;
    gap: 4px;
    margin-top: 1px;
    flex-wrap: wrap;
}

#tp-buffs .buff-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(90,138,60,0.6);
    border: 1px solid #7aaa55;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    position: relative;
}

#tp-buffs .buff-icon .buff-timer {
    position: absolute;
    bottom: -6px;
    font-size: 7px;
    color: #fff;
    text-shadow: 0 0 2px #000;
}

/* === ПРАВАЯ ЧАСТЬ === */
.tp-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    padding-top: 2px;
}

/* Компас */
.tp-compass {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: 1.5px solid #c9a227;
}

.tp-compass span {
    position: absolute;
    font-size: 8px;
    font-weight: bold;
    color: #aaa;
}

.tp-compass-n {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    color: #cc4444 !important;
}

.tp-compass-s {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.tp-compass-w {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.tp-compass-e {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.tp-compass-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #c9a227;
}

/* Координаты */
#tp-coords {
    font-size: 9px;
    color: #c9a227;
    background: rgba(0,0,0,0.5);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid #444;
}

/* Кнопки действий */
.tp-actions {
    display: flex;
    gap: 4px;
}

.tp-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(42,42,62,0.8);
    border: 1px solid rgba(201,162,39,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tp-action-btn:active {
    background: rgba(201,162,39,0.3);
}

#tp-nearby-count {
    font-size: 8px;
    color: #e8d5b0;
}

/* === XP БАР ВНИЗУ === */
.tp-xp-bar {
    position: relative;
    width: 100%;
    height: 8px;
    background: #1a1a1a;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
    margin-top: 4px;
}

.tp-xp-bar .tp-bar-fill {
    background: linear-gradient(90deg, #8a7a20, #c9a227);
    border-radius: 0 0 4px 4px;
}

.tp-xp-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px #000;
    white-space: nowrap;
}

/* Скрываем старые стили */
.player-bars,
.player-info {
    display: none !important;
}
/* === Кнопки зелий в бою === */
.potion-btn {
    position: relative;
    border-color: #6b4c2a;
    background: linear-gradient(180deg, #2a3020, #1a2018);
}

.potion-btn:hover {
    border-color: #c9a227;
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
}

.potion-count {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    color: #fff;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.potion-btn.potion-empty {
    opacity: 0.3;
    pointer-events: none;
}