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

:root {
    --rustic-brown: #8b6f47;
    --rustic-dark: #3d2817;
    --rustic-darker: #2a1a0e;
    --rustic-gold: #d4af37;
    --rustic-green: #5a7c3f;
    --rustic-stone: #9d8b6f;
    --rustic-wood: #6b4e3d;
    --rustic-leather: #7a5f3f;
    --rustic-text: #e8dcc0;
    --rustic-shadow: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--rustic-darker);
    min-height: 100vh;
    color: var(--rustic-text);
    position: relative;
    background-image: 
        url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="wood" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><rect width="100" height="100" fill="%232a1a0e"/><path d="M0,50 Q25,40 50,50 T100,50" stroke="%233d2817" stroke-width="2" fill="none" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23wood)"/></svg>');
    background-size: 200px 200px;
}

body.editor-page {
    overflow: hidden;
}

body.game-page {
    overflow: hidden;
    background: var(--rustic-darker) !important;
    background-image: none !important;
}

body.game-page .game-fullscreen {
    background: var(--rustic-darker);
}

.navbar {
    background: linear-gradient(180deg, var(--rustic-dark) 0%, var(--rustic-darker) 100%);
    padding: 1rem 2rem;
    box-shadow: 0 4px 20px var(--rustic-shadow);
    border-bottom: 3px solid var(--rustic-brown);
    position: relative;
    z-index: 1000;
}

.navbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(139, 111, 71, 0.1) 2px, rgba(139, 111, 71, 0.1) 4px);
    pointer-events: none;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    color: var(--rustic-gold);
    font-size: 2rem;
    font-weight: bold;
    text-decoration: none;
    text-shadow: 2px 2px 4px var(--rustic-shadow);
    letter-spacing: 3px;
    font-family: 'Georgia', serif;
    font-style: italic;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-menu a {
    color: var(--rustic-text);
    text-decoration: none;
    transition: all 0.3s;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: 1px solid transparent;
    font-weight: 500;
}

.nav-menu a:hover {
    color: var(--rustic-gold);
    background: rgba(139, 111, 71, 0.2);
    border-color: var(--rustic-brown);
    text-shadow: 1px 1px 2px var(--rustic-shadow);
}

.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

.flash-messages {
    margin-bottom: 1rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 2px solid;
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.flash-success {
    background: rgba(90, 124, 63, 0.3);
    color: #a8c97f;
    border-color: var(--rustic-green);
}

.flash-error {
    background: rgba(139, 69, 19, 0.3);
    color: #d4a574;
    border-color: #8b4513;
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
    position: relative;
}

.auth-box {
    background: linear-gradient(135deg, var(--rustic-dark) 0%, var(--rustic-darker) 100%);
    padding: 2.5rem;
    border-radius: 10px;
    box-shadow: 
        0 8px 30px var(--rustic-shadow),
        inset 0 0 30px rgba(139, 111, 71, 0.1);
    width: 100%;
    max-width: 400px;
    border: 3px solid var(--rustic-brown);
    position: relative;
    overflow: hidden;
}

.auth-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(139, 111, 71, 0.05) 10px, rgba(139, 111, 71, 0.05) 20px);
    pointer-events: none;
}

.auth-box > * {
    position: relative;
    z-index: 1;
}

.auth-box h1 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--rustic-gold);
    text-shadow: 2px 2px 4px var(--rustic-shadow);
    font-size: 2rem;
    font-family: 'Georgia', serif;
    font-style: italic;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--rustic-text);
    text-shadow: 1px 1px 2px var(--rustic-shadow);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--rustic-brown);
    border-radius: 5px;
    font-size: 1rem;
    background: rgba(42, 26, 14, 0.7);
    color: var(--rustic-text);
    transition: all 0.3s;
    font-family: 'Georgia', serif;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--rustic-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    background: rgba(42, 26, 14, 0.9);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
    font-weight: bold;
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 2px var(--rustic-shadow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--rustic-brown), var(--rustic-wood));
    color: var(--rustic-text);
    border-color: var(--rustic-gold);
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--rustic-wood), var(--rustic-brown));
    box-shadow: 0 6px 15px var(--rustic-shadow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(107, 78, 61, 0.5);
    color: var(--rustic-text);
    border-color: var(--rustic-brown);
}

