:root {
  --bg-color: #1e1e1e;
  --editor-bg: #2d2d2d;
  --console-bg: #181818;
  --text-color: #d4d4d4;
  --accent-color: #007acc;
  --button-bg: var(--accent-color);
  --button-hover-bg: #005f9e;
  --help-button-bg: #5a5a5a;
  --help-button-hover-bg: #7a7a7a;
  --error-color: #f44747;
  --font-mono: "SF Mono", "Consolas", "Menlo", "Monaco", monospace;
  --debugger-step-bg: #2a9d8f;
  --debugger-stop-bg: #e76f51;
}

/* Basic Setup */
* {
  box-sizing: border-box;
}
html {
  height: 100%;
}
body {
  font-family: var(--font-mono);
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
h1 {
  text-align: center;
  color: var(--accent-color);
  margin: 0 0 15px 0;
}

/* Layout: Mobile First (Stacked Column) */
.container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 15px;
  min-height: 0;
  width: 100%;
}
.panel {
  display: flex;
  flex-direction: column;
  background-color: var(--editor-bg);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  flex: 1;
  min-height: 0;
}
h2 {
  margin-top: 0;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 10px;
}

/* Ace Editor & Debugger Styles */
#editor {
  flex-grow: 1;
  border-radius: 4px;
  border: 1px solid #444;
}
#editor .ace_gutter-cell.ace_breakpoint {
  background-image: radial-gradient(#e63946 50%, transparent 55%);
  background-repeat: no-repeat;
  background-size: 12px 12px;
  background-position: 3px center;
}
.current-line {
  background-color: rgba(255, 255, 0, 0.15);
  position: absolute;
  z-index: 20;
}
.variable-highlight {
  background-color: rgba(0, 122, 204, 0.5);
  position: absolute;
  z-index: 21;
  border-radius: 2px;
}

/* Main Buttons */
.button-container {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}
.button-container button {
  color: white;
  border: none;
  padding: 12px 15px;
  font-size: 0.9em;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-grow: 1;
}
#runButton {
  background-color: var(--button-bg);
}
#helpButton {
  background-color: var(--help-button-bg);
}

/* Stop State for Main Run Button */
#runButton.is-stopping {
  background-color: var(--debugger-stop-bg);
}
#runButton.is-stopping:hover {
  background-color: #d85a3c;
}

/* Floating Debugger Toolbar */
.floating-toolbar {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  background-color: var(--editor-bg);
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  padding: 8px;
  flex-direction: column;
  gap: 8px;
  min-width: 250px;
}
#toolbarHandle {
  cursor: move;
  display: flex;
  gap: 8px;
  padding-bottom: 8px;
  justify-content: center;
}
.floating-toolbar button {
  background-color: transparent;
  border: 1px solid #555;
  border-radius: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s;
}
.floating-toolbar button:hover {
  background-color: #444;
}
.floating-toolbar button svg {
  width: 24px;
  height: 24px;
  fill: var(--text-color);
}
#variableDisplay {
  border-top: 1px solid #444;
  padding-top: 8px;
}
#variableDisplay h4 {
  margin: 0 0 5px;
  font-size: 0.9em;
  color: var(--accent-color);
  text-align: center;
}
.variable-list {
  font-size: 0.8em;
  max-height: 120px;
  overflow-y: auto;
  padding-right: 5px;
}
.var-entry {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}
.var-name {
  font-weight: bold;
  color: #9cdcfe;
}
.var-value {
  color: #ce9178;
}

/* Console */
.console {
  background-color: var(--console-bg);
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #444;
  display: flex;
  flex-direction: column;
}
#consoleOutput {
  flex: 1;
}
.console-line {
  margin-bottom: 5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.console-line.error {
  color: var(--error-color);
  font-weight: bold;
}
.console-line.output {
  color: var(--text-color);
}
.console-line.prompt {
  color: #6a9955;
}
.console-line.input {
  color: #a9a9a9;
}
#consoleInputContainer {
  display: none;
}
#consoleInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #a9a9a9;
  font-family: inherit;
  font-size: inherit;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
  padding: 1rem;
}
.modal-content {
  background-color: var(--editor-bg);
  padding: 20px;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 {
  color: var(--accent-color);
}
.modal-content code {
  background-color: var(--console-bg);
  padding: 2px 5px;
  border-radius: 3px;
}
.close-button {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

/* --- RESPONSIVE DESIGN --- */
@media (min-width: 800px) and (orientation: landscape) {
  body {
    align-items: center;
  }
  h1 {
    margin-bottom: 20px;
  }
  .container {
    flex-direction: row;
    gap: 20px;
    max-width: 1600px;
  }
  .panel {
    min-width: 0;
  }
  .modal {
    align-items: flex-start;
    padding-top: 5vh;
  }
  .modal-content {
    max-width: 750px;
  }
}
