/* ============================================================
   FANTASY WORLD — stylesheet
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-deep:      #09080f;
    --bg-dark:      #100e1a;
    --bg-mid:       #18152a;
    --bg-card:      #1c1830;
    --bg-card-hover:#221e38;
    --gold:         #c9a840;
    --gold-light:   #e8d48a;
    --gold-dim:     #75601e;
    --purple:       #5a3a8a;
    --purple-light: #9b72cf;
    --text:         #d4cde8;
    --text-muted:   #7a7090;
    --border:       #2e2645;
    --border-gold:  #4a3a10;
    --radius:       6px;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text);
    font-family: 'Lora', Georgia, serif;
    font-size: 15px;
    line-height: 1.7;
}

h1, h2, h3, h4 { padding: 0; margin: 0; }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-light); }

p { margin: 0 0 .8em; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple-light); }

/* ---------- Grid ---------- */
[class*="col"] { float: left; }
.row::after { content: ""; clear: both; display: table; }
[class*="col"] { width: 100%; }       /* mobile first */

video, img { max-width: 100%; height: auto; }

/* ---------- HEADER ---------- */
header {
    position: relative;
    background-image: url(img/head.jpeg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center 30%;
    height: 280px;
    margin-top: 12px;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

/* dark overlay on top of image */
.header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        120deg,
        rgba(9, 5, 20, 0.82) 0%,
        rgba(9, 5, 20, 0.55) 55%,
        rgba(9, 5, 20, 0.25) 100%
    );
}

div.bk {
    position: absolute;
    padding: 22px 28px;
    top: 50%;
    transform: translateY(-50%);
    left: 16px;
    z-index: 2;
}

header h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow:
        0 0 18px rgba(201, 168, 64, 0.8),
        0 0 40px rgba(201, 168, 64, 0.4),
        2px 2px 4px rgba(0,0,0,0.9);
    letter-spacing: .05em;
}

.header-ornament {
    color: var(--gold-dim);
    font-size: .85rem;
    letter-spacing: .15em;
    margin: 6px 0 10px;
    animation: pulse-gold 3s ease-in-out infinite;
}

header h2 {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 1.15rem;
    color: rgba(212, 205, 232, 0.85);
    text-shadow: 1px 1px 6px rgba(0,0,0,0.9);
    letter-spacing: .06em;
}

.header-scroll-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--gold-dim);
    font-size: 1.4rem;
    animation: bounce 2s ease-in-out infinite;
    z-index: 2;
}

@keyframes pulse-gold {
    0%, 100% { opacity: .6; }
    50%       { opacity: 1; }
}
@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%       { transform: translateX(-50%) translateY(5px); }
}

/* ---------- NAVBAR ---------- */
nav {
}

ul.topnav {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(to bottom, #1a1530, #120f22);
    border-bottom: 1px solid var(--border-gold);
    font-family: 'Cinzel', serif;
    font-size: .8rem;
    letter-spacing: .08em;
}

ul.topnav li { float: left; }
ul.topnav li.right { float: right; }

ul.topnav li a {
    display: block;
    color: var(--text-muted);
    text-align: center;
    padding: 14px 18px;
    text-decoration: none;
    transition: color .25s, background .25s;
    position: relative;
}

ul.topnav li a::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%; right: 50%;
    height: 2px;
    background: var(--gold);
    transition: left .25s, right .25s;
}

ul.topnav li a:hover,
ul.topnav li a.active {
    color: var(--gold-light);
    background: rgba(201,168,64,.07);
}

ul.topnav li a:hover::after,
ul.topnav li a.active::after {
    left: 0; right: 0;
}

.branav {
    background: linear-gradient(to right, var(--bg-deep), var(--purple), var(--bg-deep));
    height: 2px;
}

/* ---------- ASIDE ---------- */
aside {
    background: linear-gradient(180deg, #1a1528 0%, var(--bg-deep) 100%);
    padding-top: 10px;
    border-right: 1px solid var(--border);
}

.sideblock {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    min-height: 120px;
}

.sideblock:last-child { border-bottom: none; }

.title {
    font-family: 'Cinzel', serif;
    font-size: .95rem;
    color: var(--gold);
    letter-spacing: .12em;
    padding: 0 0 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-gold);
    text-shadow: 0 0 10px rgba(201,168,64,.3);
}

.orn {
    color: var(--purple-light);
    margin-right: 6px;
    font-size: .8em;
}

