:root {
  color-scheme: dark;
  --bg: #10141d;
  --panel: #171d29;
  --panel-2: #1e2635;
  --line: #303949;
  --text: #f5f7fb;
  --muted: #aeb7c8;
  --green: #64d68a;
  --teal: #58c7c7;
  --amber: #f2be63;
  --rose: #ee7d8f;
  --blue: #79a7ff;
  --ink: #10141d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(100, 214, 138, 0.08), transparent 30%),
    linear-gradient(225deg, rgba(242, 190, 99, 0.08), transparent 32%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: var(--ink);
  font-weight: 800;
  padding: 0 16px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: transparent;
  color: var(--rose);
  border: 1px solid rgba(238, 125, 143, 0.58);
}

.icon-button {
  width: 42px;
  padding: 0;
  border-radius: 50%;
  background: var(--amber);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(16, 20, 29, 0.78);
}

.brand-row,
.topbar,
.section-header,
.level-row,
.panel-title,
.top-actions,
.feedback-strip,
.dialog-actions,
.habit-top,
.habit-meta,
.stat-row,
.skill-row,
.log-item {
  display: flex;
  align-items: center;
}

.brand-row,
.topbar,
.section-header,
.level-row,
.panel-title,
.feedback-strip {
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  justify-content: flex-start;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: var(--ink);
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.25rem;
}

h2 {
  font-size: clamp(1.15rem, 1.8vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.brand-row p,
.muted,
.date-label {
  color: var(--muted);
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.avatar-panel,
.stats-panel,
.skill-panel,
.log-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

#avatarCanvas {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  display: block;
  margin: 0 auto 12px;
  image-rendering: pixelated;
}

.level-row strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.xp-track,
.stat-track,
.skill-track {
  height: 10px;
  border-radius: 999px;
  background: #0d1119;
  overflow: hidden;
  margin-top: 12px;
}

.xp-track span,
.stat-track span,
.skill-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
}

.stats-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.stat-row {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.workspace {
  min-width: 0;
  max-width: 100vw;
  width: 100%;
  overflow: hidden;
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  min-height: 74px;
  min-width: 0;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.feedback-strip {
  background: #f2be63;
  color: var(--ink);
  border-radius: 8px;
  padding: 14px 16px;
}

.feedback-strip .eyebrow {
  color: rgba(16, 20, 29, 0.68);
}

.feedback-strip button {
  background: var(--ink);
  color: var(--text);
  white-space: nowrap;
}

.quick-win-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-win-button {
  position: relative;
  background: var(--ink);
  color: var(--text);
  padding: 0 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.quick-win-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.quick-win-button:active:not(:disabled) {
  transform: scale(0.98);
}

.quick-win-button .button-text {
  position: relative;
  z-index: 2;
  display: block;
  font-weight: 800;
}

.quick-win-button .progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--green);
  z-index: 1;
  opacity: 0.7;
  transition: width 0.1s linear;
}

.task-section {
  display: grid;
  gap: 12px;
}

.compact h2 {
  font-size: 1.1rem;
}

.habit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.habit-card {
  min-height: 188px;
  display: grid;
  gap: 12px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.habit-card.done {
  border-color: rgba(100, 214, 138, 0.7);
}

.habit-top,
.habit-meta {
  justify-content: space-between;
  gap: 12px;
}

.habit-title {
  font-weight: 900;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.habit-card.done .tag {
  color: var(--green);
}

.habit-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.habit-actions button {
  width: 100%;
}

.delete-habit {
  width: auto;
  min-width: 92px;
}

.penalty {
  color: var(--rose);
  font-weight: 800;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.skill-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.skill-panel .section-header {
  grid-column: 1 / -1;
}

.skill-tree,
.activity-log {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.skill-tree {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.skill-graph {
  position: relative;
  width: 860px;
  height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #121824;
  background-size: 40px 40px;
}

.skill-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.skill-lines line {
  stroke: rgba(174, 183, 200, 0.32);
  stroke-width: 4;
  stroke-linecap: round;
}

.skill-lines line.active {
  stroke: var(--teal);
}

.skill-icon {
  position: absolute;
  z-index: 2;
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #1d2635;
  color: var(--text);
  box-shadow: 0 0 0 8px #121824;
}

.skill-icon span {
  font-size: 0.86rem;
  font-weight: 900;
}

.skill-icon.unlocked {
  border-color: var(--teal);
  background: var(--green);
  color: var(--ink);
}

.skill-icon.ready {
  border-color: rgba(242, 190, 99, 0.9);
  background: rgba(242, 190, 99, 0.2);
  color: var(--amber);
}

.skill-icon.can-unlock {
  background: var(--amber);
  color: var(--ink);
  box-shadow: 0 0 0 8px #121824, 0 0 18px rgba(242, 190, 99, 0.45);
}

.skill-icon.locked {
  opacity: 0.5;
}

.skill-icon.selected {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}

.skill-info {
  min-height: 248px;
  position: sticky;
  top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.skill-info h3 {
  margin: 2px 0 0;
  font-size: 1.25rem;
}

.skill-info p {
  grid-column: 1 / -1;
  color: var(--muted);
  margin: 0;
}

.skill-info dl {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin: 0;
}

.skill-info dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.skill-info dt {
  color: var(--muted);
  font-weight: 800;
}

.skill-info dd {
  margin: 0;
  text-align: right;
}

.skill-info button {
  grid-column: 1 / -1;
}

.skill-info-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink);
  font-weight: 900;
}

.log-item p {
  color: var(--muted);
  margin-top: 4px;
}

.log-item {
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.log-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: var(--ink);
  font-weight: 900;
  flex: 0 0 auto;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: calc(100vw - 24px);
}

dialog::backdrop {
  background: rgba(7, 9, 13, 0.72);
}

.dialog-card {
  width: min(420px, calc(100vw - 48px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  overflow-x: hidden;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.help-card {
  width: min(620px, calc(100vw - 48px));
}

.help-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.help-list li {
  overflow-wrap: anywhere;
}

.help-list strong {
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #0d1119;
  color: var(--text);
}

@media (max-width: 860px) {
  .app-shell,
  .lower-grid,
  .skill-panel,
  .skill-path {
    grid-template-columns: 1fr;
  }

  .skill-info {
    position: static;
  }

  .skill-path::before {
    left: 16px;
    right: auto;
    top: 18px;
    bottom: 18px;
    width: 2px;
    height: auto;
  }

  .skill-node {
    margin-left: 18px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    width: 100%;
    max-width: 100vw;
  }

  .topbar,
  .feedback-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .feedback-strip button {
    width: 100%;
  }

  .quick-win-buttons {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }

  .top-actions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 520px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .workspace > *,
  .topbar > div,
  .top-actions {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }

  .avatar-panel,
  .stats-panel {
    width: 100%;
    max-width: 358px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .level-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .section-header button {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions button {
    min-width: 0;
  }

  .top-actions .icon-button {
    width: 100%;
    border-radius: 8px;
  }

  .habit-actions {
    grid-template-columns: 1fr;
  }

  .delete-habit {
    width: 100%;
  }

  .habit-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .dialog-card,
  .help-card {
    width: min(300px, calc(100vw - 40px));
    padding: 14px;
  }

  .help-list {
    padding-left: 16px;
  }
}
