@charset "UTF-8";
/* CSS for Triangle Agency Agent System */

:root {
    --primary-color: #d9d9d9;
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --accent-red: #B23132;
    --text-color: #eee;
    --border-color: #333;
    --content-width: 900px; /* Fixed width for alignment */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'NotoSansSC', 'ITCAvantGardePro', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent body scroll, use main scroll */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

@font-face {
    font-family: 'Alimama';
    src: url('../font/AlimamaShuHeiTi-Bold.woff') format('woff');
    font-weight: normal; /* Map to normal so it works as default Chinese font */
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'ITCAvantGardePro';
    src: url('../font/ITCAvantGardePro-Md.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'NotoSansSC';
    src: url('../font/NotoSansSC-min.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSerifCN';
    src: url('../font/SourceHanSerifCN-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Background Animation Container */
#animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto; /* Blocks clicks while visible */
}

#click-prompt {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    color: #B23132;
    font-family: 'Alimama', 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: auto; /* Enable clicks on text */
    text-shadow: 0 0 5px #B23132;
    z-index: 10000;
    white-space: nowrap; /* Prevent wrapping */
    width: 100%;
    text-align: center;
}

#click-prompt.visible {
    opacity: 1;
    animation: promptPulse 2s infinite;
}

@keyframes promptPulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #B23132; }
    50% { opacity: 0.5; text-shadow: 0 0 2px #500; }
}

/* Main Layout */
.character-sheet-container {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 1s ease-in;
    width: 100%;
    display: flex;
    justify-content: center;
}

header {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border-bottom: 2px solid var(--accent-red);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-triangle {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 26px solid var(--accent-red);
}

h1 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Alimama', sans-serif;
}

h2, h3, h4, h5, h6 {
    font-family: 'Alimama', sans-serif;
}

main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.agent-sheet {
    background: rgba(30, 30, 30, 0.95);
    width: 100%;
    max-width: 100%; /* Fully fluid */
    border: 1px solid var(--border-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 auto;
}

/* Name Plate / Top Section */
.cs-header {
    display: grid;
    grid-template-columns: 200px 1fr 300px; /* 3 Columns: Avatar, Info, ARC */
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    box-sizing: border-box;
}

/* Column Styles */
.cs-header-col {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-family: 'Alimama', sans-serif; /* Force Chinese font for headers if needed, or let inherit */
}

.col-avatar {
    align-items: center;
}

.col-basic {
    justify-content: space-between;
}

.col-arc {
    justify-content: space-between;
}

/* Avatar Frame - Standard Photo Size (e.g. 3:4) */
.cs-avatar-frame {
    width: 100%;
    aspect-ratio: 3/4;
    background: #333;
    border: 2px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
}

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.8rem;
    color: #eee; /* Brightened from #888 */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Alimama', sans-serif;
}

/* Inputs & Selects */
.cs-input-large {
    font-size: 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-red);
    color: #fff;
    width: 100%;
    padding: 5px;
}

.cs-input-medium {
    font-size: 1.2rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid #555;
    color: #eee;
    width: 100%;
    padding: 5px;
}

.cs-select-large {
    font-size: 1.1rem;
    background: #222;
    border: 1px solid #444;
    color: #eee;
    padding: 8px;
    width: 100%;
    cursor: pointer;
}

.cs-select-large:focus {
    border-color: var(--accent-red);
    outline: none;
}

/* Reputation Control */
.reputation-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reputation-control input[type="text"] {
    text-align: center;
    font-weight: bold;
    color: var(--accent-red);
}

/* Buttons */
.cs-btn-small {
    background: #444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.cs-btn-small:hover {
    background: #555;
}

.cs-btn-small.full-width {
    width: 100%;
}

.cs-btn-save {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    text-transform: uppercase;
    transition: background 0.2s;
    font-family: 'Alimama', sans-serif;
}

.cs-btn-save:hover {
    background: #d43f40;
}

.save-area {
    margin-top: auto;
}

/* Mobile Responsive for Header */
@media (max-width: 960px) {
    .cs-header {
        grid-template-columns: 1fr 1fr; /* 50% 50% split */
        grid-template-areas: 
            "avatar basic"
            "arc arc"; /* ARC takes full width below */
        gap: 10px;
        padding: 10px;
    }

    .col-avatar {
        grid-area: avatar;
        text-align: center;
    }

    .col-basic {
        grid-area: basic;
        gap: 5px; 
        justify-content: space-between; /* Distribute vertically to match avatar */
        height: 100%; /* Ensure it takes full height of the grid cell */
    }

    /* Compact inputs for mobile to match avatar height */
    .col-basic .cs-input-large {
        font-size: 1.3rem; /* Slightly larger */
        padding: 4px;
    }

    .col-basic .cs-input-medium {
        font-size: 1.05rem; /* Slightly larger */
        padding: 4px;
    }

    .col-basic .form-group {
        gap: 2px;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .col-basic label {
        font-size: 0.8rem; /* Slightly larger */
        margin-bottom: 0;
    }

    .reputation-control {
        gap: 5px;
    }

    .reputation-control .cs-btn-small {
        padding: 2px 6px;
        font-size: 0.7rem;
    }

    .col-arc {
        grid-area: arc;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr; /* Three columns for selects */
        gap: 10px;
        margin-top: 10px;
        border-top: 1px solid #333;
        padding-top: 15px;
    }
    
    /* Ensure selects fit on mobile */
    .col-arc .form-group {
        width: 100%;
    }

    .cs-avatar-frame {
        width: 100%; /* Fill the column */
        aspect-ratio: 3/4;
        margin: 0 auto 5px auto;
    }
    
    .save-area {
        grid-column: 1 / -1; /* Save button spans full width */
        margin-top: 10px;
    }
}

/* Extra Small Screens (Phone Portrait) */
@media (max-width: 480px) {
    .col-arc {
        grid-template-columns: 1fr; /* Stack selects on very small screens */
    }
}

/* Tabs */
.cs-tabs {
    display: flex;
    background: #252525;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50; /* Ensure tabs are above other elements */
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    box-sizing: border-box;
}

.cs-tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid #333;
    position: relative;
    z-index: 51;
    font-family: 'Alimama', sans-serif;
}

.cs-tab-btn:hover {
    background: #333;
    color: #fff;
}

.cs-tab-btn.active {
    background: #3e3e3e;
    color: var(--accent-red); /* Default fallback */
    font-weight: bold;
    font-size: 1.2rem;
    border-bottom: 2px solid currentColor; /* Use text color for border */
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 2px rgba(0,0,0,0.8); /* Subtle stroke effect */
}

/* Custom Active Colors by Data Attribute */
.cs-tab-btn[data-tab="character"].active,
.cs-tab-btn[data-tab="balance"].active {
    color: #F0DFD6 !important;
}

.cs-tab-btn[data-tab="anomaly"].active {
    color: #2141AD !important;
}

.cs-tab-btn[data-tab="reality"].active {
    color: #DBA736 !important;
}

.cs-tab-btn[data-tab="function"].active {
    color: #AA322E !important;
}

/* Content Area */
.cs-content {
    padding: 20px;
    flex: 1;
    display: flex;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    box-sizing: border-box;
}

.cs-layout-grid {
    display: grid;
    grid-template-columns: 300px 1fr; /* Left sidebar fixed width */
    gap: 20px;
    width: 100%;
    min-width: auto;
}

.cs-col-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cs-col-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Reality Trigger Section */
.cs-reality-container {
    background: #222;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 4px;
}

.cs-subsection-title {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #eee; /* Brightened from #888 */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Alimama', sans-serif;
}

.cs-reality-name {
    color: #DBA736;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 5px;
    font-family: 'SourceHanSerifCN', serif;
}

.cs-competency-name {
    color: #AA322E;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 5px;
    font-family: 'SourceHanSerifCN', serif;
}

.cs-reality-content {
    font-size: 0.9rem;
    color: #eee; /* Brightened from #ccc */
    line-height: 1.5;
    margin-bottom: 15px;
    min-height: 50px;
    font-family: 'NotoSansSC', sans-serif;
}

#prime-directive-content {
    min-height: auto;
    margin-bottom: 5px;
}