.side-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.side-list li {
    padding: 4px 0;
    border-bottom: 1px solid rgba(46,38,69,.4);
    font-size: .88rem;
    color: var(--text-muted);
}
.side-list li:last-child { border-bottom: none; }
.side-list li a {
    color: var(--text-muted);
    transition: color .2s, padding-left .2s;
    display: block;
}
.side-list li a:hover {
    color: var(--gold-light);
    padding-left: 6px;
}

.bcont {
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ---------- CONTENT AREA ---------- */
.bordfr {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.marginfcol {
    padding: 18px 20px 20px;
    background: var(--bg-dark);
}

.contsect {
    margin-bottom: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .3s, box-shadow .3s;
}

.contsect:hover {
    border-color: var(--gold-dim);
    box-shadow: 0 0 20px rgba(201,168,64,.08), 0 4px 24px rgba(0,0,0,.5);
}

.contitle {
    background: linear-gradient(to right, #221b38, #1a1630);
    padding: 10px 16px;
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: .06em;
    border-left: 4px solid var(--gold);
    display: flex;
    align-items: center;
    gap: 12px;
}

.tale-num {
    font-family: 'Cinzel Decorative', serif;
    font-size: .8rem;
    color: var(--purple-light);
    background: rgba(90,58,138,.18);
    border: 1px solid var(--purple);
    border-radius: 3px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.contcon {
    padding: 14px 16px;
    background: var(--bg-card);
    color: var(--text);
    font-size: .93rem;
}

.contfoot {
    background: var(--bg-card);
    padding: 8px 16px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}

.ornament-line {
    color: var(--gold-dim);
    font-size: .75rem;
    letter-spacing: .1em;
    opacity: .7;
}

.read-more {
    font-family: 'Cinzel', serif;
    font-size: .78rem;
    letter-spacing: .1em;
    color: var(--gold);
    border: 1px solid var(--border-gold);
    padding: 5px 14px;
    border-radius: 3px;
    transition: background .2s, color .2s, border-color .2s;
}
.read-more:hover {
    background: var(--gold);
    color: var(--bg-deep);
    border-color: var(--gold);
}

/* ---------- FOOTER ---------- */
footer {
    position: relative;
    background: #07050f;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    align-items: flex-end;
}

.footer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: top center;
}

.footer-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    text-align: center;
    padding: 60px 20px 20px;
    background: linear-gradient(to top, #07050f 45%, rgba(7, 5, 15, 0.8) 70%, transparent 100%);
}

.footer-logo {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.3rem;
    color: var(--gold);
    text-shadow: 0 0 14px rgba(201,168,64,.5);
    margin-bottom: 10px;
}

.footer-copy {
    color: var(--text-muted);
    font-size: .82rem;
    margin: 4px 0;
}

.footer-links {
    margin: 8px 0 0;
    font-size: .82rem;
}
.footer-links a {
    color: var(--text-muted);
    transition: color .2s;
}
.footer-links a:hover { color: var(--gold-light); }

/* ---------- RPG UI STYLES ---------- */

.setup-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.setup-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setup-group label {
    font-family: 'Cinzel', serif;
    color: var(--gold-light);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

.rpg-input {
    background: #100e1a;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    width: 100%;
}

.rpg-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(201, 168, 64, 0.2);
}

.rpg-btn {
    background: linear-gradient(to right, #221b38, #1a1630);
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.1em;
    text-shadow: 0 0 5px rgba(201, 168, 64, 0.5);
    width: 100%;
}

.rpg-btn:hover {
    background: var(--gold);
    color: var(--bg-deep);
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(201, 168, 64, 0.4);
    text-shadow: none;
}

/* Chat Log Area */
.chat-log {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 480px;
    overflow-y: auto;
    padding: 20px;
    background: url(img/head.jpeg) center bottom / cover no-repeat;
    position: relative;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
}

.chat-log::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(16, 14, 26, 0.85);
    z-index: 0;
}

.msg {
    position: relative;
    z-index: 1;
    border-radius: 8px;
    padding: 14px 18px;
    max-width: 85%;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.msg-header {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.msg-speaker-name { flex: 1; }

.msg-delete-btn {
    background: none;
    border: none;
    color: transparent;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}
.msg:hover .msg-delete-btn { color: rgba(255,255,255,0.35); }
.msg-delete-btn:hover { color: #ff6b6b !important; background: rgba(255,80,80,0.12); }
    letter-spacing: 0.05em;
    opacity: 0.9;
}

.msg-body {
    font-size: 0.95rem;
}

/* Character Specific Chat Styles */
.msg-gm {
    background: rgba(26, 20, 15, 0.9);
    border: 1px solid var(--border-gold);
    color: #e8d48a;
    align-self: center;
    max-width: 95%;
    text-align: center;
}
.msg-gm .msg-header {
    color: var(--gold);
    text-transform: uppercase;
}

.msg-ai-1 {
    background: rgba(30, 20, 45, 0.85);
    border: 1px solid rgba(90, 58, 138, 0.6);
    align-self: flex-start;
}
.msg-ai-1 .msg-header { color: var(--purple-light); }

.msg-ai-2 {
    background: rgba(45, 20, 20, 0.85);
    border: 1px solid rgba(138, 58, 58, 0.6);
    align-self: flex-start;
}
.msg-ai-2 .msg-header { color: #f28b8b; }

.msg-ai-3 {
    background: rgba(20, 45, 25, 0.85);
    border: 1px solid rgba(58, 138, 70, 0.6);
    align-self: flex-start;
}
.msg-ai-3 .msg-header { color: #8bf293; }

.msg-player {
    background: rgba(20, 30, 45, 0.85);
    border: 1px solid rgba(80, 120, 180, 0.6);
    align-self: flex-end;
}
.msg-player .msg-header { 
    color: #8bb4f2; 
    text-align: right; 
}

.chat-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

.rpg-textarea {
    flex-grow: 1;
    resize: none;
    height: 60px;
    background: rgba(16, 14, 26, 0.9);
}

.action-btn {
    width: auto;
    padding: 0 24px;
    min-width: 140px;
}

/* Saved games list */
.saved-game-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(46,38,69,.4);
    font-size: .82rem;
}
.saved-game-item:last-child { border-bottom: none; }
.sg-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.sg-date {
    color: var(--text-muted);
    font-size: .75rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.sg-actions { display: flex; gap: 4px; flex-shrink: 0; }
.sg-load-btn, .sg-del-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    padding: 1px 5px;
    font-size: .75rem;
    line-height: 1.4;
    transition: background .2s, color .2s;
}
.sg-load-btn { color: var(--gold); }
.sg-load-btn:hover { background: var(--gold); color: var(--bg-deep); border-color: var(--gold); }
.sg-del-btn { color: #c05050; }
.sg-del-btn:hover { background: #c05050; color: #fff; border-color: #c05050; }

/* Typing indicator dots */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 1.4em;
}
.typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* ---------- MEDIA QUERIES ---------- */
@media only screen and (min-width: 700px) {
    .col-1  { width: 8.33%; }
    .col-2  { width: 16.66%; }
    .col-3  { width: 25%; }
    .col-4  { width: 33.33%; }
    .col-5  { width: 41.66%; }
    .col-6  { width: 50%; }
    .col-7  { width: 58.33%; }
    .col-8  { width: 66.66%; }
    .col-9  { width: 75%; }
    .col-10 { width: 83.33%; }
    .col-11 { width: 91.66%; }
    .col-12 { width: 100%; }
}

@media only screen and (min-width: 1200px) {
    body { width: 1200px; margin: auto; }
}

@media only screen and (min-width: 800px) {
    header { background-position: center -60px; height: 300px; }
}

@media screen and (max-width: 700px) {
    ul.topnav li,
    ul.topnav li.right { float: none; }
    ul.topnav li a::after { display: none; }
    aside { border-right: none; border-bottom: 1px solid var(--border); }
    header h1 { font-size: 1.6rem; }

    /* Убираем лишние боковые отступы */
    .marginfcol { padding: 8px 8px 12px; }

    /* Настройка секций */
    .setup-grid { padding: 12px 10px; gap: 12px; }
    .contfoot { padding: 8px 8px 10px; }
    .contcon { padding: 10px 10px; }

    /* Чат: высота и отступы */
    .chat-log {
        padding: 10px 8px;
        max-height: calc(100svh - 360px);
        min-height: 200px;
    }

    /* Сообщения: растянуть на всю ширину */
    .msg { max-width: 98%; padding: 10px 12px; }
    .msg-gm { max-width: 100%; }

    /* Поле ввода + кнопка — колонкой */
    .chat-controls {
        flex-direction: column;
        gap: 8px;
    }
    .rpg-textarea { height: 72px; flex-grow: unset; }
    .action-btn {
        width: 100%;
        min-width: unset;
        padding: 12px;
    }
}

@media only screen and (max-width: 400px) {
    header { height: 200px; }
    div.bk { padding: 14px; }
    header h1 { font-size: 1.3rem; }
    .marginfcol { padding: 6px 6px 10px; }
    .setup-grid { padding: 10px 8px; }
}