:root {
    --bg-color: #001F3F;
    /* Secondary Brand Color */
    --ui-bg-color: #222222;
    /* Dark Neutral */
    --primary-color: #FF7A00;
    /* Primary Brand Color */
    --text-color: #E6E6E6;
    /* Light Neutral */
    --font-family: 'Raleway', sans-serif;
    --border-radius: 20px;
}

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

/*fonts*/
@font-face {
    font-family: Raleway;
    src: local("Raleway"),
        url("/fonts/Raleway-VariableFont_wght.woff2"),
        url("/fonts/Raleway-VariableFont_wght.ttf");
    font-display: swap;
    font-weight: 100 900;
}

@font-face {
    font-family: Raleway;
    src: local("Raleway"),
        url("/fonts/Raleway-Italic-VariableFont_wght.woff2"),
        url("/fonts/Raleway-Italic-VariableFont_wght.ttf");
    font-style: italic;
    font-display: swap;
    font-weight: 100 900;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

a {
    color: var(--primary-color);
}

p~p {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Changed from center to allow scrolling from top */
    align-items: center;
    /*background: rgba(0, 31, 63, 0.9);*/
    background: radial-gradient(ellipse 100% 80% at 130% 50%, var(--primary-color), transparent),
        radial-gradient(circle at 20% 20%, var(--bg-color), transparent),
        linear-gradient(to bottom, var(--bg-color), var(--ui-bg-color));
    /* #001F3F with opacity */
    backdrop-filter: blur(5px);
    pointer-events: auto;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    /* Enable vertical scrolling */
    padding: 2rem 0;
    /* Add padding for scroll content */
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

.metric-name {
    text-align: left;
    color: var(--text-color);
    font-size: 1.1rem;
    padding-right: 2rem;
}

.metric-value {
    text-align: right;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.metric-value.best-score {
    color: #95B05E;
    /* Green for best */
    text-shadow: 0 0 10px rgba(149, 176, 94, 0.5);
}

.game-tip {
    margin-top: 1rem;
    max-width: 50ch;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.4;
    border: 2px solid var(--primary-color);
}

.mode-btn.campaign {
    border-color: var(--primary-color);
    color: var(--primary-color);
    margin-top: 0.5rem;
}

.mode-btn.campaign:hover {
    background: var(--primary-color);
    color: var(--ui-bg-color);
    box-shadow: 0 0 15px rgba(149, 176, 94, 0.3);
}

.chart-container {
    width: 100%;
    height: 200px;
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    /* Changed from space-around */
    gap: 2.5rem;
    /* Added gap for tighter spacing */
    align-items: flex-end;
    padding-bottom: 2rem;
    /* For labels */
    border-bottom: 1px solid rgba(230, 230, 230, 0.1);
    position: relative;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40px;
    height: 100%;
    justify-content: flex-end;
    position: relative;
}

.chart-bar {
    width: 100%;
    transition: height 0.5s ease;
}

.chart-bar.target {
    background-color: #95B05E;
}

.chart-bar.off-target {
    background-color: #FF5733;
}

.chart-label {
    text-align: center;
    color: var(--text-color);
    font-size: 0.8rem;
}

.tutorial-content {
    display: flex;
    gap: 3rem;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.tutorial-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 300px;
    text-align: center;
}

.tutorial-step h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.tutorial-step p {
    font-size: 1.1rem;
    line-height: 1.4;
    color: var(--text-color);
}

.tutorial-diagram {
    width: 200px;
    height: 150px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Controls Diagram */
.icon-mouse {
    width: 30px;
    height: 50px;
    border: 2px solid var(--text-color);
    border-radius: 15px;
    position: absolute;
    left: 40px;
    top: 50px;
}

.icon-mouse::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: var(--primary-color);
}

.icon-hand {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--text-color);
    position: absolute;
    left: 50px;
    top: 60px;
    opacity: 0.5;
    /* Ghost hand */
}

.diagram-arrow {
    position: absolute;
    left: 80px;
    top: 70px;
    width: 40px;
    height: 2px;
    background: var(--primary-color);
}

.diagram-arrow::after {
    content: '';
    position: absolute;
    right: 0;
    top: -4px;
    border-left: 8px solid var(--primary-color);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.demo-particle {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 5px white;
}

.p1 {
    right: 40px;
    top: 60px;
}

.p2 {
    right: 30px;
    top: 75px;
}

.p3 {
    right: 50px;
    top: 70px;
}

/* Objective Diagram */
.demo-cell {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 10px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 3px black;
}

.demo-cell.target {
    background: radial-gradient(circle at 30% 30%, #4CAF50, #2E7D32);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
}

.demo-cell.off-target {
    background: radial-gradient(circle at 30% 30%, #F44336, #C62828);
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.6);
}

.demo-cell.monocyte {
    background: radial-gradient(circle at 30% 30%, #2196F3, #0D47A1);
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.6);
}

.title {
    font-size: 4rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 3rem;
}

.btn {
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: var(--font-family);
    margin: 0.5rem;
}

.btn.primary {
    background: var(--primary-color);
    color: var(--ui-bg-color);
    /* Dark text on Orange button */
    box-shadow: 0 0 20px rgba(255, 122, 0, 0.4);
}

.btn.primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 122, 0, 0.6);
}

.btn.primary:active {
    transform: scale(0.95);
}

.btn.secondary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    margin-top: 1rem;
    font-size: 1rem;
    padding: 0.75rem 2rem;
}

.btn.secondary:hover {
    background: rgba(255, 122, 0, 0.1);
}

.settings-container {
    background: var(--ui-bg-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(230, 230, 230, 0.1);
    width: 80%;
    max-width: 500px;
    margin-bottom: 2rem;
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--text-color);
}

.setting-item input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--primary-color);
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

table.score-table {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.score-board {
    display: flex;
    gap: 2rem;
    background: rgba(34, 34, 34, 0.8);
    /* #222222 */
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(230, 230, 230, 0.1);
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #94a3b8;
    /* Keep slightly muted for labels? Or use text-color */
    color: rgba(230, 230, 230, 0.7);
    margin-bottom: 0.25rem;
}

.score-item .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.score-item.target .value {
    color: #95B05E;
}

/* Brand Green */
.score-item.off-target .value {
    color: #FF5733;
}

/* Brand Red/Orange */
.score-item.particles .value {
    color: var(--primary-color);
}

.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
    align-items: center;
}

.mode-btn {
    width: 80%;
    max-width: 400px;
    padding: 1rem;
    font-size: 1.1rem;
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    transition: all 0.2s ease;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 700;
}

.mode-btn:hover {
    background: var(--primary-color);
    color: var(--ui-bg-color);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(255, 122, 0, 0.3);
}

#level-image {
    max-width: 300px;
    max-height: 300px;
    height: auto;
}

#level-image-container {
    width: 300px;
    height: 300px;
    background: rgba(240, 240, 240, 0.1);
    border-radius: 10px;
    border: 2px solid var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

em {
    font-family: serif;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"%3E%3Cpath d="M 5 90 Q 75 75 95 90" stroke="%23ff7b00" stroke-width="10px" fill="none" /%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}