.cs-reality-track {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a1a;
    padding: 8px;
    border-radius: 4px;
}

.cs-reality-track label {
    font-size: 0.9rem;
    color: #fff; /* Brightened from #ddd */
    font-weight: bold;
    font-family: 'Alimama', sans-serif;
}

.cs-track-squares {
    display: flex;
    gap: 5px;
}

.cs-track-square {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid #555;
    background: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.cs-track-square:checked {
    background: #DBA736;
    border-color: #DBA736;
    box-shadow: 0 0 5px #DBA736;
}

/* Sections */
h3 {
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 15px;
    color: #fff; /* Brightened from #bbb */
    font-size: 1rem;
    font-family: 'Alimama', sans-serif;
}

.cs-form-row {
    display: flex;
    justify-content: flex-start; /* Align start to keep them close */
    gap: 15px; /* Fixed gap between label and input */
    align-items: center;
    margin-bottom: 10px;
}

.cs-form-row label {
    min-width: 80px; /* Ensure labels align nicely */
    text-align: right;
    font-size: 1.1rem; /* Larger font */
    font-weight: bold; /* Bolder text */
    letter-spacing: 1px;
    color: #fff; /* Brightened from #ddd */
    font-family: 'Alimama', sans-serif;
}

.cs-input-underline {
    background: transparent;
    border: none;
    border-bottom: 1px solid #555;
    color: #eee;
    text-align: left; /* Align text left */
    width: auto;
    flex: 1; 
}

.cs-input-small {
    background: #222;
    border: 1px solid #444;
    color: #eee;
    padding: 8px 12px; /* More padding */
    width: 140px; /* Even wider */
    text-align: center;
    border-radius: 8px; /* Rounded corners */
    font-size: 1.1rem; /* Larger numbers */
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.cs-input-small:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 8px rgba(178, 49, 50, 0.3);
    outline: none;
    background: #2a2a2a;
}

.cs-select-large {
    font-size: 1.1rem;
    background: #222;
    border: 1px solid #444;
    color: #eee;
    padding: 8px 12px; /* More padding */
    width: 100%;
    cursor: pointer;
    border-radius: 8px; /* Rounded corners */
    transition: all 0.3s ease;
}

.cs-select-large:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 8px rgba(178, 49, 50, 0.3);
    outline: none;
}

