:root {
    --bg-dark: #161A1D;
    --bg-card: #0B090A;
    --primary-red: #A4161A;
    --secondary-red: #ff4d4d;
    --accent-red: #E5383B;
    --text-silver: #B1A7A6;
    --text-white: #F5F3F4;
    --dark-gray: #444;
    --light-gray: #999;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-silver);
    font-family: 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 1rem 2rem;
    background-color: var(--bg-card);
    border-bottom: 2px solid var(--primary-red);
}

.nav-logo {
    height: 32px;
    display: block;
}

nav a, nav span {
    color: var(--text-white);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

nav a:hover { color: var(--accent-red); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    margin-top: 50px;
    padding: 0 20px;
}

h1 {
    color: var(--text-white);
    margin-bottom: 1.5rem;
    border-left: 5px solid var(--primary-red);
    padding-left: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#games-list, #my-games-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

#games-list > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 22px;
    min-height: 260px;
    position: relative;
    transition: 0.2s ease;
    box-shadow: var(--shadow);
    color: var(--light-gray);
    font-size: 0.95rem;
}

#games-list > div:hover {
    border-color: var(--dark-gray);
    transform: translateY(-2px);
}

#games-list > div b {
    font-size: 1.8rem;
    color: #F5F3F4;
    margin-bottom: -5px;
    display: block;
}

#games-list > div a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: 0.2s ease;
    background: var(--primary-red);
    color: white;
    text-decoration: none;
    border: none;
    margin-top: auto;
}

#games-list > div a:hover {
    background: #c1121f;
}

button, .btn_link, #games-list a, #my-games-list a, #game-actions a, #game-actions button {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    transition: background 0.3s;
    margin: 5px 2px;
}

button:hover, .btn_link:hover {
    background-color: var(--accent-red);
}

#login_box {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    border-top: 4px solid var(--primary-red);
    box-shadow: var(--shadow);
}

.logo { width: 300px; margin-bottom: 20px; }

input, textarea {
    width: 100%;
    background: #1b1b1b;
    border: 1px solid var(--dark-gray);
    padding: 12px;
    color: white;
    margin: 10px 0;
    border-radius: 4px;
}

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

.game-player {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin-top: 20px;
}

.game-player iframe {
    display: block;
    max-width: 100%;
    background: white;
    border: 4px solid var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.fullscreen-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgb(0 0 0 / 0.75);
    color: #fff;
    border: 1px solid rgb(255 255 255 / 0.25);
    border-radius: 6px;
    cursor: pointer;
    margin: 0;
    width: auto;
}

.fullscreen-btn:hover {
    background: var(--primary-red);
    border-color: var(--primary-red);
}

.game-player:fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    background: #000;
}

.game-player:fullscreen iframe {
    width: 100%;
    height: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.game-player:fullscreen .fullscreen-btn {
    top: 16px;
    right: 16px;
}

#logout-btn {
    margin-left: auto;
    background-color: transparent;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
}

#logout-btn:hover {
    background-color: var(--primary-red);
    color: white;
}

#login_box form button[type="submit"] {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-top: 15px;
    box-shadow: 0 4px 20px rgba(164, 22, 26, 0.5);
    transition: transform 0.2s;
}

#login_box form button[type="submit"]:hover {
    transform: scale(1.02);
    background-color: var(--accent-red);
}

.btn_link {
    font-size: 0.85rem;
    opacity: 0.6;
    background: none;
    color: #B1A7A6;
    border: none;
    margin: 5px 10px;
}

.btn_link:hover {
    opacity: 1;
    color: #F5F3F4;
    background: none;
    text-decoration: underline;
}

.auth-links {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

a {
    color: var(--primary-red);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--accent-red);
}

#my-games-list > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 22px;
    min-height: 220px;
    position: relative;
    transition: 0.2s ease;
}

#my-games-list > div:hover {
    border-color: var(--dark-gray);
    transform: translateY(-2px);
}

#my-games-list > div b {
    font-size: 1.8rem;
    color: #F5F3F4;
    margin-bottom: -5px;
}

#my-games-list > div span {
    color: var(--light-gray);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

#my-games-list > div a, #my-games-list > div button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: 0.2s ease;
}

#my-games-list > div a {
    background: var(--primary-red);
    color: white;
    text-decoration: none;
    border: none;
}

#my-games-list > div a:hover {
    background: #c1121f;
}

#my-games-list > div button {
    background: transparent;
    border: 1px solid #666;
    color: #ddd;
}

#my-games-list > div button:hover {
    border-color: var(--light-gray);
    color: white;
}

#my-games-list > div button:last-child {
    position: absolute;
    right: 22px;
    bottom: 22px;
    border: 1px solid var(--secondary-red);
    color: var(--secondary-red);
}

#my-games-list > div button:last-child:hover {
    background: var(--secondary-red);
    color: white;
}

#editor-status {
    color: var(--accent-red);
}

#editor-status:empty {
    display: none;
}

#generate-btn:disabled, #save-btn:disabled {
    opacity: 0.55;
}

#my-games-list > div span .status-public {
    color: #4edf7a;
    font-weight: bold;
}

#my-games-list > div span .status-private {
    color: var(--secondary-red);
    font-weight: bold;
}

.username {
    font-weight: bold;
}

.error-box {
    background-color: rgba(164, 22, 26, 0.2);
    color: var(--secondary-red);
    border: 1px solid var(--primary-red);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

.comments-container {
    margin-top: 40px;
    margin-bottom: 50px;
    padding: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--primary-red);
    border-radius: 8px;
    color: var(--text-silver);
    box-shadow: var(--shadow);
}

.comments-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-white);
    border-bottom: 1px solid var(--dark-gray);
    padding-bottom: 10px;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.comment-form textarea, .comment-edit-input {
    width: 100%;
    height: 90px;
    padding: 12px;
    background-color: var(--bg-dark);
    border: 1px solid var(--dark-gray);
    color: var(--text-white);
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
}

.comment-form textarea:focus, .comment-edit-input:focus {
    outline: none;
    border-color: var(--accent-red);
}

.comment-form button {
    align-self: flex-start;
    padding: 10px 20px;
    background-color: var(--primary-red);
    color: var(--text-white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
}

.comment-form button:hover {
    background-color: var(--accent-red);
}

.comment-form button:active {
    transform: scale(0.98);
}

.error-box {
    background-color: rgba(164, 22, 26, 0.2);
    color: var(--secondary-red);
    border: 1px solid var(--primary-red);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 600;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comment-item {
    background-color: var(--bg-dark);
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-red);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.comment-header strong {
    color: var(--text-white);
    font-size: 1.05rem;
}

.comment-header .comment-date {
    font-size: 0.85rem;
    color: var(--light-gray);
}

.comment-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.comment-actions {
    display: flex;
    gap: 6px;
}

.comment-actions button {
    padding: 4px 10px;
    font-size: 0.8rem;
    margin: 0;
}

.comment-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.comment-content {
    line-height: 1.5;
    font-size: 0.95rem;
    color: var(--text-silver);
    white-space: pre-wrap;
    word-break: break-word;
}