* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1f2d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #163042;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#renderCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

/* =========================================================
   ЛЕВАЯ ВЕРХНЯЯ ИНФО-ПАНЕЛЬ ПАЦИЕНТА (Экранчик медкарты)
   ========================================================= */
#patientMonitor {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 242px;
  background: linear-gradient(165deg, rgba(16, 39, 58, 0.94) 0%, rgba(11, 28, 44, 0.96) 100%);
  border: 2px solid rgba(94, 211, 255, 0.48);
  border-radius: 15px;
  padding: 8px 10px;
  color: #e8f7ff;
  box-shadow: 0 10px 24px rgba(4, 15, 26, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.monitor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(120, 210, 255, 0.22);
}

.patient-avatar-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 35%, #2a5f85, #14324a);
  border: 2px solid rgba(125, 224, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.patient-avatar-wrap img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.mood-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #132c42;
  border: 1.5px solid #63d2ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.patient-title-block {
  min-width: 0;
  flex: 1;
}

.monitor-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #63d2ff;
  margin-bottom: 1px;
}

#patientNameText {
  margin: 0 0 3px 0;
  font-size: 14.5px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.symptoms-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  color: #ffd6a0;
  background: rgba(255, 145, 77, 0.18);
  border: 1px solid rgba(255, 167, 89, 0.42);
  border-radius: 7px;
  padding: 2px 6px;
}

.symptoms-pill.cured {
  color: #a9ffcb;
  background: rgba(46, 213, 115, 0.2);
  border-color: rgba(46, 213, 115, 0.55);
}

.monitor-readings {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reading-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 7px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.22s ease;
}

.reading-row.updated {
  background: rgba(74, 210, 255, 0.14);
  border-color: rgba(99, 210, 255, 0.45);
}

.r-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.r-name {
  color: #a4c8e0;
  font-weight: 600;
  flex-shrink: 0;
}

.r-val {
  margin-left: auto;
  text-align: right;
  font-weight: 700;
  font-size: 11.5px;
}

.r-val.pending {
  color: #7798b2;
  font-weight: 500;
  font-style: italic;
}

.r-val.alert {
  color: #ff9f7a;
}

.r-val.ok {
  color: #67f2a5;
}

.monitor-footer {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(120, 210, 255, 0.2);
}

.diagnosis-line {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: #9dc5df;
  font-weight: 700;
}

.treatment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.t-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 193, 79, 0.17);
  border: 1px solid rgba(255, 202, 99, 0.48);
  color: #ffe39f;
}

.t-tag.done {
  background: rgba(68, 228, 138, 0.22);
  border-color: rgba(68, 228, 138, 0.6);
  color: #afffd0;
  text-decoration: line-through;
}

