:root {
  --bg-0: #ffffff;
  --bg-1: #f8fafc;
  --bg-2: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --accent: #1cb0f6;
  --accent-dim: #bae6fd;
  --accent-glow: rgba(28, 176, 246, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --danger-dim: #fca5a5;
  --text-1: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --shelf-wood: #1a0e05;
  --shelf-edge: #3d2008;
  --font-ar: "Tajawal", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --url-counter: url("https://i.imgur.com/dawBZjd.png");
  --url-shelves: url("https://i.imgur.com/rIReD0J.png");
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ar);
  background: var(--bg-0);
  color: var(--text-1);
  box-sizing: border-box;
  overflow: hidden;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}
*::-webkit-scrollbar {
  display: none;
}
* {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
button,
input,
textarea {
  font-family: inherit;
}

/* SCREEN 0 */
#screen-0 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-0);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.app-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 8px 0;
}
.subtitle {
  color: var(--text-2);
  margin: 0 0 32px 0;
  font-size: 16px;
}
.input-group {
  text-align: right;
  margin-bottom: 24px;
}
.input-group label {
  display: block;
  color: var(--text-1);
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}
.input-group input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.login-btn {
  width: 100%;
  background: #fff;
  color: #000;
  border: 1px solid var(--border);
  padding: 12px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.login-btn:hover {
  background: #f0f0f0;
}
.start-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.1s;
  position: relative;
}
.start-btn:hover {
  opacity: 0.9;
}
.start-btn:active {
  transform: scale(0.98);
}
.start-btn-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: #000;
  opacity: 0.7;
  margin-bottom: 4px;
}

/* SCREEN 1 */
#screen-1 {
  display: none;
  width: 100%;
  height: 100vh;
  position: relative;
}
.game-header {
  height: 48px;
  background: transparent;
  border-bottom: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}
.game-header > * {
  pointer-events: auto;
}
.header-right {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  transform: translateY(12px);
}
.header-center {
  font-size: 20px;
  letter-spacing: 4px;
  display: flex;
  gap: 4px;
  transform: translateY(12px);
}
.heart-full {
  color: var(--danger);
  display: inline-block;
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.5));
}
.heart-empty {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  color: transparent;
  display: inline-block;
  width: 24px;
  height: 24px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes heartBeat {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}
.header-center.beat {
  animation: heartBeat 0.4s ease-in-out;
}
.header-left {
  background: rgba(19, 31, 36, 0.7);
  backdrop-filter: blur(4px);
  padding: 4px 12px;
  border-radius: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
  transform: translateY(12px);
}

.scene-container {
  margin-top: 0;
  width: 100%;
  height: 100vh;
  perspective: 1500px;
  overflow: hidden;
}
.room-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.room-wrapper.facing-shelf {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.face-counter {
  background: var(--bg-1) var(--url-counter) no-repeat center/cover;
}
.face-shelf {
  transform: rotateY(180deg);
  background: var(--bg-1) var(--url-shelves) no-repeat center/100% 100%;
}

.fab {
  position: absolute;
  top: 20px;
  background: var(--bg-card);
  color: var(--text-1);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 600;
  backdrop-filter: blur(4px);
  transition:
    background 0.2s,
    transform 0.2s;
  z-index: 20;
}
.fab:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}
.face-counter .fab {
  left: 20px;
}
.face-shelf .fab {
  right: 20px;
}

/* Counter View UI */
.novel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40%;
  background: linear-gradient(
    to top,
    rgba(7, 7, 13, 0.95) 0%,
    rgba(7, 7, 13, 0.85) 60%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
}
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  width: 100%;
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
  color: #ffffff;
}
.bubble-patient {
  background: transparent;
}
.bubble-student {
  background: transparent;
  color: var(--text-2);
}
.bubble-loading {
  background: transparent;
  font-size: 20px;
  letter-spacing: 2px;
}
.danger-toast {
  background: var(--danger-dim);
  color: #fca5a5;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  align-self: center;
  margin: 4px 0;
  text-align: center;
}
.input-row {
  background: rgba(15, 15, 24, 0.9);
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-wrapper {
  display: flex;
  gap: 12px;
}
.input-wrapper textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 12px;
  resize: none;
  outline: none;
  font-size: 16px;
  height: 48px;
  line-height: 24px;
}
.input-wrapper textarea:focus {
  border-color: var(--accent);
}
.btn-send {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 20px;
  font-weight: 700;
  cursor: pointer;
}
.btn-send:disabled,
.input-wrapper textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.progress-text {
  display: none;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  font-family: var(--font-mono);
  direction: ltr;
}
.progress-text.success {
  color: var(--success);
}

