/* Guided onboarding pilot. Existing game styles are untouched. */
.ct-blocker { position:fixed; background:rgba(0,0,0,.62); z-index:2146000000; touch-action:none; }
.ct-spotlight { position:fixed; z-index:2146000001; pointer-events:none; border:2px solid #ffd66c; border-radius:12px; box-shadow:0 0 12px #f0a93e, inset 0 0 8px rgba(255,214,108,.25); animation:ctPulse 1.5s ease-in-out infinite; }
@keyframes ctPulse { 0%,100% {box-shadow:0 0 8px #f0a93e} 50% {box-shadow:0 0 22px #ffdf8f} }
.ct-pointer {position:fixed;width:70px;height:70px;object-fit:contain;z-index:2146000003;pointer-events:none;transform:translate(-50%,-50%) rotate(-45deg);filter:drop-shadow(0 0 8px #000);}
.ct-card {position:fixed;z-index:2146000004;left:50%;top:50%;width:min(450px,calc(100vw - 40px));box-sizing:border-box;transform:translate(-50%,-50%);border-radius:17px;background:linear-gradient(150deg,#152b48,#081424);border:1px solid #d9a856;color:#fff;box-shadow:0 8px 30px #000b;padding:14px 16px;display:flex;gap:12px;align-items:center;max-height:min(43vh,310px);overflow:auto;}
.ct-card.ct-top,.ct-card.ct-bottom {top:50%;bottom:auto;}
.ct-cat {width:88px;height:112px;object-fit:contain;flex-shrink:0;align-self:flex-end;}
.ct-copy {flex:1;min-width:0;display:flex;flex-direction:column;gap:9px;font-size:17px;line-height:1.5;}
.ct-copy p {margin:0;white-space:pre-line;}
.ct-button {background:#e3b658;border:0;border-radius:10px;padding:9px 13px;color:#142235;font-size:16px;font-weight:700;cursor:pointer;align-self:flex-end;min-height:38px;}
.ct-button:disabled {opacity:.4;cursor:wait;} .ct-button.ct-ghost {background:transparent;border:1px solid #b2a182;color:#ddd;}
.ct-modal {position:fixed;inset:0;z-index:2146000020;background:rgba(0,0,0,.70);display:flex;align-items:center;justify-content:center;padding:20px;}
.ct-modal .ct-card {position:relative;inset:auto;left:auto;bottom:auto;top:auto;transform:none;max-height:90vh;width:min(470px,100%);}
.ct-modal .ct-cat {width:100px;height:145px;}
/* Welcome screen only: show each completion reward with its existing game asset. */
.ct-welcome-rewards {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;}
.ct-welcome-reward {min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:8px 3px;border:1px solid #425471;border-radius:9px;background:rgba(9,20,37,.64);text-align:center;line-height:1.15;}
.ct-welcome-reward img {width:36px;height:36px;max-width:100%;object-fit:contain;}
.ct-welcome-reward strong {font-size:17px;color:#ffdb82;}
.ct-welcome-reward span {font-size:12px;color:#e4eaf4;}
@media(max-width:400px) {
  .ct-modal .ct-welcome {gap:8px;padding:12px;}
  .ct-modal .ct-welcome .ct-cat {width:68px;height:100px;}
  .ct-welcome-rewards {gap:4px;}
  .ct-welcome-reward {padding:6px 2px;}
  .ct-welcome-reward img {width:28px;height:28px;}
  .ct-welcome-reward strong {font-size:15px;}
  .ct-welcome-reward span {font-size:11px;}
}
.ct-actions {display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;}
.ct-gift {display:flex;align-items:center;gap:10px;background:#0b1a2d;padding:8px;border-radius:10px;}
.ct-gift img {width:58px;height:58px;object-fit:contain;}
.ct-gift small {color:#b8c9db;display:block;}
/* Gift step only: bigger mentor at top, compact item preview and two buttons below. */
.ct-gift-card {display:grid;grid-template-columns:112px minmax(0,1fr);align-items:start;gap:8px 12px;padding:12px 14px;max-height:min(72vh,390px);overflow-y:auto;}
.ct-gift-card .ct-cat {grid-column:1;grid-row:1;width:112px;height:152px;align-self:start;object-position:center top;}
.ct-gift-card .ct-copy {display:contents;}
.ct-gift-card .ct-copy > p {grid-column:2;grid-row:1;align-self:center;font-size:17px;line-height:1.35;overflow-wrap:break-word;}
.ct-gift-card .ct-gift-preview {grid-column:1 / -1;grid-row:2;display:flex;flex-direction:column;align-items:center;gap:5px;padding:0;text-align:center;}
.ct-gift-card .ct-gift-preview .item-slot-lg {width:68px;height:68px;}
.ct-gift-card .ct-gift-name {font-size:14px;font-weight:700;color:#ddd;line-height:1.25;}
.ct-gift-card .ct-actions {grid-column:1 / -1;grid-row:3;display:flex;flex-wrap:nowrap;justify-content:center;width:100%;gap:8px;}
.ct-gift-card .ct-actions .ct-button {flex:1 1 0;min-width:0;align-self:stretch;padding:8px 6px;font-size:clamp(12px,3.5vw,16px);text-align:center;white-space:normal;}
.ct-gift-card .ct-actions #ctNext {flex-grow:1.35;}
@media(max-width:400px) {
  .ct-gift-card {grid-template-columns:96px minmax(0,1fr);gap:6px 9px;padding:11px 12px;}
  .ct-gift-card .ct-cat {width:96px;height:138px;}
  .ct-gift-card .ct-copy > p {font-size:15px;}
}
/* Post-defeat aid: mentor high, reward images with amounts underneath. */
.ct-aid-card {display:grid;grid-template-columns:112px minmax(0,1fr);align-items:start;gap:10px 12px;padding:12px 14px;max-height:min(72vh,390px);overflow-y:auto;}
.ct-aid-card .ct-cat {grid-column:1;grid-row:1;width:112px;height:152px;align-self:start;object-position:center top;}
.ct-aid-card .ct-copy {display:contents;}
.ct-aid-card .ct-copy > p {grid-column:2;grid-row:1;align-self:center;font-size:17px;line-height:1.35;overflow-wrap:break-word;}
.ct-aid-card .ct-aid-rewards {grid-column:1 / -1;grid-row:2;display:flex;justify-content:center;align-items:center;gap:24px;}
.ct-aid-card .ct-aid-reward {display:flex;flex-direction:column;align-items:center;gap:4px;min-width:76px;}
.ct-aid-card .ct-aid-reward img {width:52px;height:52px;object-fit:contain;}
.ct-aid-card .ct-aid-reward strong {font-size:17px;font-weight:700;color:#ffda82;}
.ct-aid-card .ct-actions {grid-column:1 / -1;grid-row:3;display:flex;flex-wrap:nowrap;justify-content:space-between;width:100%;gap:8px;}
.ct-aid-card .ct-actions .ct-button {flex:1 1 0;min-width:0;align-self:stretch;padding:8px 6px;font-size:clamp(12px,3.5vw,16px);text-align:center;white-space:normal;}
@media(max-width:400px) {
  .ct-aid-card {grid-template-columns:96px minmax(0,1fr);gap:7px 9px;padding:11px 12px;}
  .ct-aid-card .ct-cat {width:96px;height:138px;}
  .ct-aid-card .ct-copy > p {font-size:15px;}
  .ct-aid-card .ct-aid-reward img {width:44px;height:44px;}
}
/* Training finale: big mentor on top, three picture-first rewards, full-width buttons. */
.ct-final-card {
  display:grid;
  grid-template-columns:112px minmax(0,1fr);
  align-items:start;
  gap:9px 12px;
  padding:12px 14px;
  max-height:min(76vh,420px);
  overflow-y:auto;
}
.ct-final-card .ct-cat {
  grid-column:1;
  grid-row:1;
  width:112px;
  height:152px;
  align-self:start;
  object-position:center top;
}
.ct-final-card .ct-copy {display:contents;}
.ct-final-card .ct-copy > p {
  grid-column:2;
  grid-row:1;
  align-self:center;
  font-size:17px;
  line-height:1.35;
  overflow-wrap:break-word;
}
.ct-final-card .ct-final-rewards {
  grid-column:1 / -1;
  grid-row:2;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  align-items:center;
  gap:12px;
  padding:8px 4px;
  background:rgba(8,20,37,.65);
  border:1px solid #425471;
  border-radius:10px;
}
.ct-final-card .ct-final-reward {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:5px;
  min-width:0;
  text-align:center;
}
.ct-final-card .ct-final-reward img {
  display:block;
  width:52px;
  height:52px;
  object-fit:contain;
}
.ct-final-card .ct-final-reward strong {
  color:#ffda82;
  font-size:18px;
  font-weight:700;
}
.ct-final-card .ct-actions {
  grid-column:1 / -1;
  grid-row:3;
  display:flex;
  flex-wrap:nowrap;
  width:100%;
  gap:8px;
  justify-content:space-between;
}
.ct-final-card .ct-actions .ct-button {
  flex:1 1 0;
  min-width:0;
  align-self:stretch;
  padding:8px 6px;
  font-size:clamp(12px,3.5vw,16px);
  text-align:center;
  white-space:normal;
}
.ct-complete-card .ct-actions {grid-row:2;}
@media(max-width:400px) {
  .ct-final-card {grid-template-columns:96px minmax(0,1fr);gap:7px 9px;padding:11px 12px;}
  .ct-final-card .ct-cat {width:96px;height:138px;}
  .ct-final-card .ct-copy > p {font-size:15px;}
  .ct-final-card .ct-final-reward img {width:44px;height:44px;}
}
.ct-progress {font-size:11px;color:#c2a879;}
/* Class-explanation dialogs only: centered, symmetric 20px gutters, one scroll area. */
#roleModal.ct-class-info-modal {
  box-sizing:border-box;
  padding:20px;
  align-items:center;
  justify-content:center;
}
#roleModal.ct-class-info-modal .modal-content {
  box-sizing:border-box;
  width:100%;
  max-width:500px;
  height:640px;
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
  margin:auto;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
#roleModal.ct-class-info-modal .modal-header {
  flex:0 0 auto;
}
#roleModal.ct-class-info-modal .modal-body {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  overflow-y:auto;
  overscroll-behavior:contain;
}
/* Role selector in the three class descriptions; mirrors main-screen icon + label. */
#roleModal.ct-class-info-modal .ct-class-role-options {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
  margin:12px 0 14px;
}
#roleModal.ct-class-info-modal .ct-class-role-choice {
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:6px;
  min-width:0;
  padding:9px 4px 7px;
  border:0;
  border-radius:11px;
  background:transparent;
  color:#a7acb8;
  font:inherit;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
#roleModal.ct-class-info-modal .ct-class-role-icon {
  display:flex;
  align-items:center;
  justify-content:center;
  width:60px;
  height:60px;
  max-width:100%;
  position:relative;
}
#roleModal.ct-class-info-modal .ct-class-role-icon::before {
  content:'';
  position:absolute;
  inset:-15px;
  border-radius:50%;
  background:radial-gradient(circle,var(--ct-role-accent,#00aaff) 0%,transparent 70%);
  opacity:0;
  transform:scale(.8);
  transition:opacity .3s ease,transform .3s ease;
  pointer-events:none;
}
#roleModal.ct-class-info-modal .ct-class-role-icon img {
  width:60px;
  height:60px;
  max-width:100%;
  object-fit:contain;
  position:relative;
  z-index:1;
  filter:grayscale(1) opacity(.45);
  transition:filter .2s ease,transform .2s ease;
}
#roleModal.ct-class-info-modal .ct-class-role-name {
  display:block;
  width:100%;
  text-align:center;
  font-size:12px;
  line-height:1.2;
  overflow-wrap:break-word;
}
#roleModal.ct-class-info-modal .ct-class-role-choice.is-active {
  color:#fff;
}
#roleModal.ct-class-info-modal .ct-class-role-choice.is-active .ct-class-role-icon::before {
  opacity:.65;
  transform:scale(1);
}
#roleModal.ct-class-info-modal .ct-class-role-choice.is-active img {
  filter:none;
  transform:scale(1.08);
}
#roleModal.ct-class-info-modal .ct-class-role-choice:focus-visible {
  outline:2px solid #ffdf8f;
  outline-offset:2px;
}
#roleModal.ct-class-info-modal .ct-class-role-description .role-card {
  margin-bottom:0;
}
@media(max-width:400px) {
  #roleModal.ct-class-info-modal .ct-class-role-options {gap:4px;}
  #roleModal.ct-class-info-modal .ct-class-role-choice {padding:7px 2px 5px;}
  #roleModal.ct-class-info-modal .ct-class-role-icon,
  #roleModal.ct-class-info-modal .ct-class-role-icon img {width:48px;height:48px;}
  #roleModal.ct-class-info-modal .ct-class-role-name {font-size:11px;}
}
/* Welcome dialog: cat above the copy, rewards and buttons use the entire width. */
.ct-modal .ct-welcome {
  display:grid;
  grid-template-columns:minmax(65px,92px) minmax(0,1fr);
  column-gap:10px;
  row-gap:10px;
  align-items:start;
}
.ct-modal .ct-welcome .ct-cat {
  grid-column:1;
  grid-row:1;
  align-self:start;
  transform:translateY(-6px);
}
.ct-modal .ct-welcome .ct-copy {
  grid-column:2;
  grid-row:1;
}
.ct-modal .ct-welcome .ct-welcome-rewards {
  grid-column:1 / -1;
  grid-row:2;
}
.ct-modal .ct-welcome .ct-actions {
  grid-column:1 / -1;
  grid-row:3;
  display:flex;
  flex-wrap:nowrap;
  gap:8px;
  width:100%;
  justify-content:space-between;
}
.ct-modal .ct-welcome .ct-actions .ct-button {
  flex:1 1 0;
  min-width:0;
  padding:9px 5px;
  font-size:clamp(12px,3.5vw,16px);
  text-align:center;
  white-space:nowrap;
}
.ct-modal .ct-welcome #ctAccept {
  flex-grow:1.35;
}

@media(max-width:400px){.ct-cat {width:60px;height:87px}.ct-card{padding:10px;gap:8px}.ct-copy{font-size:15px}.ct-pointer{width:56px;height:56px}}
@media(max-height:530px){.ct-card{max-height:46vh}.ct-cat{height:75px;width:56px}}

/* Shared mentor-dialog template: image | narration, reward row, two equal buttons.
   Used by every tutorial card (including welcome); unrelated game modals are excluded.
   Earlier step-specific styles remain as fallbacks and are overridden here. */
.ct-card.ct-dialog-layout {
  display:grid;
  grid-template-columns:clamp(82px,25vw,112px) minmax(0,1fr);
  grid-auto-rows:auto;
  align-items:start;
  gap:10px 12px;
  padding:13px 14px;
  max-height:min(55vh,330px);
  max-height:min(55dvh,330px);
  overflow-y:auto;
  overscroll-behavior:contain;
}
.ct-card.ct-dialog-layout.ct-gift-card,
.ct-card.ct-dialog-layout.ct-aid-card,
.ct-card.ct-dialog-layout.ct-final-card {
  max-height:min(78vh,430px);
  max-height:min(78dvh,430px);
}
.ct-modal .ct-card.ct-dialog-layout {
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
}
.ct-card.ct-dialog-layout > .ct-cat,
.ct-modal .ct-card.ct-dialog-layout > .ct-cat {
  grid-column:1;
  grid-row:1;
  width:100%;
  height:148px;
  max-width:112px;
  align-self:start;
  justify-self:center;
  object-fit:contain;
  object-position:center top;
  transform:none;
}
.ct-card.ct-dialog-layout > .ct-copy {
  display:contents;
}
.ct-card.ct-dialog-layout > .ct-copy > p {
  grid-column:2;
  grid-row:1;
  min-width:0;
  margin:0;
  align-self:start;
  font-size:17px;
  line-height:1.4;
  white-space:pre-line;
  overflow-wrap:anywhere;
}
.ct-card.ct-dialog-layout .ct-gift-preview,
.ct-card.ct-dialog-layout .ct-aid-rewards,
.ct-card.ct-dialog-layout .ct-final-rewards,
.ct-card.ct-dialog-layout .ct-welcome-rewards {
  grid-column:1 / -1;
  grid-row:auto;
  width:100%;
  min-width:0;
  box-sizing:border-box;
  margin:0;
  padding:9px 6px;
  background:rgba(8,20,37,.65);
  border:1px solid #425471;
  border-radius:10px;
}
.ct-card.ct-dialog-layout .ct-actions {
  grid-column:1 / -1;
  grid-row:auto;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  align-items:stretch;
  justify-content:stretch;
  flex-wrap:nowrap;
  gap:8px;
  width:100%;
  box-sizing:border-box;
  margin:0;
  padding-top:10px;
  border-top:1px solid rgba(217,168,86,.25);
}
.ct-card.ct-dialog-layout .ct-actions > .ct-button {
  display:block;
  flex:none;
  width:100%;
  min-width:0;
  box-sizing:border-box;
  margin:0;
  padding:9px 6px;
  align-self:stretch;
  font-size:clamp(12px,3.5vw,16px);
  line-height:1.25;
  text-align:center;
  white-space:normal;
  overflow-wrap:break-word;
}
.ct-card.ct-dialog-layout .ct-actions > .ct-button:only-child {
  grid-column:1 / -1;
}
@media (max-width:400px) {
  .ct-card.ct-dialog-layout {
    grid-template-columns:90px minmax(0,1fr);
    gap:8px 9px;
    padding:11px 12px;
  }
  .ct-card.ct-dialog-layout > .ct-cat,
  .ct-modal .ct-card.ct-dialog-layout > .ct-cat {
    height:128px;
    max-width:90px;
  }
  .ct-card.ct-dialog-layout > .ct-copy > p {
    font-size:15px;
    line-height:1.38;
  }
}
@media (max-height:530px) {
  .ct-card.ct-dialog-layout > .ct-cat,
  .ct-modal .ct-card.ct-dialog-layout > .ct-cat {
    height:80px;
  }
  .ct-card.ct-dialog-layout {
    max-height:calc(100dvh - 28px);
  }
  .ct-card.ct-dialog-layout.ct-gift-card,
  .ct-card.ct-dialog-layout.ct-aid-card,
  .ct-card.ct-dialog-layout.ct-final-card {
    max-height:calc(100dvh - 28px);
  }
}

/* Welcome rewards only: icons and counts, with no group or cell backgrounds. */
.ct-modal .ct-welcome.ct-dialog-layout .ct-welcome-rewards {
  background:transparent;
  border:0;
  box-shadow:none;
  padding:0;
}
.ct-modal .ct-welcome.ct-dialog-layout .ct-welcome-reward {
  background:transparent;
  border:0;
  box-shadow:none;
  padding:0;
}


/* Uniform transparent tutorial rewards. Backpack item slots keep their own frame. */
.ct-card.ct-dialog-layout .ct-gift-preview,
.ct-card.ct-dialog-layout .ct-aid-rewards,
.ct-card.ct-dialog-layout .ct-final-rewards,
.ct-card.ct-dialog-layout .ct-welcome-rewards {
  background:transparent;
  border:0;
  box-shadow:none;
  padding:0;
}
.ct-card.ct-dialog-layout .ct-aid-reward,
.ct-card.ct-dialog-layout .ct-final-reward,
.ct-card.ct-dialog-layout .ct-welcome-reward {
  background:transparent;
  border:0;
  box-shadow:none;
  padding:0;
}

/* Center reward icons as a compact group instead of stretching them edge-to-edge. */
.ct-card.ct-dialog-layout .ct-welcome-rewards,
.ct-card.ct-dialog-layout .ct-final-rewards {
  grid-template-columns:repeat(3,minmax(0,70px));
  justify-content:center;
  column-gap:12px;
}
.ct-card.ct-dialog-layout .ct-aid-rewards {
  gap:12px;
}
.ct-card.ct-dialog-layout .ct-aid-reward {
  min-width:64px;
}

/* Welcome: centered game title on its own line, with mentor intro below. */
.ct-modal .ct-welcome.ct-dialog-layout > .ct-copy > .ct-welcome-greeting {
  grid-column:2;
  grid-row:1;
  align-self:center;
}
.ct-modal .ct-welcome.ct-dialog-layout > .ct-copy > .ct-welcome-game-title {
  grid-column:1 / -1;
  grid-row:2;
  justify-self:center;
  width:100%;
  text-align:center;
  font-size:clamp(23px,6vw,31px);
  font-weight:800;
  letter-spacing:.04em;
  line-height:1.15;
  color:#f5cc7b;
  text-shadow:0 0 12px rgba(238,178,71,.5),0 2px 2px rgba(0,0,0,.75);
}
.ct-modal .ct-welcome.ct-dialog-layout > .ct-copy > .ct-welcome-description {
  grid-column:1 / -1;
  grid-row:3;
  line-height:1.4;
  white-space:pre-line;
}
.ct-modal .ct-welcome.ct-dialog-layout > .ct-copy > .ct-welcome-description strong {
  color:#f5d291;
}
.ct-modal .ct-welcome.ct-dialog-layout .ct-welcome-rewards {grid-row:4;}
.ct-modal .ct-welcome.ct-dialog-layout .ct-actions {grid-row:5;}
