/* ============================================================
   PSEUDOCODE ISLAND – Cyberpunk Terminal Style
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080b10;
  --bg2:       #0d1117;
  --bg3:       #111820;
  --border:    #1a2535;
  --border2:   #243040;
  --green:     #00ff9f;
  --cyan:      #00cfff;
  --pink:      #ff6ec7;
  --yellow:    #ffd700;
  --purple:    #bf5fff;
  --red:       #ff5f5f;
  --teal:      #5fffff;
  --dim:       #3a4a5a;
  --text:      #c8d8e8;
  --text-dim:  #5a7080;
  --font:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
}

/* scanlines */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0,0,0,.08) 2px,
    rgba(0,0,0,.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── LAYOUT ──────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: 48px 1fr;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  gap: 0;
}

/* ── HEADER ─────────────────────────────────────────────── */
#header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
  position: relative;
}
#header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--green), var(--cyan), transparent);
}
.logo {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--green);
  text-shadow: 0 0 12px var(--green);
}
.logo span { color: var(--cyan); }
#progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  max-width: 200px;
}
#progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  border-radius: 2px;
  transition: width .4s ease;
  box-shadow: 0 0 8px var(--green);
}
#progress-text { color: var(--text-dim); font-size: 11px; min-width: 80px; }
#btn-reset {
  margin-left: auto;
  background: none;
  border: 1px solid var(--dim);
  color: var(--text-dim);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  border-radius: 2px;
  transition: all .15s;
}
#btn-reset:hover { border-color: var(--red); color: var(--red); }

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: var(--bg2); }
#sidebar::-webkit-scrollbar-thumb { background: var(--border2); }

.zone-group { margin-bottom: 16px; }
.zone-label {
  font-size: 9px;
  letter-spacing: 2px;
  font-weight: 700;
  padding: 4px 8px;
  opacity: .8;
}
.level-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 6px 10px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  border-radius: 3px;
  transition: all .12s;
  border-left: 2px solid transparent;
  margin-bottom: 1px;
}
.level-btn:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
  border-left-color: var(--cyan);
}
.level-btn.active {
  background: var(--bg3);
  color: var(--cyan);
  border-left-color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
.level-btn.done { color: var(--green); }
.level-btn.done::before { content: '✓ '; }
.level-btn.locked { opacity: .3; cursor: not-allowed; }
.level-btn.locked::before { content: '🔒 '; font-size: 9px; }

/* ── MAIN ────────────────────────────────────────────────── */
#main {
  display: grid;
  grid-template-rows: 1fr 1fr;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}

/* ── PANELS ──────────────────────────────────────────────── */
.panel {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.panel-header .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dim);
}
.panel-header .dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.panel-header .dot.cyan  { background: var(--cyan);  box-shadow: 0 0 6px var(--cyan); }
.panel-header .dot.pink  { background: var(--pink);  box-shadow: 0 0 6px var(--pink); }

/* ── STORY PANEL ─────────────────────────────────────────── */
#panel-story {
  grid-column: 1; grid-row: 1;
}
#story-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  cursor: pointer;
}
#story-log::-webkit-scrollbar { width: 4px; }
#story-log::-webkit-scrollbar-thumb { background: var(--border2); }
.story-line {
  color: var(--green);
  font-size: 12px;
  line-height: 1.8;
  text-shadow: 0 0 6px rgba(0,255,159,.3);
}
.story-line::before { content: '> '; color: var(--text-dim); }