.t-tag.lollipop-ready {
  background: linear-gradient(90deg, #ff7eb3, #ffb84d);
  color: #1c1026;
  border-color: #fff;
  animation: pulseGlow 1.1s infinite alternate;
}

/* =========================================================
   ВЕРХНЯЯ ЦЕНТРАЛЬНАЯ ПАНЕЛЬ ИНСТРУМЕНТОВ И ДЕЙСТВИЙ
   ========================================================= */
#topCenterToolbar {
  position: absolute;
  top: 10px;
  left: 260px;
  right: 192px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(122, 192, 232, 0.8);
  border-radius: 15px;
  padding: 5px 7px;
  box-shadow: 0 10px 26px rgba(8, 28, 46, 0.28);
  backdrop-filter: blur(10px);
  z-index: 25;
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.group-caption {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #49718c;
  text-align: center;
}

.tool-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.toolbar-divider {
  width: 1.5px;
  background: rgba(123, 174, 204, 0.38);
  margin: 2px 1px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tool-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 48px;
  height: 44px;
  padding: 2px 4px;
  border-radius: 10px;
  border: 2px solid #cbe4f5;
  background: linear-gradient(180deg, #f5fbff 0%, #e3f2fd 100%);
  color: #1b3d54;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.tool-btn:hover {
  transform: translateY(-2px);
  border-color: #5bb8ff;
  box-shadow: 0 5px 12px rgba(45, 136, 216, 0.2);
}

.tool-btn.treat-btn {
  border-color: #ccecd9;
  background: linear-gradient(180deg, #f4fff8 0%, #def7e8 100%);
}

.tool-btn.lollipop-btn {
  border-color: #ffc2d9;
  background: linear-gradient(180deg, #fff5f9 0%, #ffe0ec 100%);
}

.tool-btn. lollipop-highlight,
.tool-btn.lollipop-ready-btn {
  border-color: #ff4f93;
  background: linear-gradient(180deg, #ffe799 0%, #ff9ec7 100%);
  animation: pulseGlow 0.9s infinite alternate;
}

.tool-btn.active {
  border-color: #ff9800 !important;
  background: linear-gradient(180deg, #fff8db 0%, #ffe082 100%) !important;
  box-shadow: 0 0 0 3px rgba(255, 160, 0, 0.32), 0 6px 14px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px) scale(1.03);
}

.tool-btn.recommended {
  border-color: #2ecc71;
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.35);
}

.tool-emoji {
  font-size: 17px;
  line-height: 1;
}

.tool-label {
  font-size: 9.5px;
  font-weight: 800;
  white-space: nowrap;
}

.tool-check {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 900;
  color: #16a34a;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s ease;
}

.tool-btn.done .tool-check {
  opacity: 1;
  transform: scale(1);
}

/* =========================================================
   ПРАВАЯ ВЕРХНЯЯ ПАНЕЛЬ ДОКТОРА И ОЧКОВ
   ========================================================= */
#doctorHud {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 20;
}

.doc-stat-card {
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(122, 192, 232, 0.8);
  border-radius: 15px;
  padding: 6px 9px;
  width: 174px;
  box-shadow: 0 10px 26px rgba(8, 28, 46, 0.25);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.doc-badge-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.doc-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #ff7eb6;
  background: #ffe6f2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-mini-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

#activeDocName {
  font-size: 13.5px;
  font-weight: 800;
  color: #173a52;
  margin-right: auto;
}

.mini-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #c5dff0;
  background: #f0f8ff;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.mini-icon-btn:hover {
  background: #dcedfc;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff9e6;
  border: 1px solid #ffd97d;
  border-radius: 10px;
  padding: 4px 8px;
}

.score-pill.cured-pill {
  background: #eefbf3;
  border-color: #a9e5c0;
}

.sc-icon {
  font-size: 16px;
}

.score-pill small {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  color: #607d8b;
  line-height: 1.1;
}

.score-pill strong {
  font-size: 14px;
  font-weight: 900;
  color: #19394e;
}

.decor-open-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border-radius: 10px;
  border: 1.5px solid #c8b6ff;
  background: linear-gradient(90deg, #f3edff, #e6f4ff);
  color: #3a276e;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.decor-open-btn:hover {
  transform: translateY(-1px);
}

.decor-count {
  background: #6c47d9;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
}

/* =========================================================
   МИРОВЫЕ ПЛАШКИ (Дверь очереди слева внизу и Анализатор справа)
   ========================================================= */
.world-badge {
  position: absolute;
  z-index: 15;
  border-radius: 14px;
  font-family: inherit;
  box-shadow: 0 8px 20px rgba(7, 22, 36, 0.35);
}

.door-badge {
  left: 18px;
  bottom: 66px;
  background: rgba(18, 43, 64, 0.9);
  border: 2px solid rgba(128, 214, 255, 0.65);
  color: #eef9ff;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 800;
  pointer-events: none;
}

.badge-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4cd137;
  box-shadow: 0 0 8px #4cd137;
}

.analyzer-badge {
  right: 22px;
  bottom: 130px;
  background: linear-gradient(135deg, rgba(22, 46, 72, 0.95), rgba(33, 68, 102, 0.95));
  border: 2px solid #63d2ff;
  color: #fff;
  padding: 8px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.analyzer-badge:hover {
  transform: translateY(-2px) scale(1.02);
}

.analyzer-badge.ready-to-run {
  background: linear-gradient(135deg, #ff9800, #ff5722);
  border-color: #fff;
  animation: pulseGlow 0.85s infinite alternate;
}

.analyzer-badge.busy {
  background: linear-gradient(135deg, #6c5ce7, #0984e3);
  border-color: #a29bfe;
}

.analyzer-badge.done {
  background: linear-gradient(135deg, #10ac84, #1dd1a1);
  border-color: #c8ffea;
}

.an-icon {
  font-size: 22px;
}

.an-texts {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.an-texts strong {
  font-size: 12px;
  font-weight: 800;
}

.an-texts small {
  font-size: 10.5px;
  color: #d1ecff;
}

/* =========================================================
   НИЖНЯЯ СТРОКА ПОДСКАЗОК ДОКТОРА
   ========================================================= */
#bottomToast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 36, 54, 0.92);
  border: 1.5px solid rgba(114, 206, 255, 0.55);
  color: #f3fbff;
  padding: 8px 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  z-index: 20;
  max-width: 92vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   ВСПЛЫВАЮЩИЕ БАЛЛЫ (+40 ⭐)
   ========================================================= */
#floatingPointsContainer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.float-score {
  position: absolute;
  font-size: 18px;
  font-weight: 900;
  color: #ffe066;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  animation: floatUpFade 1.3s ease-out forwards;
}

@keyframes floatUpFade {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.75); }
  20% { opacity: 1; transform: translate(-50%, -12px) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -58px) scale(0.95); }
}

@keyframes pulseGlow {
  from { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.55); transform: scale(1); }
  to { box-shadow: 0 0 18px 4px rgba(255, 105, 180, 0.65); transform: scale(1.04); }
}

/* =========================================================
   МОДАЛЬНЫЕ ОКНА (ВЫБОР ДОКТОРА И ДЕКОРАЦИИ)
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 24, 38, 0.76);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: linear-gradient(180deg, #ffffff 0%, #f1f8fe 100%);
  border: 3px solid #88ccf7;
  border-radius: 26px;
  padding: 24px 26px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(4, 15, 28, 0.55);
  text-align: center;
}

.clinic-crest {
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #0984e3;
  background: #e1f3ff;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.doctor-modal h1 {
  margin: 0 0 6px 0;
  font-size: clamp(22px, 2.5vw, 30px);
  color: #13344c;
}

.doctor-modal p {
  margin: 0 auto 18px auto;
  max-width: 540px;
  font-size: 14px;
  color: #4b6b82;
}

.doctors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.doctor-choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 16px;
  border-radius: 20px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ada-card {
  background: linear-gradient(180deg, #fff5f9 0%, #ffe3ef 100%);
  border-color: #ff9ec4;
}

.olga-card {
  background: linear-gradient(180deg, #f0fffc 0%, #d5faf2 100%);
  border-color: #63e2c6;
}

.doctor-choice-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(17, 48, 74, 0.18);
}

.doc-avatar-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.girl-portrait-frame {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  padding: 4px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(20, 48, 72, 0.16);
}

.ada-frame {
  border: 3px solid #ff7eb6;
}

.olga-frame {
  border: 3px solid #26de81;
}

.girl-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.glove-preview {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 99px;
}

.pink-glove {
  background: #ff6fa9;
  color: #fff;
}

.mint-glove {
  background: #1abc9c;
  color: #fff;
}

.doctor-choice-card h3 {
  margin: 0 0 6px 0;
  font-size: 20px;
  color: #15354b;
}

.doctor-choice-card p {
  font-size: 12.5px;
  color: #4c697d;
  margin: 0 0 14px 0;
  line-height: 1.35;
}

.choose-btn-fake {
  margin-top: auto;
  display: inline-block;
  padding: 8px 16px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  background: #163850;
  color: #fff;
}

/* Окно декораций */
.modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-top-bar h2 {
  margin: 0;
  font-size: 20px;
  color: #16364d;
}

.close-modal-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #e3eff8;
  color: #1e425e;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.decor-sub {
  font-size: 13px;
  color: #51718a;
  margin: 0 0 14px 0;
  text-align: left;
}