/* Shelf View UI */
#shelf-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.drop-zone {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 28px;
  /* Optional: uncomment to debug coordinates */
  /* border: 2px dashed rgba(255,255,255,0.3); border-radius: 8px; */
  border-radius: 3px;
}

.shelf-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.plank {
  display: none; /* Legacy planks hidden */
}
.plank:last-child {
  margin-bottom: 0;
}
.section-header {
  font-family: var(--font-mono);
  color: var(--text-2);
  text-align: center;
  margin: 8px 0 16px 0;
  font-size: 14px;
}
.drugs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 0 12px;
}
.drug-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  position: absolute;
  width: 34px;
  height: 28px;
  font-size: 14px;
  transform: translate(-50%, -50%);
  pointer-events: auto !important;
  user-select: none;
  touch-action: manipulator;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.drug-card:active {
  transform: translate(-50%, calc(-50% + 1px));
  z-index: 100 !important;
}
.drug-card.disabled {
  opacity: 0.45;
}
.drug-card:not(.disabled):hover {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 4px 15px var(--accent-glow);
  transform: translate(-50%, calc(-50% - 2px));
}
.drug-card.shake {
  animation: shake 0.4s ease-in-out;
}
.drug-name {
  font-weight: 700;
  font-size: 7.5px;
  margin-bottom: 0px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  word-wrap: break-word;
  text-align: center;
  height: 100%;
  width: 100%;
}

.confirm-bar {
  position: sticky;
  bottom: -2px;
  left: -2px;
  right: -2px;
  background: var(--bg-2);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
  margin-top: auto;
}
.confirm-text {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-1);
}
.confirm-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn-yes {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  pointer-events: auto !important;
}
.btn-no {
  background: var(--bg-1);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  pointer-events: auto !important;
}

/* Result Overlay */
#screen-result {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(7, 7, 13, 0.95);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 10px;
  text-align: center;
  overflow: hidden;
}
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(15px, 3vw, 24px);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: clamp(14px, 2vw + 10px, 18px);
}
.result-card img,
.result-card table,
.result-card pre,
.result-card a,
.result-card .res-val {
  max-width: 100%;
  overflow-x: auto;
  word-wrap: break-word;
}
.res-icon {
  font-size: 40px;
  margin-bottom: 10px;
}
.res-icon.success {
  color: var(--success);
}
.res-icon.danger {
  color: var(--danger);
}
.res-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}
.res-score {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 16px;
  direction: ltr;
}
.res-details {
  text-align: right;
  background: var(--bg-1);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  line-height: 1.4;
  font-size: 14px;
  overflow-y: auto;
  max-height: 250px;
}
.res-label {
  color: var(--text-2);
  font-size: 12px;
  margin-bottom: 4px;
  display: block;
  font-weight: bold;
}
.res-val {
  color: var(--text-1);
  font-weight: 500;
  margin-bottom: 12px;
  display: block;
}
.res-val:last-child {
  margin-bottom: 0;
}
.res-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  width: 100%;
}
.res-btn.outline {
  background: transparent;
  color: var(--text-1);
  border: 2px solid var(--border);
  margin-top: 12px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-5px);
  }
  40%,
  80% {
    transform: translateX(5px);
  }
}

/* Home Screen Layout - Duolingo Desktop Style */
.home-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  background-color: #131f24;
  color: #ffffff;
  font-family: var(--font-ar), sans-serif;
  overflow: hidden;
}

/* Left Sidebar */
.duo-sidebar {
  width: 256px;
  border-left: 2px solid #2b3e4a; /* RHS since RTL, we want border on right visually, but in RTL it's border-left */
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  border-left: 2px solid #2b3e4a;
}
.duo-logo {
  color: #58cc02;
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 30px;
  letter-spacing: -0.5px;
  font-family: "Varela Round", var(--font-ar), sans-serif;
  text-align: right;
  margin-right: 12px;
}
.duo-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.duo-nav-item {
  background: transparent;
  border: 2px solid transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: 0.2s;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  text-align: right;
  flex-direction: row-reverse;
}
.duo-nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
.duo-nav-item.active {
  background-color: rgba(28, 176, 246, 0.1);
  border: 2px solid #84d8ff;
  color: #1cb0f6;
}
.nav-icon {
  font-size: 24px;
}