/* ── TASK PANEL ──────────────────────────────────────────── */
#panel-task {
  grid-column: 1; grid-row: 2;
}
#task-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
#task-content::-webkit-scrollbar { width: 4px; }
#task-content::-webkit-scrollbar-thumb { background: var(--border2); }
#zone-title {
  font-size: 9px;
  letter-spacing: 3px;
  font-weight: 700;
  margin-bottom: 6px;
  opacity: .8;
}
#level-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,207,255,.4);
  margin-bottom: 12px;
}
#task-text {
  color: var(--text);
  line-height: 1.8;
  font-size: 12px;
}
#task-text code {
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--yellow);
}
#hints-container {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hint-item {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--yellow);
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text);
  border-radius: 0 3px 3px 0;
}
.hint-item code {
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 1px 4px;
  border-radius: 2px;
  color: var(--yellow);
}
.hint-num {
  color: var(--yellow);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
}
#task-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── EDITOR PANEL ────────────────────────────────────────── */
#panel-editor {
  grid-column: 2; grid-row: 1;
}
#code-editor {
  flex: 1;
  background: var(--bg);
  color: #e8f4ff;
  border: none;
  outline: none;
  padding: 16px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  caret-color: var(--green);
}
#code-editor::selection { background: rgba(0,207,255,.2); }
#editor-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  align-items: center;
  flex-shrink: 0;
}
.shortcut-hint {
  color: var(--text-dim);
  font-size: 10px;
  margin-left: auto;
}

/* ── OUTPUT PANEL ────────────────────────────────────────── */
#panel-output {
  grid-column: 2; grid-row: 2;
}
#output-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.8;
  transition: background .15s;
}
#output-panel::-webkit-scrollbar { width: 4px; }
#output-panel::-webkit-scrollbar-thumb { background: var(--border2); }
.output-prompt { color: var(--text-dim); font-size: 10px; display: block; margin-bottom: 6px; }
.output-line { padding: 1px 0; }
.output-line.ok     { color: var(--cyan); }
.output-line.error  { color: var(--red); }
.output-line.warn   { color: var(--yellow); }
.output-line.system { color: var(--green); font-weight: 600; text-shadow: 0 0 8px var(--green); }

/* flash effects */
#output-panel.success-flash { animation: flashGreen .5s ease; }
#output-panel.error-flash   { animation: flashRed   .5s ease; }
@keyframes flashGreen {
  0%,100% { background: var(--bg); }
  30%      { background: rgba(0,255,159,.08); }
}
@keyframes flashRed {
  0%,100% { background: var(--bg); }
  30%      { background: rgba(255,95,95,.08); }
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  padding: 6px 16px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid;
  transition: all .15s;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.btn-primary {
  background: rgba(0,255,159,.1);
  border-color: var(--green);
  color: var(--green);
}
.btn-primary:hover {
  background: rgba(0,255,159,.2);
  box-shadow: 0 0 14px rgba(0,255,159,.4);
}
.btn-primary:active { transform: scale(.97); }
.btn-secondary {
  background: rgba(0,207,255,.07);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-secondary:hover {
  background: rgba(0,207,255,.15);
  box-shadow: 0 0 10px rgba(0,207,255,.3);
}
.btn-ghost {
  background: none;
  border-color: var(--dim);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--yellow); color: var(--yellow); }
.btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  box-shadow: none;
}
#btn-next { display: none; }

/* ── END SCREEN ──────────────────────────────────────────── */
#end-screen {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8,11,16,.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  backdrop-filter: blur(4px);
}
.end-glitch {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--green);
  text-shadow: 0 0 30px var(--green), 0 0 60px var(--green);
  animation: glitch 2s infinite;
}
@keyframes glitch {
  0%,100% { text-shadow: 0 0 30px var(--green); transform: none; }
  92%      { text-shadow: -3px 0 var(--pink), 3px 0 var(--cyan); transform: skewX(-1deg); }
  94%      { text-shadow: 3px 0 var(--pink), -3px 0 var(--cyan); transform: skewX(1deg); }
  96%      { text-shadow: 0 0 30px var(--green); transform: none; }
}
.end-sub {
  color: var(--cyan);
  font-size: 14px;
  letter-spacing: 4px;
  text-align: center;
  line-height: 2;
}

/* ── SCROLLBAR GLOBAL ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
