:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef4f1;
  --panel-3: #f8faf8;
  --primary: #136f63;
  --primary-dark: #0f5149;
  --primary-soft: rgba(19, 111, 99, 0.12);
  --text: #17211d;
  --muted: #68756f;
  --line: #dbe2dd;
  --success: #0f766e;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 39, 33, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(19, 111, 99, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: "Tajawal", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.floating-back {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 30;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--primary);
  text-decoration: none;
  box-shadow: var(--shadow);
  font-size: 1.35rem;
  font-weight: 900;
  backdrop-filter: blur(10px);
}

.floating-back:hover {
  background: var(--primary);
  color: #fff;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero > div:first-child,
.level-card,
.stat-card,
.command-panel,
.main-board,
.achievement-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero > div:first-child {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  padding: 30px;
  background:
    linear-gradient(135deg, rgba(19, 111, 99, 0.94), rgba(23, 33, 29, 0.96)),
    url("data:image/svg+xml,%3Csvg width='960' height='360' viewBox='0 0 960 360' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.18' stroke-width='2'%3E%3Cpath d='M48 266h864M88 210h784M128 154h704M168 98h624'/%3E%3Cpath d='M208 276V78M352 276V78M496 276V78M640 276V78M784 276V78'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.25'%3E%3Ccircle cx='208' cy='210' r='7'/%3E%3Ccircle cx='352' cy='154' r='7'/%3E%3Ccircle cx='496' cy='198' r='7'/%3E%3Ccircle cx='640' cy='112' r='7'/%3E%3Ccircle cx='784' cy='172' r='7'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: #fff;
}

.hero > div:first-child::after {
  content: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 800;
}

.hero .eyebrow {
  color: #abf0df;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  position: relative;
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy {
  position: relative;
  max-width: 660px;
  margin-bottom: 0;
  color: #dce8e3;
  font-size: 1.12rem;
  line-height: 1.9;
}

.level-card {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 24px;
}

.level-card span {
  color: var(--muted);
  font-weight: 700;
}

.level-card strong {
  font-size: 3rem;
}

.level-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.level-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #33a089);
  transition: width 350ms ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: 1.7rem;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.command-panel,
.main-board {
  padding: 18px;
}

.command-panel {
  position: sticky;
  top: 18px;
  height: fit-content;
}

.panel-head,
.section-title,
.tabs,
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.section-title h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
}

.panel-head span,
.section-title span {
  color: var(--muted);
  font-weight: 700;
}

.add-challenge-head {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.quick-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-type {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-3);
  color: var(--text);
  text-align: center;
  display: grid;
  place-content: center;
}

.quick-type input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.quick-type strong,
.quick-type span {
  display: block;
}

.quick-type strong {
  margin-bottom: 4px;
  font-size: 1rem;
}

.quick-type span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.quick-type.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(19, 111, 99, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

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

textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(19, 111, 99, 0.75);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.primary-button,
.ghost-button,
.danger-button,
.tab,
.complete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 800;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.ghost-button,
.tab {
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.danger-button {
  width: 100%;
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tab:hover,
.complete-button:hover {
  transform: translateY(-1px);
}

.danger-zone {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tabs {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.tab {
  padding: 0 16px;
}

.home-link {
  text-decoration: none;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.due-reminders {
  margin-bottom: 18px;
}

.compact-title {
  margin-bottom: 12px;
}

.reminder-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filters {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-3);
}

.filters label {
  min-width: 210px;
  flex: 1;
}

.board-view {
  display: none;
}

.board-view.active {
  display: block;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.achievement-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 16px;
  overflow: hidden;
  transition: transform 200ms ease, border-color 200ms ease, background 200ms ease;
}

.achievement-card:hover {
  transform: translateY(-2px);
  border-color: rgba(19, 111, 99, 0.35);
}

.achievement-card.done {
  border-color: rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, rgba(19, 111, 99, 0.08), rgba(255, 255, 255, 0)), var(--panel);
}

.achievement-card.done::after {
  content: "مكتمل";
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 800;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-inline-start: 72px;
}

.card-top h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
  line-height: 1.5;
}

.card-top p,
.card-meta {
  color: var(--muted);
  line-height: 1.7;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.badge.hot {
  background: var(--primary-soft);
  color: var(--primary);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.points {
  color: var(--warning);
  font-weight: 900;
}

.complete-button {
  min-width: 118px;
  padding: 0 14px;
  background: var(--panel-2);
}

.complete-button.done {
  background: rgba(15, 118, 110, 0.12);
  color: var(--success);
}

.success-burst {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, 24px) scale(0.96);
  opacity: 0;
  padding: 14px 22px;
  border: 1px solid rgba(15, 118, 110, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--success);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.success-burst.show {
  animation: burst 1100ms ease forwards;
}

.hidden {
  display: none !important;
}

@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, 24px) scale(0.96); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1); }
}

@media (max-width: 1120px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .command-panel {
    position: static;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .floating-back {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }

  .app {
    padding: 10px;
    padding-top: 58px;
  }

  .hero {
    gap: 8px;
    margin-bottom: 8px;
  }

  .hero > div:first-child {
    min-height: auto;
    padding: 14px;
  }

  .hero > div:first-child::after {
    display: none;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.78rem;
  }

  h1 {
    margin-bottom: 6px;
    font-size: 1.65rem;
  }

  .hero-copy {
    font-size: 0.86rem;
    line-height: 1.55;
  }

  .level-card,
  .command-panel,
  .main-board {
    padding: 12px;
  }

  .level-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
  }

  .level-card strong {
    font-size: 1.75rem;
  }

  .level-bar {
    grid-column: 1 / -1;
    height: 8px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
  }

  .stat-card {
    min-height: 72px;
    padding: 10px;
  }

  .stat-card span {
    margin-bottom: 4px;
    font-size: 0.76rem;
  }

  .stat-card strong {
    font-size: 1.18rem;
  }

  .cards-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .quick-type-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-type {
    padding: 8px;
    text-align: center;
  }

  .quick-type strong {
    font-size: 0.95rem;
  }

  .quick-type span {
    font-size: 0.68rem;
  }

  .panel-head,
  .section-title,
  .filters,
  .card-footer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .card-top {
    padding-inline-start: 0;
  }

  .complete-button,
  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }
}