/* Middle Content */
.duo-main {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.duo-tab {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

/* Phases / Unit Header */
.duo-unit-header {
  background-color: #00cd9c;
  border-radius: 16px;
  width: 100%;
  padding: 20px 24px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
  color: #ffffff;
  text-align: left;
  direction: ltr;
  box-shadow: 0 4px 0 #00a880;
  cursor: pointer;
  transition: 0.1s;
}
.duo-unit-header:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 transparent;
}
.duo-unit-sub {
  font-size: 14px;
  font-weight: 700;
  opacity: 0.8;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.duo-unit-title {
  font-size: 22px;
  font-weight: 800;
}

/* Sections List View Elements */
.duo-back-nav {
  color: #afafaf;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  direction: ltr;
  align-self: flex-start;
}
.duo-back-nav:hover {
  color: #fff;
}

.duo-section-card {
  background-color: #1a272e;
  border: 2px solid #2b3e4a;
  border-radius: 16px;
  padding: 24px;
  color: #fff;
  text-align: left;
  direction: ltr;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.duo-section-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.02) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.02) 50%,
    rgba(255, 255, 255, 0.02) 75%,
    transparent 75%,
    transparent
  );
  background-size: 60px 60px;
  pointer-events: none;
}

.duo-section-card.active {
  background-color: #202f36;
  flex-direction: column;
  align-items: flex-start;
}
.duo-section-card.active::after {
  display: none;
}

.duo-section-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1;
}
.duo-section-title {
  font-size: 22px;
  font-weight: 800;
}
.duo-section-desc {
  font-size: 14px;
  font-weight: 800;
  color: #58cc02;
  display: flex;
  align-items: center;
  gap: 6px;
}

.duo-continue-btn {
  background-color: #1cb0f6;
  color: white;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #1899d6;
  text-transform: uppercase;
  margin-top: 20px;
}
.duo-continue-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 transparent;
}

.duo-review-btn {
  background-color: transparent;
  color: #1cb0f6;
  border: 2px solid #2b3e4a;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
  z-index: 1;
}
.duo-review-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Path Container */
.duo-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
  padding-bottom: 60px;
}
.duo-path-node {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: default;
  background-color: #2b3e4a;
  box-shadow: 0 6px 0 #1b262d; /* Locked default */
}
.duo-path-node.unlocked {
  background-color: #00cd9c;
  box-shadow: 0 6px 0 #00a880;
  cursor: pointer;
}
.duo-path-node.unlocked:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 #00a880;
}
.duo-node-icon {
  font-size: 32px;
  color: #ffffff;
}

/* Active node tooltip */
.duo-node-tooltip {
  position: absolute;
  top: -50px;
  background: #ffffff;
  color: #00cd9c;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 1px;
  flex-direction: column;
  align-items: center;
  display: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.duo-node-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}
.duo-path-node.unlocked .duo-node-tooltip {
  display: flex;
} /* Simplification: Show START on unlocked always for ref */

/* Right Sidebar */
.duo-right-panel {
  width: 330px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 2px solid #2b3e4a; /* visually left border since RTL body, but actually border-right in ltr context. Wait, if body is RTL, panels are swapped. Let's force LTR for layout or just adapt. */
}
.duo-top-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  direction: ltr;
  font-weight: 700;
  font-size: 15px;
}
.duo-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #afafaf;
  position: relative;
}
.duo-stat.interactive {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 12px;
  transition: background 0.1s;
}
.duo-stat.interactive:hover {
  background: rgba(255, 255, 255, 0.05);
}

