body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 20px;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #333;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
    margin-bottom: 20px;
}

main {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
}

section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

h2 {
    color: #555;
    border-bottom: 2px solid #ddd;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

h3 {
     color: #666;
     margin-top: 20px;
}

h4 {
    color: #777;
}

code {
    background-color: #eee;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: monospace;
}

pre.code-block {
    background-color: #2d2d2d;
    color: #ccc;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    white-space: pre-wrap; /* Wrap long lines */
    word-wrap: break-word; /* Break words if needed */
}

pre.code-block code {
    background-color: transparent; /* Reset background for code inside pre */
    padding: 0;
}


.table-container {
    overflow-x: auto; /* Make table scrollable on small screens */
    margin-bottom: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f0f0f0;
}


/* Quiz Styles */
.quiz {
    background-color: #eef;
    padding: 15px;
    margin-top: 20px;
    border-left: 5px solid #66f;
    border-radius: 4px;
}

.quiz ol {
    list-style: none; /* Remove default list style */
    padding-left: 0; /* Remove default padding */
}

.quiz ol li {
    margin-bottom: 8px; 
    padding: 5px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    display: flex; 
    justify-content: space-between; /* Pushes button to the right */
    align-items: center; /* Vertically center items */
}

.quiz button {
    padding: 5px 10px;
    cursor: pointer;
    margin-left: 10px; /* Space between text and button */
}

.quiz .feedback {
    margin-top: 10px;
    font-weight: bold;
    padding: 8px;
    border-radius: 3px;
}

.quiz .feedback.correct {
    color: green;
    background-color: #dfd;
    border: 1px solid green;
}

.quiz .feedback.incorrect {
    color: red;
    background-color: #fdd;
    border: 1px solid red;
}

/* Bit Visualizer Styles */
.bit-visualizer {
    background-color: #f0f0f0;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-top: 10px;
    text-align: center;
}

.bit-container {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.bit-label {
    width: 50px; /* Align labels */
    text-align: right;
    margin-right: 10px;
    font-weight: bold;
    color: #555;
}

.bit-value {
    font-size: 0.8em;
    color: #777;
    width: 30px; /* Match bit width */
    text-align: center;
}

.bit {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    border: 1px solid #aaa;
    margin: 2px;
    text-align: center;
    cursor: pointer;
    background-color: #fff;
    user-select: none; /* Prevent text selection */
    border-radius: 3px;
}

.bit.on {
    background-color: #8f8;
    font-weight: bold;
}

.bit-result {
    margin-top: 15px;
    font-size: 1.1em;
}

/* Pointer Visualizer Styles */
.pointer-visualizer {
    background-color: #fff8e1; /* Light yellow background */
    padding: 20px;
    border: 1px solid #ffe082; /* Amber border */
    border-radius: 5px;
    margin-top: 15px;
}

.memory-cell {
    border: 1px solid #ccc;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #fff;
    display: flex;
    align-items: center;
    position: relative; /* For absolute positioning of type */
    min-height: 40px;
}

.address {
    font-family: monospace;
    color: #666;
    margin-right: 15px;
    font-size: 0.9em;
}

.variable-name {
    font-weight: bold;
    margin-right: 10px;
    min-width: 70px; /* Ensure names align */
}

.value {
    font-family: monospace;
    background-color: #e3f2fd; /* Light blue background for value */
    padding: 5px 8px;
    border-radius: 3px;
    min-width: 80px; /* Give space for pointer value */
    text-align: center;
}

.pointer-value {
    color: #0d47a1; /* Dark blue for pointer value */
    font-weight: bold;
}

.type {
    position: absolute;
    right: 10px;
    top: 5px;
    font-size: 0.8em;
    color: #999;
}

.pointer-visualizer .controls {
    margin-top: 15px;
    text-align: center;
}

.pointer-visualizer button {
    padding: 8px 15px;
    margin: 5px;
    cursor: pointer;
}

.pointer-visualizer button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.pointer-visualizer p {
    margin-top: 15px;
    text-align: center;
    font-style: italic;
    min-height: 1.2em; /* Reserve space for feedback */
}

/* Memory Visualizer Styles */
.memory-visualizer {
    background-color: #e0f2f7; /* Light cyan background */
    padding: 20px;
    border: 1px solid #80deea; /* Cyan border */
    border-radius: 5px;
    margin-top: 15px;
}

.memory-row {
    display: flex;
    flex-wrap: wrap; /* Allow cells to wrap */
    background-color: #fff;
    padding: 10px;
    border: 1px solid #ccc;
    margin-bottom: 20px;
    min-height: 80px; /* Ensure some space */
}

.memory-cell-vis {
    border: 1px solid #bdbdbd;
    width: 60px; /* Fixed width for each byte cell */
    height: 60px;
    margin: 2px;
    display: flex;
    flex-direction: column; /* Stack address, value, name */
    justify-content: space-between; /* Space out elements */
    align-items: center;
    font-size: 0.8em;
    position: relative; /* For label overlay */
    background-color: #fafafa;
    overflow: hidden; /* Hide overflow */
}

.mem-address {
    font-family: monospace;
    font-size: 0.9em;
    color: #666;
    background-color: #eee;
    width: 100%;
    text-align: center;
    padding: 1px 0;
}

.mem-value {
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1em;
    flex-grow: 1; /* Allow value to take up space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.mem-label {
    position: absolute;
    bottom: 1px;
    left: 1px;
    right: 1px;
    font-size: 0.8em;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    text-align: center;
    padding: 1px 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Highlighting styles */
.memory-cell-vis.highlight-write {
    animation: write-highlight 0.7s ease-out;
}

.memory-cell-vis.highlight-error {
    animation: error-highlight 0.7s ease-out;
    border-color: red;
}

@keyframes write-highlight {
    0% { background-color: #ffcc80; } /* Light orange */
    100% { background-color: #fafafa; }
}

@keyframes error-highlight {
    0% { background-color: #ffcdd2; } /* Light red */
    100% { background-color: #fafafa; }
}

/* Assign different background colors based on variable type */
.memory-cell-vis[data-type="int"] {
    background-color: #e3f2fd; /* Light blue */
}
.memory-cell-vis[data-type="char"] {
    background-color: #fce4ec; /* Light pink */
}
.memory-cell-vis[data-type="short-array"] {
    background-color: #e8f5e9; /* Light green */
}
.memory-cell-vis[data-type="pointer"] {
    background-color: #fffde7; /* Light yellow */
}
.memory-cell-vis[data-type="register"] {
    background-color: #f3e5f5; /* Light purple */
}

.mem-controls {
    margin-top: 15px;
    padding: 10px;
    background-color: #f1f1f1;
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px; /* Space between control groups/buttons */
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-group label {
    font-size: 0.9em;
}

.control-group input {
    padding: 4px;
    width: 60px; /* Small input fields */
}

.mem-controls button {
     padding: 6px 12px;
     cursor: pointer;
}

.mem-controls button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Pointer Drill Styles */
.drill-question {
    background-color: #f9fbe7; /* Lime accent background */
    padding: 15px 20px;
    margin-bottom: 25px;
    border: 1px solid #f0f4c3; /* Lime border */
    border-left: 5px solid #afb42b; /* Darker lime */
    border-radius: 4px;
}

.drill-question h4 {
    margin-top: 0;
    color: #558b2f; /* Dark Green */
}

.drill-question form label {
    display: block; /* Put each radio button on a new line */
    margin-bottom: 8px;
    cursor: pointer;
}

.drill-question form input[type="radio"] {
    margin-right: 8px;
}

.drill-question button {
    padding: 8px 15px;
    margin-top: 10px;
    cursor: pointer;
    background-color: #8bc34a; /* Light Green button */
    color: white;
    border: none;
    border-radius: 3px;
}

.drill-question button:hover {
    background-color: #7cb342;
}

.drill-feedback {
    margin-top: 10px;
    font-weight: bold;
    padding: 8px;
    border-radius: 3px;
}

.drill-feedback.correct {
    color: green;
    background-color: #e8f5e9; /* Light Green */
    border: 1px solid #a5d6a7;
}

.drill-feedback.incorrect {
    color: red;
    background-color: #ffebee; /* Light Red */
    border: 1px solid #ef9a9a;
}

.explanation {
    margin-top: 10px;
    padding: 10px;
    background-color: #eee;
    border: 1px dashed #ccc;
    font-size: 0.95em;
    line-height: 1.5;
}

/* Conversion Practice Styles */
#conversion-practice {
    background-color: #fff9c4; /* Light yellow */
    border-left: 5px solid #fbc02d; /* Darker yellow */
    padding: 15px 20px;
    border-radius: 4px;
}

.practice-problem {
    background-color: #fff;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #eee;
    border-radius: 3px;
}

.practice-problem .prompt {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.practice-problem .prompt strong {
    font-family: monospace;
    background-color: #eee;
    padding: 1px 4px;
    border-radius: 2px;
}
.practice-problem .prompt span {
    font-style: italic;
    color: #555;
}

.practice-problem input[type="text"] {
    padding: 8px;
    margin-right: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    min-width: 150px; /* Give some space */
    font-family: monospace;
}

.practice-problem button {
    padding: 8px 15px;
    cursor: pointer;
}

.conversion-feedback {
     margin-top: 10px;
     font-weight: bold;
     padding: 8px;
     border-radius: 3px;
}

.conversion-feedback.correct {
     color: green;
     background-color: #e8f5e9;
     border: 1px solid #a5d6a7;
}

.conversion-feedback.incorrect {
     color: red;
     background-color: #ffebee;
     border: 1px solid #ef9a9a;
}

.correct-answer {
     margin-top: 8px;
     padding: 8px;
     background-color: #f0f0f0;
     border: 1px dashed #ccc;
     font-size: 0.95em;
}

.correct-answer span {
    font-family: monospace;
    font-weight: bold;
}

footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.9em;
    color: #777;
}

/* Flashcard Styles */
.practice-section .problem .code-block {
    font-size: 1.8em;
    font-weight: bold;
    margin: 10px 0;
    padding: 10px;
    background-color: #eee;
    border-radius: 5px;
    text-align: center;
}

.practice-section .answer-input {
    margin-top: 15px;
    text-align: center;
}

.practice-section .answer-input label {
    margin-right: 10px;
}

.practice-section .answer-input input {
    padding: 8px;
    margin-right: 10px;
    width: 100px; /* Adjust as needed */
}

.practice-section .answer-input button {
    padding: 8px 15px;
    cursor: pointer;
}

#feedback {
    margin-top: 15px;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 5px;
}

#feedback.correct {
    color: green;
    background-color: #e0ffe0;
    border: 1px solid green;
}

#feedback.incorrect {
    color: red;
    background-color: #ffe0e0;
    border: 1px solid red;
}

#feedback.error {
    color: orange;
    background-color: #fff0e0;
    border: 1px solid orange;
}

#next-button {
    display: none; /* Hidden by default, shown by JS */
    margin-left: 10px;
}

/* Quick Reference Style */
.quick-reference {
    text-align: center;
    font-size: 0.9em;
    color: #555;
    margin-bottom: 10px;
}

.quick-reference code {
    font-weight: bold;
    font-size: 1.1em;
    padding: 2px 6px;
}

/* Explanation Style */
.explanation {
    font-size: 0.9em;
    margin-top: 5px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-left: 3px solid #ccc;
    text-align: left;
}

.explanation code {
    background-color: #eee;
    padding: 1px 4px;
    border-radius: 3px;
} 