.cs-textarea {
    width: 100%;
    background: #222;
    border: 1px solid #444;
    color: #eee;
    resize: vertical;
}

/* ARC Triangle Stats */
.cs-arc-grid {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
}

.cs-arc-item {
    text-align: center;
}

.cs-triangle-input {
    position: relative;
    width: 60px;
    height: 52px; /* Triangle Aspect */
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-triangle-input input {
    width: 30px;
    text-align: center;
    background: transparent;
    border: none;
    color: #fff;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 2;
}

.cs-triangle-input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 52px solid rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.cs-arc-label {
    display: block;
    font-size: 0.8rem;
    margin-top: 5px;
    color: #ccc;
    font-family: 'Alimama', sans-serif;
}

/* Quality Assurances Grid */
.cs-qa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Wider items to fit 9 triangles */
    gap: 15px;
    width: 100%;
}

.cs-qa-item {
    background: #222;
    padding: 10px;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 4px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 10px; /* Add gap for when wrapping occurs */
}

.cs-tri-check-group-9 {
    display: flex;
    gap: 4px; /* Consistent gap */
    align-items: center;
    flex-wrap: wrap; /* Allow triangles to wrap if needed */
    justify-content: flex-end; /* Keep them right-aligned */
}

.cs-qa-item label {
    font-size: 1rem;
    font-weight: bold;
    color: #fff; /* Brightened from #ddd */
    margin-right: auto; /* Push label to left */
    white-space: nowrap;
    font-family: 'Alimama', sans-serif;
    flex-shrink: 0; /* Prevent label from shrinking */
}

