:root {
  --beige:      #f8f5ee;
  --beige-dark: #ede6d0;
  --ink:        #2a2010;
  --bubble-bg:  rgba(252, 249, 240, 0.96);
  --term-bg:    rgba(245, 240, 225, 0.98);
  --success:    #355d36;
  --success-bg: rgba(227, 241, 222, 0.96);
  --failure:    #7a2a1f;
  --failure-bg: rgba(249, 229, 221, 0.97);
}

@font-face {
  font-family: "SouthernLiteraryMess";
  src: url("./SouthernLiteraryMess.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  width: 100%; height: 100%;
}

body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--beige);
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--ink);
}

body.dashboard-open #bubbleWrap {
  opacity: 0;
  pointer-events: none;
}

/* ── thought bubble ──────────────────────── */
#bubbleWrap {
  position: fixed;
  top: 7vh;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;   /* tail angles toward bottom-right head */
  width: min(660px, 88vw);
  pointer-events: auto;
  z-index: 10;
  filter: drop-shadow(0 16px 24px rgba(65, 42, 16, 0.14));
}

#bubble {
  width: 100%;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 22%),
    radial-gradient(circle at 77% 82%, rgba(239, 221, 183, 0.52) 0%, rgba(239, 221, 183, 0) 38%),
    var(--bubble-bg);
  border: 2px solid rgba(120, 90, 30, 0.28);
  border-radius: 46% 54% 50% 50% / 42% 42% 58% 58%;
  padding: 2.4em 3em;
  text-align: center;
  font-family: "SouthernLiteraryMess", "Georgia", "Times New Roman", serif;
  font-size: clamp(1.15rem, 2.8vw, 1.92rem);
  letter-spacing: 0.02em;
  line-height: 1.7;
  box-shadow:
    0 10px 36px rgba(48, 34, 12, 0.12),
    inset 0 1px 0 rgba(255,255,240,0.75),
    inset 0 -10px 24px rgba(225, 200, 146, 0.14);
  transition: box-shadow 0.22s ease;
  cursor: grab;
  user-select: none;
}

#bubble:active { cursor: grabbing; }
#bubbleWrap.dragging #bubble {
  box-shadow:
    0 14px 40px rgba(38, 24, 8, 0.2),
    inset 0 1px 0 rgba(255,255,240,0.82),
    inset 0 -8px 18px rgba(225, 200, 146, 0.2);
}

/* thought-bubble tail dots */
.tdot {
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.82) 0%, rgba(255,255,255,0) 35%),
    var(--bubble-bg);
  border: 2px solid rgba(120, 90, 30, 0.2);
  margin-top: 7px;
  margin-right: 14%;
  pointer-events: none;
}
.tdot1 { width: 22px; height: 22px; }
.tdot2 { width: 14px; height: 14px; margin-right: 9%;  margin-top: 5px; }
.tdot3 { width:  8px; height:  8px; margin-right: 5%;  margin-top: 4px; }

/* ── status strip ────────────────────────── */
#statusBar {
  position: fixed;
  bottom: 118px;
  left: 18px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  opacity: 0.45;
  z-index: 20;
  font-family: "Courier New", monospace;
  display: none;
}

/* ── terminal ────────────────────────────── */
#terminal {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--term-bg);
  border-top: 1px solid rgba(120, 90, 30, 0.2);
  padding: 8px 18px;
  font-family: "Courier New", monospace;
  font-size: clamp(0.78rem, 1.5vw, 0.92rem);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

#terminalOutput {
  display: none;
}
#terminalOutput::-webkit-scrollbar { display: none; }
#terminalOutput p {
  line-height: 1.45;
  opacity: 0.8;
}

#terminalForm {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
}

#terminalPrompt {
  opacity: 0.95;
  white-space: nowrap;
  color: #3a2a13;
}

#terminalInput {
  flex: 1;
  background: #fff;
  border: 1.5px solid rgba(120, 90, 30, 0.45);
  border-radius: 5px;
  outline: none;
  font: inherit;
  color: var(--ink);
  caret-color: var(--ink);
  padding: 3px 8px;
}