.decor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 10px;
  text-align: left;
}

.decor-item-card {
  background: #fff;
  border: 2px solid #d4e8f7;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.decor-item-card.unlocked {
  border-color: #4cd137;
  background: #f4fff6;
}

.decor-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.decor-item-head span {
  font-size: 24px;
}

.decor-item-head strong {
  font-size: 13px;
  color: #17384f;
}

.decor-item-desc {
  font-size: 11.5px;
  color: #5a788f;
}

.decor-buy-btn {
  margin-top: auto;
  padding: 6px 10px;
  border-radius: 9px;
  border: none;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  background: #0984e3;
  color: #fff;
}

.decor-buy-btn.unlocked {
  background: #2ecc71;
}

/* =========================================================
   АДАПТИВНОСТЬ ПОД ПЛАНШЕТЫ И МОБИЛКИ
   ========================================================= */
@media (max-width: 820px) {
  #topCenterToolbar {
    top: auto;
    bottom: 48px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 96vw;
    overflow-x: auto;
    padding: 5px 8px;
  }

  .door-badge {
    bottom: 130px;
  }

  .analyzer-badge {
    bottom: 130px;
  }
}

@media (max-width: 680px) {
  #patientMonitor {
    width: calc(100vw - 24px);
    padding: 8px 10px;
  }

  #doctorHud {
    top: auto;
    bottom: 128px;
    right: 10px;
  }

  .doc-stat-card {
    min-width: 165px;
    padding: 6px 9px;
  }

  .doctors-grid {
    grid-template-columns: 1fr;
  }

  .tool-btn {
    min-width: 54px;
    height: 48px;
  }
}