.stat-popup {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 50%;
  transform: translateX(50%);
  background: #1a272e;
  border: 2px solid #2b3e4a;
  border-radius: 16px;
  padding: 20px;
  z-index: 200;
  min-width: 250px;
  flex-direction: column;
  cursor: default;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.duo-stat.interactive:hover .stat-popup {
  display: flex;
}
.stat-popup::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 10px 12px 10px;
  border-style: solid;
  border-color: transparent transparent #2b3e4a transparent;
}
.stat-popup::after {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 10px 12px 10px;
  border-style: solid;
  border-color: transparent transparent #1a272e transparent;
}
.stat-popup h3 {
  margin: 0 0 12px 0;
  color: white;
  font-size: 18px;
  text-align: left;
}
.stat-popup-content {
  color: #afafaf;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
  line-height: 1.4;
  font-weight: 700;
}
.stat-popup-btn {
  background: transparent;
  border: 2px solid #2b3e4a;
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 800;
  padding: 12px;
  cursor: pointer;
  text-transform: uppercase;
  width: 100%;
  transition: 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stat-popup-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Node locked popup */
.locked-node-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a272e;
  border: 2px solid #2b3e4a;
  border-radius: 16px;
  padding: 20px;
  z-index: 200;
  width: 280px;
  flex-direction: column;
  cursor: default;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  text-align: left;
}
.duo-path-node.show-popup .locked-node-popup {
  display: flex;
}
.duo-path-node.show-popup {
  z-index: 100;
}
.locked-node-popup::before {
  content: "";
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 12px 10px 0 10px;
  border-style: solid;
  border-color: #2b3e4a transparent transparent transparent;
}
.locked-node-popup::after {
  content: "";
  position: absolute;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 12px 10px 0 10px;
  border-style: solid;
  border-color: #1a272e transparent transparent transparent;
}
.locked-node-popup h3 {
  margin: 0 0 8px 0;
  color: #58cc02;
  font-size: 18px;
  font-weight: 800;
}
.locked-node-popup p {
  margin: 0 0 16px 0;
  color: #afafaf;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
}
.locked-node-btn {
  background: transparent;
  border: 2px solid #37464f;
  border-radius: 12px;
  color: #37464f;
  font-size: 15px;
  font-weight: 800;
  padding: 12px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
}
.duo-card {
  border: 2px solid #2b3e4a;
  border-radius: 16px;
  padding: 20px;
  text-align: left;
  direction: ltr;
}
.duo-card-btn {
  width: 100%;
  background: #5a3cf5;
  border: none;
  padding: 14px;
  color: white;
  font-weight: 800;
  font-size: 15px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #462fc1;
  margin-top: 10px;
  text-transform: uppercase;
}
.duo-card-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 transparent;
}

.empty-state {
  text-align: center;
  color: var(--text-3);
  font-size: 16px;
  margin-top: 40px;
}

/* Hide old bottom nav */
.bottom-nav {
  display: none !important;
}

/* RTL Adjustments */
body {
  direction: rtl;
}
.duo-layout {
  direction: rtl;
}

.duo-mobile-top-stats {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  direction: ltr;
  font-weight: 700;
  font-size: 15px;
  box-sizing: border-box;
  background: #131f24;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid #2b3e4a;
}

/* Lectures (Letters) UI */
.duo-lectures-header {
  text-align: center;
  margin-bottom: 24px;
  color: #fff;
}
.duo-lectures-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  font-family: var(--font-ar), sans-serif;
}
.duo-lectures-sub {
  font-size: 16px;
  color: #afafaf;
}

.duo-start-btn {
  background-color: #1cb0f6;
  color: white;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 0 #1899d6;
  margin-bottom: 32px;
  text-transform: uppercase;
}
.duo-start-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 transparent;
  margin-bottom: 36px;
}

.duo-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #1e293b;
  font-weight: 900;
  font-size: 18px;
  margin-bottom: 24px;
  width: 100%;
}
.duo-divider::before,
.duo-divider::after {
  content: "";
  flex: 1;
  border-bottom: 2px solid #e2e8f0;
  margin: 0 16px;
}

.duo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}
.duo-letter-card {
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  background: #ffffff;
  transition: 0.1s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}
.duo-letter-card:active {
  background: #f8fafc;
  transform: scale(0.98);
}
.duo-letter-main {
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
  text-align: center;
}
.duo-letter-sub {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 600;
}

.duo-progress-track {
  width: 32px;
  height: 6px;
  background: #2b3e4a;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.duo-progress-fill {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: #ffc800;
  border-radius: 3px;
}