.cs-tri-check {
    appearance: none;
    width: 0;
    height: 0;
    border-left: 8px solid transparent; /* Slightly wider base */
    border-right: 8px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
    outline: none;
}

/* Up Triangle */
.cs-tri-check.up {
    border-bottom: 14px solid #fff;
}

/* Down Triangle */
.cs-tri-check.down {
    border-top: 14px solid #fff;
}

/* Hover Effects */
.cs-tri-check:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

/* Checked States */
.cs-tri-check.up:checked {
    border-bottom-color: #2141AD;
    filter: drop-shadow(0 0 5px #2141AD);
}

.cs-tri-check.down:checked {
    border-top-color: #2141AD;
    filter: drop-shadow(0 0 5px #2141AD);
}

.cs-qa-count {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    margin-right: 15px; /* Spacing between number and triangles */
    min-width: 20px;
    text-align: center;
}

/* Specific Overrides */
.cs-section-basic .cs-select-large {
    width: 166px; /* 140px width + 24px padding + 2px border */
    box-sizing: border-box;
    text-align: center;
    text-align-last: center;
}

.qa-cn {
    color: #fff; /* Brightened from #ddd */
    margin-right: 5px;
}

/* Dynamic Lists */
.ability-item, .relationship-item, .benefit-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #252525;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #333;
    align-items: center;
}

.cs-btn-add {
    background: #333;
    color: #fff;
    border: 1px dashed #555;
    width: 100%;
    padding: 5px;
    cursor: pointer;
}

.cs-btn-small {
    background: #522;
    color: #fff;
    border: none;
    padding: 2px 5px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Sanctioned Behaviors Styles */
.cs-sanctioned-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cs-sanctioned-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

.cs-sanctioned-item:last-child {
    border-bottom: none;
}

.cs-sanctioned-label {
    flex: 1;
    font-size: 0.9rem;
    color: #eee;
    cursor: pointer;
    /* Ensure text doesn't select when clicking quickly */
    user-select: none; 
    font-family: 'NotoSansSC', sans-serif;
}

.cs-sanctioned-check {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid #555;
    background: #333;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
    position: relative;
}

.cs-sanctioned-check:checked {
    background: #AA322E; /* Competency Red */
    border-color: #AA322E;
    box-shadow: 0 0 5px #AA322E;
}

.cs-sanctioned-check:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
}

.cs-sanctioned-check:hover {
    border-color: #AA322E;
}

/* --- Track System Styles --- */

.track-section {
    margin-bottom: 40px;
}

.track-header-text {
    margin-bottom: 15px;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.track-lock-icon {
    width: 100px;
    height: auto;
    flex-shrink: 0;
    margin-top: 5px; /* Align with text top */
}

.track-header-content {
    flex: 1;
}

.track-warning {
    color: #FF0000;
    font-family: 'SourceHanSerifCN', serif;
    font-weight: bold;
    font-size: 1rem;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff; /* White stroke */
    margin: 0 0 5px 0;
}

.track-instruction {
    color: #888;
    font-family: 'SourceHanSerifCN', serif;
    font-size: 0.9rem;
    margin: 0;
}

.track-title {
    border-bottom: 2px solid #444;
    padding-bottom: 5px;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-family: 'Alimama', sans-serif;
}

/* The Box/Node */
.step-box-label {
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Hidden Input for State (0, 1, 2) */
.step-box-label input[type="hidden"] {
    display: none;
}

.step-box-visual {
    display: flex;
    align-items: center;

    justify-content: center;
    width: 100%;
    aspect-ratio: 1/1;
    background: #222;
    border: 1px solid #555;
    color: #ddd;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.2s;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
    position: relative;
}


/* Custom Alert Modal Styles */
#custom-alert-modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 20000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.95); /* Black w/ opacity */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}


.box-code {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px; /* Increased from 14px */
    color: #a88;
}

.quad {
    position: absolute;
    width: 48%;
    height: 48%;
    background: rgba(150, 170, 220, 0.25);
    border-radius: 3px;
}
.quad.tl { left: 4%; top: 4%; }
.quad.tr { right: 4%; top: 4%; }
.quad.bl { left: 4%; bottom: 4%; }
.quad.br { right: 4%; bottom: 4%; }

.mark-check {
    position: absolute;
    right: 3px;
    top: 3px;
    font-size: 14px;
}

.mark-cross {
    position: absolute;
    left: 3px;
    bottom: 3px;
    font-size: 14px;
}

/* State 1: Active (Color) */
.step-box-visual.active {
    color: #fff;
}

.competency-track .step-box-visual.active {
    background: #B23132;
    border-color: #ff5555;
    box-shadow: 0 0 5px rgba(178, 49, 50, 0.5);
}

.reality-track .step-box-visual.active {
    background: #E6A23C;
    border-color: #FFD700;
    box-shadow: 0 0 5px rgba(230, 162, 60, 0.5);
}

.anomaly-track .track-title {
    color: #254392;
    border-color: #254392;
}

.anomaly-track .step-box-visual.active {
    background: #254392;
    border-color: #254392;
    box-shadow: 0 0 5px rgba(37, 67, 146, 0.5);
    color: #254392; /* Text color for contrast */
}

.mark-cross.big-cross {
    font-size: 24px;
    font-weight: bold;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    right: auto;
    bottom: auto;
}

/* State 2: Gray (Inactive/Used) */
.step-box-visual.gray {
    background: #444 !important;
    border-color: #666 !important;
    color: #ccc !important;
    box-shadow: none !important;
}

/* Competency Rank Borders - High Contrast Alternating */
.step-box-visual.rank-border-0 { border-color: #444444; } /* Apprentice: Dark Grey */
.step-box-visual.rank-border-1 { border-color: #DDDDDD; } /* Assistant: Light Silver */
.step-box-visual.rank-border-2 { border-color: #666666; } /* Senior Assistant: Medium Grey */
.step-box-visual.rank-border-3 { border-color: #FFD700; } /* Assistant Manager: Bright Gold */
.step-box-visual.rank-border-4 { border-color: #8B4500; } /* Manager: Dark Rust/Brown */
.step-box-visual.rank-border-5 { border-color: #FF9800; } /* Regional Director: Bright Orange */
.step-box-visual.rank-border-6 { border-color: #800000; } /* VP: Dark Maroon */
.step-box-visual.rank-border-7 { border-color: #FF3D00; } /* Senior VP: Bright Red-Orange */
.step-box-visual.rank-border-8 { border-color: #4A148C; } /* Executive VP: Dark Purple/Indigo (Distinct from Red) */
.step-box-visual.rank-border-9 { border-color: #B23132; border-width: 3px; } /* Chairman: Brand Red (Thick) */

/* Track Grid Layout */
.track-grid {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 20px;
    width: 100%;
    direction: ltr; /* Left to Right */
    width: 100%; /* Allow grid to fill container */
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Mobile Responsive */
@media (max-width: 960px) {
    :root {
        --content-width: 100%;
    }

    .cs-tabs,
    .cs-content,
    .cs-panel,
    .cs-panel.active {
        max-width: 100% !important;
    }

    #click-prompt {
        font-size: 1.2rem;
        white-space: nowrap;
    }

    .cs-layout-grid {
        grid-template-columns: 1fr;
        min-width: auto; /* Allow shrinking on mobile */
    }

    .track-row, .track-row.bottom {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        flex-direction: row;
        align-items: start;
    }
    
    .track-grid {
        grid-template-columns: repeat(5, 1fr);
        direction: ltr; /* Mobile: Left to Right */
        width: 100%;
        max-width: 350px;
        gap: 8px;
    }
    
    .track-desc-row {
        flex-direction: column;
    }

    .cs-panel {
        /* Width handled by base style */
        margin: 0;
    }
    
    .cs-header, .cs-tabs, .cs-content {
        /* Width handled by base style */
        padding-left: 10px;
        padding-right: 10px;
        margin: 0;
    }

    .agent-sheet {
        height: 100vh; /* Full viewport height on mobile */
        width: 100% !important;
        max-width: 100% !important;
        border: none;
        margin: 0;
    }

    /* Hide English Quality Assurances on Mobile */
    .qa-en {
        display: none;
    }

    /* Reorder Mobile Sections: Quality (1) -> Reality (2) -> Competency (3) */
    .cs-col-right {
        display: flex;
        flex-direction: column;
    }
    
    .cs-section-qa {
        order: 1;
    }

    /* cs-col-left contains Reality and ECS, which are separate blocks.
       We need to target the containers within cs-col-left and cs-col-right to interleave them if they were siblings,
       but here they are in different columns. 
       Wait, on mobile .cs-layout-grid is single column.
       The structure is:
       .cs-layout-grid
         .cs-col-left
           .cs-section-currencies (ECS)
           .cs-section-basic (Career)
           .cs-section-triggers (Reality)
         .cs-col-right
           .cs-section-qa (Quality)
           .cs-section-directives (Competency)
       
       To reorder them completely (Quality -> Reality -> Competency), we need to flatten the grid or use display contents.
       Or we can just move .cs-col-right visually above .cs-col-left if we want Quality first?
       User asked for: "Reality should be below Quality, and above Competency."
       So: Quality -> Reality -> Competency.
       Currently:
       Left Col: ECS, Basic, Reality
       Right Col: Quality, Competency
       
       If we just stack columns, it's Left then Right. So ECS -> Basic -> Reality -> Quality -> Competency.
       
       To achieve Quality -> Reality -> Competency, we need to interleave.
       Let's use display: contents on the columns to flatten them into the grid container.
    */
    .cs-col-left, .cs-col-right {
        display: contents;
    }

    /* Now direct children of cs-layout-grid are:
       ECS, Basic, Reality (from left)
       Quality, Competency (from right)
       
       Let's assign orders.
    */
    .cs-section-currencies { order: 10; } /* ECS - keep at top or bottom? Usually top. Let's say 1 */
    .cs-section-basic { order: 11; } /* Career */
    
    .cs-section-qa { order: 20; } /* Quality - User wants this first among the big three? */
    .cs-section-triggers { order: 21; } /* Reality - User: "Reality should be under Quality" */
    .cs-section-directives { order: 22; } /* Competency - User: "Reality above Competency" */
    
    /* Adjusting orders to match logical flow or user request specifically */
    /* Let's assume User wants:
       1. Top stuff (ECS, Career) - untouched
       2. Quality
       3. Reality
       4. Competency
    */
    .cs-section-currencies { order: 1; }
    .cs-section-basic { order: 2; }
    .cs-section-qa { order: 3; }
    .cs-section-triggers { order: 4; }
    .cs-section-directives { order: 5; }

    /* Mobile Reputation Text Fix */
    .reputation-control input[type="text"] {
        font-size: 0.9rem;
        width: 100%;
        min-width: 0;
    }
    
    .reputation-control {
        gap: 5px;
    }

    /* Reality panel: wrap header fields to avoid overflow on phones */
    #panel-reality .relationship-item .anomaly-header {
        flex-wrap: wrap;
    }
    #panel-reality .relationship-item .anomaly-header .ah-col-ability,
    #panel-reality .relationship-item .anomaly-header .ah-col-quality {
        flex: 1 1 100% !important;
        min-width: 0;
    }
    #panel-reality .relationship-item .anomaly-body {
        padding: 10px !important;
    }

    /* Reality Panel Relationship Track Overflow */
    #panel-reality .rel-track-container {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    #panel-reality .rel-track-inner {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: flex-start !important;
    }

    #panel-reality .track-circle {
        margin: 4px !important;
    }
    
    /* Fix "Join Network" label position when wrapped */
    #panel-reality .rel-track-inner > div {
         margin-bottom: 15px !important;
    }

    /* Reality Panel Benefit Section Overflow */
    #panel-reality .rel-benefit-container {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #panel-reality .rel-benefit-container > div:first-child {
        margin-right: 0 !important;
        width: 100% !important;
    }

    #panel-reality .rel-benefit-container > div:last-child {
        width: 100% !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center !important;
        margin-left: 0 !important;
        border-top: 1px solid #444;
        padding-top: 10px;
    }
    
    #panel-reality .rel-benefit-container > div:last-child .box-square-large {
        margin-right: 10px;
        margin-bottom: 0 !important;
    }

    /* Function (Procurement) cards: ensure left alignment and full-width fields */
    #panel-function .anomaly-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 10px !important;
        height: auto !important;
    }
    
    #panel-function .anomaly-header .ph-cost,
    #panel-function .anomaly-header .ph-name,
    #panel-function .anomaly-header .ph-select,
    #panel-function .anomaly-header .ph-actions {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    #panel-function .anomaly-header label {
        text-align: left !important;
        display: block !important;
        width: 100% !important;
        margin-bottom: 4px !important;
    }

    #panel-function .cs-input-underline,
    #panel-function .cs-select-underline {
        width: 100% !important;
        text-align: left !important;
        box-sizing: border-box !important;
    }

    /* Ensure name and cost inputs have visible height and color */
    #panel-function .anomaly-header .ph-name input.cs-input-underline,
    #panel-function .anomaly-header .ph-name div.cs-input-underline,
    #panel-function .anomaly-header .ph-cost input.cs-input-underline {
        display: block !important;
        line-height: 1.6;
        padding: 6px 0;
        min-height: 30px !important;
        color: #eee !important;
        white-space: normal !important; /* Allow wrapping */
        overflow: visible !important;
    }

    /* Override grid layout for catalog on mobile to prevent overflow */
    #procurement-catalog {
        display: grid !important;
        grid-template-columns: 100% !important;
        gap: 20px !important;
    }

    /* Fix Body and Textarea Overflow */
    #panel-function .anomaly-card,
    #panel-function .anomaly-body,
    #panel-function .ab-section {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #panel-function .cs-textarea-lines {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}

