:root {
    --imperial-gold: #d4af37;
    --scholar-blue: #1e3799;
    --jade-green: #00a8a8;
    --vermillion-red: #c0392b;
    --ink-black: #2c3e50;
    --rice-paper: #faf6f1;
    --silk-white: #ffffff;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.2);

    --font-family: "Noto Serif SC", serif;
    --font-mono: "JetBrains Mono", monospace;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #f5d7b1 0%, #d4a574 50%, #8b6b47 100%);
    color: var(--ink-black);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 96vw;
    height: 92vh;
    max-width: 1800px;
    background: linear-gradient(135deg, rgba(250, 246, 241, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 3px solid rgba(212, 175, 55, 0.3);
}

/* Header */
.main-header {
    padding: 1.2rem 2rem;
    background: linear-gradient(135deg, var(--imperial-gold) 0%, #b8941e 100%);
    border-bottom: 3px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-content h1 {
    font-size: 1.8rem;
    color: var(--silk-white);
    margin-bottom: 4px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.traditional {
    font-family: var(--font-title);
    font-size: 2.2rem;
    letter-spacing: 2px;
}

.highlight {
    font-weight: 400;
}

.subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.header-controls {
    position: absolute;
    top: 1.2rem;
    right: 2rem;
    display: flex;
    gap: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Main Stage */
.main-stage {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    overflow: hidden;
}

.hierarchy-container {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(250, 246, 241, 0.5) 0%, rgba(255, 255, 255, 0.3) 100%);
}

.hierarchy-title {
    text-align: center;
    margin-bottom: 40px;
}

.hierarchy-title h2 {
    font-size: 1.8rem;
    color: var(--scholar-blue);
    margin-bottom: 8px;
    font-family: var(--font-title);
}

.hierarchy-title p {
    color: #777;
    font-size: 0.9rem;
}

/* Hasse Diagram */
.hasse-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.rank-level {
    display: flex;
    justify-content: center;
    z-index: 2;
}

.rank-card {
    width: 260px;
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 3px solid;
}

.rank-card::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.5));
    border-radius: 16px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.rank-card:hover::before {
    opacity: 1;
}

.rank-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.rank-card.selected {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.rank-card.prime {
    border-color: var(--vermillion-red);
    background: linear-gradient(135deg, #fff5f5 0%, white 100%);
}

.rank-card.minister {
    border-color: var(--scholar-blue);
    background: linear-gradient(135deg, #f0f5ff 0%, white 100%);
}

.rank-card.prefect {
    border-color: var(--jade-green);
    background: linear-gradient(135deg, #f0fff4 0%, white 100%);
}

.rank-card.magistrate {
    border-color: var(--imperial-gold);
    background: linear-gradient(135deg, #fffbf0 0%, white 100%);
}

.rank-seal {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--imperial-gold), #b8941e);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
    box-shadow: var(--shadow-sm);
    font-family: var(--font-title);
}

.rank-card h3 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-family: var(--font-title);
    letter-spacing: 2px;
}

.rank-desc {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
}

.rank-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    font-size: 0.8rem;
    color: #555;
    font-family: var(--font-mono);
}

/* Connection Lines */
.connection-line {
    width: 3px;
    height: 50px;
    background: linear-gradient(180deg, var(--imperial-gold), rgba(212, 175, 55, 0.3));
    margin: -3px 0;
    z-index: 1;
}

.relation-formula {
    margin-top: 40px;
    text-align: center;
}

.formula-box {
    display: inline-block;
    padding: 16px 32px;
    background: white;
    border: 2px solid var(--imperial-gold);
    border-radius: 12px;
    font-size: 1.2rem;
    font-family: var(--font-mono);
    box-shadow: var(--shadow-sm);
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 3px solid rgba(212, 175, 55, 0.3);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.panel-section {
    background: white;
    padding: 20px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--imperial-gold);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.panel-icon {
    font-size: 1.4rem;
}

.panel-header h3 {
    font-size: 1.1rem;
    color: var(--ink-black);
}

.detail-panel {
    border-top-color: var(--scholar-blue);
}

.detail-content {
    font-size: 0.9rem;
    line-height: 1.7;
}

.placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.property-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.property-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}

.property-icon {
    width: 28px;
    height: 28px;
    background: var(--jade-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.property-info strong {
    display: block;
    color: var(--scholar-blue);
    margin-bottom: 4px;
}

.property-info p {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.6;
}

.insight-section {
    border-top-color: var(--vermillion-red);
}

.insight-content {
    font-size: 0.9rem;
    line-height: 1.8;
}

.insight-content h4 {
    color: var(--vermillion-red);
    margin: 12px 0 8px 0;
    font-size: 1rem;
}

.insight-content h4:first-child {
    margin-top: 0;
}

.insight-content p {
    color: #555;
    margin-bottom: 12px;
}