/* =========================================================
   SHADOW REALM -- gray smoke punishment
   ========================================================= */

/* ---- everyone: a subtle 3.4-second passage into the Realm ---- */
.srealm-flicker {
  position: fixed;
  inset: 0;
  z-index: 2147483050;
  pointer-events: none;
  overflow: hidden;
  display: grid;
  place-items: center;
  backdrop-filter: grayscale(.72) contrast(.94) brightness(.88);
  -webkit-backdrop-filter: grayscale(.72) contrast(.94) brightness(.88);
  animation: srealm-storm 3.4s ease-in-out forwards;
}
/* One soft dim, no strobing flashes, then an unhurried clear. */
@keyframes srealm-storm {
  0% { background: rgba(30, 32, 38, 0); opacity: 0; }
  16% { background: rgba(38, 40, 47, .34); opacity: 1; }
  72% { background: rgba(45, 47, 54, .4); opacity: .92; }
  100% { background: rgba(45, 47, 54, 0); opacity: 0; }
}
.srealm-cloud { position: absolute; inset: 0; }
.srealm-cloud i {
  position: absolute;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 40%, rgba(var(--c), var(--c), calc(var(--c) + 8), .25), transparent 42%),
    radial-gradient(circle at 62% 58%, rgba(var(--c), var(--c), calc(var(--c) + 8), .18), transparent 48%),
    radial-gradient(circle at 50% 50%, rgba(calc(var(--c) - 40), calc(var(--c) - 40), calc(var(--c) - 32), .2), rgba(90, 94, 102, .08) 58%, transparent 72%);
  filter: blur(16px);
  opacity: 0;
  animation: srealm-billow 3.4s cubic-bezier(.22, .58, .35, 1) var(--d) forwards;
}
/* Rolls in from the edge toward the middle, swelling and turning, then thins out. */
@keyframes srealm-billow {
  0% { opacity: 0; transform: translate(0, 0) scale(.55) rotate(0deg); }
  22% { opacity: .42; }
  78% { opacity: .36; transform: translate(calc(var(--dx) * .82), calc(var(--dy) * .82)) scale(1.12) rotate(calc(var(--r) * .45)); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.25) rotate(calc(var(--r) * .55)); }
}
.srealm-glyph {
  position: relative;
  max-width: 100vw;
  padding: 0 4vw;
  text-align: center;
  font: 900 clamp(1.6rem, 8vw, 7rem)/1.1 var(--font-machine, ui-monospace, monospace);
  letter-spacing: .26em;
  color: rgba(235, 238, 243, .0);
  text-shadow: 0 0 30px rgba(220, 224, 232, .0);
  animation: srealm-glyph 3.4s ease-in-out forwards;
}
@keyframes srealm-glyph {
  0%, 22% { color: rgba(235, 238, 243, 0); text-shadow: 0 0 30px rgba(220, 224, 232, 0); transform: scale(.94); }
  40%, 80% { color: rgba(235, 238, 243, .38); text-shadow: 0 0 30px rgba(220, 224, 232, .38), 0 0 70px rgba(160, 165, 175, .24); transform: scale(1); }
  100% { color: rgba(235, 238, 243, 0); text-shadow: 0 0 30px rgba(220, 224, 232, 0); transform: scale(1.06); }
}
/* Reduced motion: a steady gray haze and the glyph, no flicker or drift. */
.srealm-flicker.still { animation: srealm-still 3s ease-out forwards; }
.srealm-flicker.still .srealm-cloud i { animation: none; opacity: .35; transform: none; }
.srealm-flicker.still .srealm-glyph { animation: none; color: rgba(235, 238, 243, .5); }
@keyframes srealm-still { 0%, 75% { background: rgba(58, 61, 68, .6); opacity: 1; } 100% { opacity: 0; } }

.srealm-toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 2147483060;
  transform: translateX(-50%);
  padding: 12px 20px;
  font: 800 13px/1.3 var(--font-machine, ui-monospace, monospace);
  letter-spacing: .18em;
  color: #e8e9ec;
  text-align: center;
  background: linear-gradient(180deg, #3a3d44, #1c1d22);
  border: 1px solid #8b9099;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .6), 0 0 26px rgba(160, 165, 175, .35);
  animation: srealm-toast-in .35s ease-out;
  transition: opacity .6s, transform .6s;
  max-width: calc(100vw - 32px);
}
.srealm-toast b { color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, .6); }
.srealm-toast.out { opacity: 0; transform: translate(-50%, -8px); }
@keyframes srealm-toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }

/* ---- the banished Little Hero: veil, countdown, locked composer ---- */
.srealm-veil {
  position: fixed;
  inset: 0;
  z-index: 2147483040;
  pointer-events: none;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(60, 62, 70, .25), rgba(18, 19, 22, .62));
  backdrop-filter: grayscale(1);
  -webkit-backdrop-filter: grayscale(1);
  animation: srealm-veil-in .6s ease-out;
  transition: opacity .6s;
}
.srealm-veil.out { opacity: 0; }
.srealm-smoke {
  position: absolute;
  inset: auto -20% -25% -20%;
  height: 70%;
  background:
    radial-gradient(ellipse 30% 40% at 20% 70%, rgba(190, 195, 205, .35), transparent 70%),
    radial-gradient(ellipse 35% 45% at 60% 80%, rgba(170, 175, 185, .3), transparent 70%),
    radial-gradient(ellipse 25% 35% at 85% 65%, rgba(200, 204, 212, .3), transparent 70%);
  filter: blur(14px);
  animation: srealm-drift 7s ease-in-out infinite alternate;
}
.srealm-smoke.two { animation-duration: 9s; animation-direction: alternate-reverse; opacity: .8; }
.srealm-banner {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 18px 26px;
  text-align: center;
  font-family: var(--font-machine, ui-monospace, monospace);
  color: #eef0f3;
  background: rgba(24, 25, 29, .82);
  border: 1px solid #8b9099;
  box-shadow: 0 0 40px rgba(170, 175, 185, .3);
}
.srealm-seal { position:relative; width:150px; height:150px; display:grid; place-items:center; margin-bottom:22px; border-radius:50%; background:conic-gradient(from -90deg,#d7d9df 0 var(--realm-progress,360deg),rgba(97,101,111,.16) var(--realm-progress,360deg) 360deg); box-shadow:0 0 34px rgba(177,181,190,.18); }
.srealm-seal::before { content:""; position:absolute; inset:7px; border-radius:50%; background:radial-gradient(circle,#25272d,#111216 72%); border:1px solid #747984; }
.srealm-seal>div { position:relative; z-index:1; display:grid; place-items:center; gap:2px; }
.srealm-seal b { color:#f4f5f7; font:900 2.25rem/1 var(--font-machine,ui-monospace,monospace); text-shadow:0 0 14px rgba(255,255,255,.35); }
.srealm-seal small { color:#8f949e; font:800 .48rem var(--font-machine,ui-monospace,monospace); letter-spacing:.22em; }
.srealm-banner strong { font-size: clamp(1.1rem, 3.4vw, 1.8rem); letter-spacing: .24em; text-shadow: 0 0 16px rgba(255, 255, 255, .45); }
.srealm-banner span { font-size: 13px; letter-spacing: .2em; color: #b8bcc4; }
.srealm-banner b { color: #fff; font-size: 16px; }
.srealm-veil.still .srealm-smoke { animation: none; }
@keyframes srealm-veil-in { from { opacity: 0; } }
@keyframes srealm-drift { from { transform: translate(-3%, 4%); } to { transform: translate(3%, -6%); } }

body.shadow-realm-silenced #chat-input,
body.shadow-realm-silenced #dmx-input,
body.shadow-realm-silenced .chat-composer-shell,
body.shadow-realm-silenced .dmx-compose { filter: grayscale(1); opacity: .45; pointer-events: none; }

/* ---- the punished message: gray and smoking forever ---- */
:is(.chat-message, .gm-chat-message).shadow-realmed :is(.chat-message-main, .gm-chat-message-main) {
  position: relative;
  overflow: hidden;
  filter: grayscale(1);
  background: linear-gradient(180deg, #2a2c31, #1d1e22) !important;
  border-color: #6f747d !important;
  box-shadow: 0 0 16px rgba(160, 165, 175, .18) !important;
}
:is(.chat-message, .gm-chat-message).shadow-realmed:not(#srealm-guard) :is(.chat-message-text, .gm-chat-message-text, .chat-player-name, .gm-chat-player-name) {
  color: #a4a8b0 !important;
  text-decoration: none;
}
.srealm-mark {
  display: inline-block;
  margin: 0 0 4px;
  padding: 1px 8px;
  font: 800 9.5px/1.6 var(--font-machine, ui-monospace, monospace);
  letter-spacing: .2em;
  color: #d8dbe0;
  background: rgba(60, 62, 70, .8);
  border: 1px solid #7d828b;
}
.srealm-mark i {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 30% 60% at 15% 110%, rgba(200, 204, 212, .28), transparent 70%),
    radial-gradient(ellipse 25% 55% at 55% 115%, rgba(185, 190, 200, .24), transparent 70%),
    radial-gradient(ellipse 30% 60% at 90% 110%, rgba(200, 204, 212, .26), transparent 70%);
  filter: blur(6px);
  animation: srealm-wisp 6s ease-in-out infinite alternate;
}
.srealm-return-mark { display:inline-flex; align-items:center; gap:7px; margin:0 0 5px; padding:2px 9px; border:1px solid #8c82ad; color:#ddd5f4; background:linear-gradient(90deg,rgba(68,55,91,.9),rgba(33,31,42,.85)); font:800 9.5px/1.6 var(--font-machine,ui-monospace,monospace); letter-spacing:.18em; box-shadow:0 0 13px rgba(146,117,202,.2); }
.srealm-return-mark i { width:7px; height:7px; border-radius:50%; background:#c1a8ef; box-shadow:0 0 8px #9f7eda; }
:is(.chat-message,.gm-chat-message).shadow-returned :is(.chat-message-main,.gm-chat-message-main) { border-color:#74688f!important; box-shadow:0 0 15px rgba(147,116,196,.16)!important; }
.srealm-release-toast { border-color:#75698f; background:linear-gradient(180deg,#302a3d,#19171f); }
@keyframes srealm-wisp { from { transform: translateY(8%); opacity: .7; } to { transform: translateY(-14%); opacity: 1; } }

/* GM menu entry */
.gm-chat-context-menu .gm-chat-shadow-realm-action { color: #d8dbe0; }
.gm-chat-context-menu .gm-chat-shadow-realm-action:hover { background: rgba(120, 125, 135, .25); }
.gm-chat-context-menu .gm-chat-shadow-realm-release { color:#d8caef; }

@media (prefers-reduced-motion: reduce) {
  .srealm-smoke, .srealm-mark i { animation: none !important; }
}