.btn-secondary:hover {
    background: rgba(107, 78, 61, 0.7);
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.btn-success {
    background: linear-gradient(135deg, var(--rustic-green), #6b8e4f);
    color: var(--rustic-text);
    border-color: var(--rustic-green);
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
}

.auth-link a {
    color: var(--rustic-gold);
    text-decoration: none;
    text-shadow: 1px 1px 2px var(--rustic-shadow);
    transition: all 0.3s;
}

.auth-link a:hover {
    color: var(--rustic-text);
    text-decoration: underline;
}

/* Dashboard */
.dashboard-container {
    background: linear-gradient(135deg, var(--rustic-dark) 0%, var(--rustic-darker) 100%);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 30px var(--rustic-shadow);
    border: 3px solid var(--rustic-brown);
}

.dashboard-section {
    margin-bottom: 2rem;
}

.dashboard-section h2 {
    margin-bottom: 1rem;
    color: var(--rustic-gold);
    text-shadow: 2px 2px 4px var(--rustic-shadow);
    font-size: 1.8rem;
    font-family: 'Georgia', serif;
    font-style: italic;
    border-bottom: 2px solid var(--rustic-brown);
    padding-bottom: 0.5rem;
}

.character-list,
.world-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.character-card,
.world-card {
    background: rgba(42, 26, 14, 0.7);
    padding: 1.5rem;
    border-radius: 8px;
    border: 2px solid var(--rustic-brown);
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.character-card:hover,
.world-card:hover {
    border-color: var(--rustic-gold);
    box-shadow: 0 6px 15px var(--rustic-shadow);
    transform: translateY(-3px);
    background: rgba(42, 26, 14, 0.9);
}

.character-card h3,
.world-card h3 {
    margin-bottom: 0.5rem;
    color: var(--rustic-gold);
    text-shadow: 1px 1px 2px var(--rustic-shadow);
    font-family: 'Georgia', serif;
}

/* Character Creation */
.character-creation-container {
    background: linear-gradient(135deg, var(--rustic-dark) 0%, var(--rustic-darker) 100%);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 30px var(--rustic-shadow);
    border: 3px solid var(--rustic-brown);
    max-width: 600px;
    margin: 0 auto;
}

.gender-selection {
    display: flex;
    gap: 1rem;
}

.gender-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem;
    border: 2px solid var(--rustic-brown);
    border-radius: 8px;
    transition: all 0.3s;
    flex: 1;
    background: rgba(42, 26, 14, 0.5);
}

.gender-option:hover {
    border-color: var(--rustic-gold);
    box-shadow: 0 4px 10px var(--rustic-shadow);
    background: rgba(42, 26, 14, 0.7);
}

.gender-option input[type="radio"]:checked + span {
    color: var(--rustic-gold);
    font-weight: bold;
    text-shadow: 1px 1px 2px var(--rustic-shadow);
}

.character-preview {
    margin: 1.5rem 0;
    text-align: center;
}

.char-preview-box {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    background: rgba(42, 26, 14, 0.7);
    border: 3px solid var(--rustic-brown);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--rustic-shadow);
    position: relative;
}

.char-sprite {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 15px var(--rustic-shadow);
    border: 3px solid var(--rustic-gold);
}

.char-male {
    background: linear-gradient(135deg, var(--rustic-brown), var(--rustic-wood));
}

.char-female {
    background: linear-gradient(135deg, #a67c52, var(--rustic-brown));
}

/* Admin */
.admin-container {
    background: linear-gradient(135deg, var(--rustic-dark) 0%, var(--rustic-darker) 100%);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 30px var(--rustic-shadow);
    border: 3px solid var(--rustic-brown);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(42, 26, 14, 0.7);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid var(--rustic-brown);
    transition: all 0.3s;
    box-shadow: 0 4px 10px var(--rustic-shadow);
}

.stat-card:hover {
    border-color: var(--rustic-gold);
    box-shadow: 0 6px 15px var(--rustic-shadow);
    transform: translateY(-3px);
    background: rgba(42, 26, 14, 0.9);
}

.stat-card h3 {
    margin-bottom: 0.5rem;
    color: var(--rustic-text);
    text-shadow: 1px 1px 2px var(--rustic-shadow);
    font-family: 'Georgia', serif;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--rustic-gold);
    text-shadow: 2px 2px 4px var(--rustic-shadow);
    margin: 1rem 0;
    font-family: 'Georgia', serif;
}

.admin-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Admin Tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: rgba(42, 26, 14, 0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--rustic-brown);
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--rustic-brown);
    color: var(--rustic-text);
}

.admin-table th {
    background: rgba(61, 40, 23, 0.7);
    font-weight: 600;
    color: var(--rustic-gold);
    text-shadow: 1px 1px 2px var(--rustic-shadow);
    font-family: 'Georgia', serif;
}

.admin-table tr:hover {
    background: rgba(139, 111, 71, 0.2);
}

.admin-table td {
    color: var(--rustic-text);
    font-family: 'Georgia', serif;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--rustic-darker);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--rustic-brown), var(--rustic-wood));
    border-radius: 6px;
    border: 2px solid var(--rustic-darker);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--rustic-wood), var(--rustic-brown));
}