/* ── dashboard ───────────────────────────── */
#dashboard {
  position: fixed;
  top: 5vh;
  left: min(7vw, 52px);
  bottom: 90px;
  width: min(60vw, 860px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

#dashboard[hidden] {
  display: none;
}

/* compact hero strip */
.dashHero {
  padding: 12px 18px;
  border-radius: 18px;
  border: 1px solid rgba(120, 90, 30, 0.22);
  box-shadow: 0 8px 24px rgba(53, 34, 14, 0.10);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.dashHero.win  { background: linear-gradient(135deg, rgba(255, 250, 239, 0.98), var(--success-bg)); }
.dashHero.lose { background: linear-gradient(135deg, rgba(255, 249, 239, 0.98), var(--failure-bg)); }

.dashVerdict {
  flex-shrink: 0;
  font-family: "Courier New", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

.win  .dashVerdict { background: rgba(73, 129, 74, 0.14);  color: var(--success); }
.lose .dashVerdict { background: rgba(161, 69, 48, 0.14);  color: var(--failure); }

.dashHeroBody {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.dashScenarioTitle {
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.65;
}

.dashScenarioText {
  font-size: 0.95rem;
  line-height: 1.45;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.dashHeroInput {
  font-size: 0.96rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* main two-column area */
.dashMain {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* leaderboard panel */
.dashLeaderboard {
  background: rgba(255, 252, 246, 0.94);
  border: 1px solid rgba(120, 90, 30, 0.16);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(53, 34, 14, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dashLeaderboard h3 {
  font-size: 0.7rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-family: "Courier New", monospace;
  opacity: 0.60;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.dashLbList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.dashLbRow {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(246, 239, 224, 0.60);
  gap: 4px 8px;
}

.dashLbRow.dashLbSelf {
  background: rgba(200, 225, 200, 0.55);
  outline: 1px solid rgba(73, 129, 74, 0.30);
}

.dashLbRank {
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  opacity: 0.50;
}

.dashLbName {
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashLbPts {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.dashLbPts small {
  font-size: 0.65rem;
  font-weight: normal;
  opacity: 0.50;
}

.dashLbQuote {
  grid-column: 2 / -1;
  font-family: "Courier New", monospace;
  font-size: 0.70rem;
  opacity: 0.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashLbEmpty {
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  opacity: 0.50;
  padding: 8px 0;
}

/* side column */
.dashSide {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashCard {
  background: rgba(255, 252, 246, 0.94);
  border: 1px solid rgba(120, 90, 30, 0.16);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(53, 34, 14, 0.07);
  flex-shrink: 0;
}

.dashCard h3 {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  margin-bottom: 7px;
  text-transform: uppercase;
  font-family: "Courier New", monospace;
  opacity: 0.55;
}

.dashChips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.dashChip {
  background: rgba(247, 239, 220, 0.85);
  border-radius: 999px;
  padding: 3px 9px;
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.dashMono {
  font-family: "Courier New", monospace;
  font-size: 0.76rem;
  opacity: 0.65;
}

.dashRunInfo {
  margin-top: auto;
  padding: 4px 2px;
}

.dashAction {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  background: #2f2111;
  color: #fff7e9;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(44, 29, 9, 0.16);
  width: 100%;
  text-align: center;
}

/* ── 3-D head canvas ─────────────────────── */
#headCanvas {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 420px;
  height: 620px;
  z-index: 999;
  pointer-events: none;
  overflow: visible;   /* no clipping from the element itself */
}

@media (max-width: 700px) {
  #headCanvas { width: 260px; height: 400px; }
  #statusBar  { bottom: 122px; }
  #dashboard {
    inset: 18px 14px 86px 14px;
    width: auto;
    gap: 10px;
  }
  .dashMain {
    grid-template-columns: 1fr;
  }
  #bubble {
    font-size: clamp(1rem, 4.8vw, 1.4rem);
    padding: 1.8em 1.9em;
    line-height: 1.56;
  }
}
