:root {
    --bg-color: #fcefe9;
    --blood-color: #e74c3c;
    --organ-bg: #fff;
    --text-color: #2c3e50;
    --insulin-color: #3498db;
    --glucagon-color: #e67e22;
    --fat-color: #f1c40f;
    --sugar-color: #ffffff;
}

body {
    /* Prioritize Emoji fonts for icons, then TC fonts, then System UI */
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Microsoft JhengHei", "Heiti TC", sans-serif;
    background-color: #fce4ec; /* Light Pink */
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Prevent scroll */
}

.container {
    display: flex;
    flex-direction: row; /* Horizontal layout */
    width: 95vw;
    height: 90vh;
    max-width: 1400px; /* Wider for side-by-side */
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-radius: 20px;
    overflow: hidden;
}

.main-content {
    flex: 1; /* Grow to fill remaining width */
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
    flex-shrink: 0; /* No shrink */
}

.simulation-area {
    flex: 1; /* Takes remaining height */
    position: relative;
    background-color: #fff5f8;
    overflow: hidden; /* Keep organs inside */
    border-radius: 15px;
    width: 100%;
    /* Display Flex to Center the fixed-ratio container */
    display: flex;
    justify-content: center;
    align-items: center;
}

.vis-container {
    position: relative;
    width: 100%;
    /* Aspect Ratio Hack (Standard modern is aspect-ratio: 2/1) */
    aspect-ratio: 2 / 1;
    
    /* Ensure it doesn't overflow height of parent */
    max-height: 100%;
    /* If max-height kicks in, width needs to adjust to maintain ratio */
    /* width: auto doesn't always work with aspect-ratio in flex child nicely without min-height 0 trick or similiar */
    /* Best approach: Aspect Ratio box that fits inside */
    max-width: 200vh; /* Rough constraint if width is huge */
}

#bloodstream-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
    /* Ensure SVG scales same as container */
}

/* Fix bars */
.bar-container {
    width: 100%;
    height: 10px;
    background-color: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

.bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

#insulin-bar {
    background-color: var(--insulin-color);
}

#glucagon-bar {
    background-color: var(--glucagon-color);
}

#adrenaline-bar {
    background-color: #9b59b6; /* Purple for Adrenaline */
}

.readout-item {
    margin-bottom: 15px;
    width: 100%; /* Ensure full width in sidebar */
    flex-direction: row;
    align-items: center;
    gap: 10px;    
}
.organ {
    position: absolute;
    width: 120px;
    padding: 10px;
    background: var(--organ-bg);
    border: 3px solid #ddd;
    border-radius: 12px;
    text-align: center;
    z-index: 2;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.organ .icon {
    font-size: 2.2em; /* Reduced from 3em */
    margin-bottom: 5px;
}

.organ .label {
    font-weight: bold;
    color: var(--text-color);
}

.organ .status {
    font-size: 0.8em;
    color: #7f8c8d;
    margin-top: 5px;
}

/* Organ Positions - Horizontal Layout */
/* Top Row */
.other { top: 10px; left: 15%; transform: translateX(-50%); border-color: #7f8c8d; }
.brain { top: 10px; left: 50%; transform: translateX(-50%); border-color: #9b59b6; }
.liver { top: 10px; left: 85%; transform: translateX(-50%); border-color: #e67e22; }

/* Bottom Row */
.adipose { bottom: 10px; left: 15%; transform: translateX(-50%); border-color: var(--fat-color); }
.intestine { bottom: 10px; left: 50%; transform: translateX(-50%); border-color: #d35400; }
.muscle { bottom: 10px; left: 85%; transform: translateX(-50%); border-color: #e74c3c; width: 140px; }

/* Hidden/Abstract */
.pancreas { display: none; }

/* Active States */
.organ.active-uptake, 
.organ.active-release,
.organ.active-consume {
    transform: translateX(-50%) scale(1.05); /* Maintain X centering */
}

/* Specific Shadow Colors */
.organ.active-uptake {
    border-color: var(--insulin-color);
    box-shadow: 0 0 15px var(--insulin-color);
}

.organ.active-release {
    border-color: var(--glucagon-color);
    box-shadow: 0 0 15px var(--glucagon-color);
}

.organ.active-consume {
    border-color: #f39c12;
    box-shadow: 0 0 10px #f39c12;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  vertical-align: middle;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.control-panel {
    width: 320px; /* Fixed width sidebar */
    min-width: 320px;
    height: 100%;
    background: white;
    padding: 15px; /* Reduced padding */
    box-shadow: -5px 0 15px rgba(0,0,0,0.05); /* Shadow on left side if right-aligned */
    display: flex;
    flex-direction: column; /* Vertical Stack */
    gap: 15px; /* Reduced gap between readout and controls */
    overflow-y: auto; /* Allow scroll if absolutely needed */
    z-index: 10;
}

.readout {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Tighter gap */
}

.readout-item label {
    font-size: 0.85rem; /* Smaller text */
    color: #2c3e50; /* Darker, more legible */
    font-weight: 600; /* Slight bold for readability */
    margin-bottom: 2px;
}

.controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Tighter buttons */
    /* Removed margin-top: auto to prevent overflow on small screens */
}

/* Fix bars */
.bar-.control-group {
    display: flex;
    gap: 8px; /* Tighter buttons */
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow wrapping if too tight */
}

/* Fix bars */
.bar-container {
    width: 100px; /* Smaller for sidebar */
}

button {
    padding: 8px 10px; /* Compact buttons */
    font-size: 0.9em;
    background-color: #34985e; /* Unified Button Color */
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex: 1; /* Distribute buttons */
    min-width: 80px;
}

.btn:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Removed individual colors as per user request */
/* .btn.eat { background-color: #27ae60; } */
/* .btn.insulin { background-color: var(--insulin-color); } */
/* .btn.glucagon { background-color: var(--glucagon-color); } */
/* .btn.exercise { background-color: #8e44ad; } */

.simulation-info {
    margin-top: 20px;
    color: #7f8c8d;
    max-width: 800px;
    text-align: center;
}

/* Storage Visualization */
.storage-container {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-height: 40px;
    overflow: hidden;
}

.storage-unit {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

#liver-storage-visual .storage-unit { background-color: #d35400; }
#fat-storage-visual .storage-unit { background-color: #f1c40f; }
#muscle-storage-visual .storage-unit { background-color: #c0392b; }

/* Glucose Particle */
.glucose-particle {
    fill: var(--sugar-color);
    stroke: #aaa;
    stroke-width: 1;
}

.glycerol-particle {
    fill: #f1c40f; /* Yellow */
    stroke: #d35400;
    stroke-width: 1;
}

/* Animations */
@keyframes pump {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