/* Tablet/Small Desktop Adjustment (Between Mobile and Full Desktop) */
@media (min-width: 601px) and (max-width: 960px) {
    /* Make ECS and Career sections display side-by-side */
    .cs-col-left {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .cs-section-currencies {
        grid-column: 1;
        order: 1 !important;
    }

    .cs-section-basic {
        grid-column: 2;
        order: 2 !important;
    }

    /* Reality takes full width below them */
    .cs-section-triggers {
        grid-column: 1 / -1;
        order: 4 !important; /* After Quality */
    }
    
    /* Better Grid Layout for Tablets: 10 or 15 columns */
    #panel-balance .track-grid {
        grid-template-columns: repeat(10, 1fr) !important; /* 3 rows of 10 instead of 6 rows of 5 */
        max-width: 700px !important; /* Allow it to be wider */
    }
}

/* --- Panel Logic --- */
.cs-panel {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    height: 100%;
    overflow-y: auto;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
}

.cs-panel.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    height: auto;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px;
    box-sizing: border-box;
}

/* Descriptions */
.track-desc-row {
    display: flex;
    gap: 30px;
    border-top: 1px solid #333;
    padding-top: 20px;
}

.track-desc-item {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: #eee;
    padding-left: 15px;
    border-left: 3px solid #444;
    font-family: 'NotoSansSC', sans-serif;
}