/* Quests */
.duo-quest-item {
  display: flex;
  gap: 16px;
  align-items: center;
  direction: ltr;
}
.duo-quest-icon {
  font-size: 32px;
  width: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.duo-quest-content {
  flex: 1;
}
.duo-quest-title {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}
.duo-quest-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.duo-quest-progress-track {
  flex: 1;
  height: 16px;
  background: #2b3e4a;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.duo-quest-progress-fill {
  height: 100%;
  background: #ffc800;
  border-radius: 8px;
  transition: width 0.3s;
}
.duo-quest-progress-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.duo-quest-reward {
  font-size: 24px;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .duo-right-panel {
    display: none;
  }
  .duo-mobile-top-stats {
    display: flex;
  }
}

.more-menu-dropdown {
  display: none;
  position: absolute;
  right: 100%;
  top: 0;
  background: #1a272e;
  border: 2px solid #2b3e4a;
  border-radius: 12px;
  padding: 8px;
  z-index: 100;
  min-width: 150px;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  margin-right: 8px;
}

@media (max-width: 768px) {
  .more-menu-dropdown {
    left: 0;
    right: auto;
    top: auto;
    bottom: 100%;
    margin-bottom: 8px;
    margin-right: 0;
  }
  .home-layout {
    flex-direction: column;
  }

  .duo-sidebar {
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 2px solid #2b3e4a;
    flex-direction: row;
    padding: 10px 0;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    background: #131f24;
    z-index: 100;
  }

  .duo-logo {
    display: none;
  }

  .duo-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    gap: 0;
    padding: 6px 4px;
    box-sizing: border-box;
  }

  .duo-nav-item {
    flex-direction: row;
    padding: 0;
    gap: 0;
    border: none;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    flex: 1;
    min-width: 0;
  }

  .duo-nav-item .nav-label {
    display: none;
  }

  .nav-icon {
    font-size: 24px;
    filter: none;
    opacity: 0.7;
    padding: 6px 2px;
    width: 100%;
    border-radius: 12px;
    border: 2px solid transparent;
    margin: 0;
    transition: 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 60px;
    box-sizing: border-box;
  }

  .duo-nav-item.active {
    background-color: transparent;
    border: none;
  }

  .duo-nav-item.active .nav-icon {
    background-color: rgba(132, 216, 255, 0.15);
    border: 2px solid #84d8ff;
    border-radius: 16px;
    opacity: 1;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .more-nav-mobile-flex {
    flex: 1;
    width: auto !important;
  }

  .duo-main {
    padding-bottom: 90px;
  }
  .duo-tab {
    padding: 0 16px;
    box-sizing: border-box;
  }

  .duo-unit-header {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 12px;
  }
  .duo-unit-title {
    font-size: 16px;
  }
  .duo-unit-sub {
    font-size: 12px;
    margin-bottom: 4px;
    gap: 4px;
  }
  .duo-unit-header .nav-icon {
    font-size: 12px !important;
  }
  .duo-path-node {
    width: 55px;
    height: 55px;
  }
  .duo-node-icon {
    font-size: 24px;
  }

  .duo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px;
    justify-content: center;
  }
  .duo-letter-card {
    padding: 16px 8px;
    justify-content: center;
  }
  .duo-letter-main {
    font-size: 15px;
    line-height: 1.3;
    margin-bottom: 4px;
    text-align: center;
  }
  .duo-letter-sub {
    font-size: 12px;
    margin-bottom: 8px;
    line-height: 1.3;
    padding: 0 4px;
    text-align: center;
  }
}

/* Responsive refinements for landscape/small heights */
@media (max-height: 500px) {
  .novel-overlay {
    height: 65%;
    min-height: 180px;
  }
  .chat-area {
    padding: 20px 12px 12px 12px;
    gap: 8px;
  }
  .input-row {
    padding: 8px 12px;
    gap: 4px;
  }
  .input-wrapper textarea {
    height: 40px;
    padding: 8px;
    font-size: 14px;
  }
  .btn-send {
    padding: 0 16px;
    font-size: 14px;
  }
  .bubble {
    padding: 8px 12px;
    font-size: 14px;
  }
  .shelf-overlay {
    max-height: calc(100% - 20px);
    padding: 8px;
    padding-bottom: 70px;
    bottom: 10px;
  }
  .drugs-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    padding: 0 16px;
    justify-content: center;
  }
  .drug-card {
    padding: 8px;
  }
  .section-header {
    margin: 4px 0 8px 0;
    font-size: 12px;
  }
  .confirm-bar {
    padding: 12px;
    gap: 8px;
  }
  .confirm-text {
    font-size: 14px;
  }
  .btn-yes,
  .btn-no {
    padding: 8px 16px;
    font-size: 14px;
  }
  .fab {
    padding: 6px 12px;
    font-size: 12px;
    top: 10px;
  }
  .face-counter .fab {
    left: 10px;
  }
  .face-shelf .fab {
    right: 10px;
  }
}