.track-desc-item p {
    margin: 0 0 10px 0;
}
.track-group-labels {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 10px;
    color: #eee;
    font-size: 12px;
    margin: 6px 0;
    font-family: 'Alimama', sans-serif;
}
.track-group-labels .group-label {
    text-align: center;
}
.span-3 { grid-column: span 3; }

.track-arrow { position: relative; height: 14px; color: #ccc; margin: 2px 0; width: 100%; text-align: center; }

/* Anomaly Card Layout */
.anomaly-card {
    background: #222;
    border: 1px solid #333;
    border-radius: 6px;
    margin-bottom: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Header */
.anomaly-header {
    background: #409EFF; /* Anomaly Blue */
    padding: 8px 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    border-bottom: 1px solid #333;
    color: #fff; /* White text on Blue background */
}

.anomaly-header label {
    font-weight: bold;
    margin-right: 5px;
    font-family: 'Alimama', sans-serif;
    color: #fff;
    white-space: nowrap;
}

.anomaly-header input.cs-input-underline {
    border-bottom-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.anomaly-header input.cs-input-underline:focus {
    border-bottom-color: #fff;
}

/* Reality Page Placeholders */
.relationship-item .anomaly-header input::placeholder {
    color: #fff !important;
    opacity: 0.8;
}

/* Header Columns */
.ah-col-ability { 
    flex: 2; 
    display: flex; 
    align-items: center; 
}

.ah-col-ability input {
    font-family: 'Alimama', sans-serif; /* Use Alimama font for ability name */
}

.ah-col-trigger { 
    flex: 5; /* Increased flex ratio */
    display: flex; 
    align-items: center; 
    border-left: 1px solid rgba(255,255,255,0.3); 
    padding-left: 15px; 
}

.ah-col-quality { 
    flex: 1; /* Kept small */
    display: flex; 
    align-items: center; 
    border-left: 1px solid rgba(255,255,255,0.3); 
    padding-left: 15px; 
    max-width: 120px; /* Limit width specifically */
}

.relationship-item .anomaly-header .ah-col-quality {
    max-width: none;
}

/* Body */
.anomaly-body {
    display: flex;
    padding: 10px;
    gap: 15px;
    background: #2a2a2a; /* Slightly lighter than #222 for card body contrast */
}

.ab-col-left { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.ab-col-right { flex: 1; display: flex; flex-direction: column; gap: 10px; }

/* Sections */
.ab-section {
    background: rgba(64, 158, 255, 0.05); /* Very faint blue tint */
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #333;
}

.ab-section.failure {
    background: rgba(255, 0, 0, 0.05); /* Very faint red tint */
}

.ab-icon-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.ab-label {
    font-weight: bold;
    color: #409EFF;
    white-space: nowrap;
    font-family: 'Alimama', sans-serif;
}

.ab-label.error-text {
    color: #F56C6C; /* Red */
}

.cs-input-underline.full-width {
    width: 100%;
}

.cs-input-underline.error-border {
    border-bottom-color: #F56C6C;
}

.cs-textarea-lines {
    background: transparent;
    border: none;
    border-bottom: 1px solid #444;
    width: 100%;
    color: #ddd;
    resize: vertical;
    font-family: 'NotoSansSC', sans-serif;
    line-height: 1.6;
    /* Simulate lines */
    background-image: linear-gradient(transparent 95%, #444 95%);
    background-size: 100% 1.6em;
    padding-top: 0.2em;
}

.cs-textarea-lines.error-lines {
    background-image: linear-gradient(transparent 95%, #663333 95%);
}

/* Icons */
.icon-triangle-up {
    width: 0; 
    height: 0; 
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid #409EFF;
}

.icon-triangle-star {
    color: #409EFF;
    font-size: 1.2rem;
    font-weight: bold;
}

.icon-cross-hex {
    color: #F56C6C;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Question Box */
.ab-question-box {
    background: #333;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #444;
}

.q-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.q-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto; /* Push to right */
    font-size: 0.8rem;
    color: #bbb;
}

.q-trained-label, .q-page-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.a-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.track-boxes {
    display: flex;
    gap: 5px;
    align-items: center;
}

.box-square {
    width: 16px;
    height: 16px;
    border: 1px solid #666;
    background: #222;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.box-square.checked::after {
    content: '✓';
    color: #409EFF;
    font-size: 14px;
    font-weight: bold;
}

.cs-input-tiny {
    width: 30px;
    text-align: center;
    background: transparent;
    border: none;
    border-bottom: 1px solid #666;
    color: #fff;
}

/* Mobile Response for Anomaly Card */
@media (max-width: 768px) {
    .anomaly-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .ah-col-ability, .ah-col-trigger, .ah-col-quality {
        width: 100%;
        border-left: none;
        padding-left: 0;
    }
    
    .anomaly-body {
        flex-direction: column;
    }
}
