/* Mystery Word — casual event game UI (mobile-first) */

:root {
  --mw-bg0: #071820;
  --mw-bg1: #0e2f3d;
  --mw-bg2: #16485a;
  --mw-ink: #f4fbfc;
  --mw-muted: #9fc0cb;
  --mw-coral: #ff6b4a;
  --mw-gold: #ffd166;
  --mw-mint: #4ecdc4;
  --mw-sky: #7bdff2;
  --mw-panel: rgba(10, 36, 48, 0.72);
  --mw-panel-solid: #102a36;
  --mw-stroke: rgba(255, 255, 255, 0.14);
  --mw-glow: rgba(78, 205, 196, 0.35);
  --mw-radius: 22px;
  --mw-font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --mw-font-body: "Nunito", "Segoe UI", sans-serif;
  --mw-safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--mw-bg0);
  color: var(--mw-ink);
  font-family: var(--mw-font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.mw-hidden {
  display: none !important;
}

/* ── Atmosphere ─────────────────────────────────── */
.mw-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(78, 205, 196, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(255, 107, 74, 0.18), transparent 50%),
    linear-gradient(165deg, var(--mw-bg0), var(--mw-bg1) 45%, var(--mw-bg2));
}

.mw-scene__art {
  position: absolute;
  inset: 0;
  background-image: image-set(
    url("../assets/lobby-bg.webp") type("image/webp"),
    url("../assets/lobby-bg.jpg") type("image/jpeg")
  );
  background-size: cover;
  background-position: center;
  opacity: 0.42;
  transform: scale(1.04);
  will-change: transform;
  animation: mw-drift 28s ease-in-out infinite alternate;
}

.mw-scene__veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 24, 32, 0.35) 0%, rgba(7, 24, 32, 0.78) 70%, rgba(7, 24, 32, 0.92) 100%);
}

.mw-float-letters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.mw-float-letters span {
  position: absolute;
  font-family: var(--mw-font-display);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.08);
  animation: mw-float-up linear infinite;
  user-select: none;
}

@keyframes mw-drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.08) translate3d(-1.5%, 1%, 0); }
}

@keyframes mw-float-up {
  0% { transform: translate3d(0, 110vh, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate3d(10px, -20vh, 0) rotate(28deg); opacity: 0; }
}

/* ── Shell ──────────────────────────────────────── */
#mw-app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.mw-screen {
  flex: 1;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 20px 18px calc(28px + var(--mw-safe-bottom));
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: mw-screen-in 0.45s ease both;
}

.mw-screen.is-active {
  display: flex;
}

@keyframes mw-screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.mw-brand {
  text-align: center;
  margin-top: 8px;
}

.mw-brand__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mw-mint);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mw-brand__title {
  margin: 6px 0 0;
  font-family: var(--mw-font-display);
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff 10%, var(--mw-gold) 45%, var(--mw-coral) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 40px rgba(255, 209, 102, 0.15);
}

.mw-brand__tag {
  margin: 10px auto 0;
  max-width: 22rem;
  color: var(--mw-muted);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
}

.mw-panel {
  background: var(--mw-panel);
  border: 1px solid var(--mw-stroke);
  border-radius: var(--mw-radius);
  padding: 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.mw-panel--glow {
  box-shadow:
    0 0 0 1px rgba(78, 205, 196, 0.18),
    0 18px 50px rgba(0, 0, 0, 0.28),
    0 0 40px var(--mw-glow);
}

.mw-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mw-muted);
}

.mw-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.mw-input {
  width: 100%;
  border: 1px solid var(--mw-stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--mw-ink);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.mw-input:focus {
  border-color: var(--mw-mint);
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
  background: rgba(255, 255, 255, 0.09);
}

.mw-input::placeholder {
  color: rgba(159, 192, 203, 0.55);
}

.mw-avatar-chip {
  flex: 0 0 auto;
  width: 48px;
  border-radius: 14px;
  border: 1px solid var(--mw-stroke);
  display: grid;
  place-items: center;
  font-family: var(--mw-font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #071820;
}

.mw-btn {
  appearance: none;
  border: none;
  border-radius: 16px;
  padding: 15px 18px;
  font-family: var(--mw-font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  user-select: none;
}

.mw-btn:active {
  transform: scale(0.97);
}

.mw-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.mw-btn--primary {
  width: 100%;
  color: #071820;
  background: linear-gradient(135deg, var(--mw-gold), var(--mw-coral));
  box-shadow: 0 10px 28px rgba(255, 107, 74, 0.35);
}

.mw-btn--primary:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 12px 32px rgba(255, 107, 74, 0.45);
}

.mw-btn--ghost {
  width: 100%;
  color: var(--mw-ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--mw-stroke);
}

.mw-btn--mint {
  color: #071820;
  background: linear-gradient(135deg, var(--mw-mint), var(--mw-sky));
  box-shadow: 0 10px 24px rgba(78, 205, 196, 0.28);
}

.mw-btn-row {
  display: grid;
  gap: 10px;
}

.mw-error {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 107, 74, 0.12);
  border: 1px solid rgba(255, 107, 74, 0.35);
  color: #ffb4a2;
  font-size: 0.9rem;
  font-weight: 700;
}

.mw-error.is-visible {
  display: block;
  animation: mw-shake 0.35s ease;
}

@keyframes mw-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* How to play */
.mw-howto {
  display: grid;
  gap: 10px;
}

.mw-howto__title {
  margin: 0 0 2px;
  font-family: var(--mw-font-display);
  font-size: 1.15rem;
}

.mw-howto__grid {
  display: grid;
  gap: 10px;
}

@media (min-width: 640px) {
  .mw-howto__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mw-step {
  position: relative;
  overflow: hidden;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--mw-stroke);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.mw-step:hover {
  transform: translateY(-2px);
  border-color: rgba(78, 205, 196, 0.45);
}

.mw-step svg {
  width: 42px;
  height: 42px;
  margin-bottom: 8px;
}

.mw-step h3 {
  margin: 0 0 4px;
  font-family: var(--mw-font-display);
  font-size: 1rem;
}

.mw-step p {
  margin: 0;
  color: var(--mw-muted);
  font-size: 0.88rem;
  line-height: 1.35;
  font-weight: 600;
}

.mw-join-extra {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mw-code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-align: center;
  font-family: var(--mw-font-display);
  font-size: 1.2rem;
}

/* Waiting */
.mw-wait-hero {
  text-align: center;
}

.mw-pulse-ring {
  width: 88px;
  height: 88px;
  margin: 8px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: radial-gradient(circle at 30% 30%, var(--mw-mint), var(--mw-coral));
  font-family: var(--mw-font-display);
  font-size: 1.6rem;
  color: #071820;
  box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.5);
  animation: mw-pulse 1.8s ease-out infinite;
}

@keyframes mw-pulse {
  0% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.45); }
  70% { box-shadow: 0 0 0 22px rgba(78, 205, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0); }
}

.mw-count-big {
  font-family: var(--mw-font-display);
  font-size: clamp(2.5rem, 12vw, 3.4rem);
  line-height: 1;
  margin: 0;
}

.mw-wait-sub {
  color: var(--mw-muted);
  font-weight: 700;
  margin: 6px 0 0;
}

.mw-room-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.12);
  border: 1px dashed rgba(255, 209, 102, 0.45);
  color: var(--mw-gold);
  font-family: var(--mw-font-display);
  letter-spacing: 0.18em;
}

.mw-tip {
  min-height: 3.2rem;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--mw-sky);
  font-weight: 700;
  transition: opacity 0.35s ease;
}

.mw-players-sample {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.mw-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--mw-stroke);
  font-size: 0.85rem;
  font-weight: 800;
  animation: mw-pop 0.35s ease both;
}

.mw-pill__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: #071820;
}

@keyframes mw-pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

/* Gameplay */
.mw-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mw-stat {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--mw-stroke);
  min-width: 88px;
  text-align: center;
}

.mw-stat__label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mw-muted);
  font-weight: 800;
}

.mw-stat__value {
  font-family: var(--mw-font-display);
  font-size: 1.25rem;
}

.mw-stat--timer {
  flex: 1 1 auto;
  max-width: 220px;
  padding: 12px 16px;
  background: linear-gradient(160deg, rgba(255, 209, 102, 0.22), rgba(78, 205, 196, 0.14));
  border: 2px solid rgba(255, 209, 102, 0.65);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.25);
}

.mw-timer-clock {
  font-size: clamp(1.75rem, 7vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  color: #ffd166;
  font-variant-numeric: tabular-nums;
}

.mw-stat--timer.is-urgent,
#mw-timer-wrap.is-urgent {
  border-color: rgba(255, 107, 74, 0.85);
  box-shadow: 0 0 28px rgba(255, 107, 74, 0.45);
  background: linear-gradient(160deg, rgba(255, 107, 74, 0.28), rgba(255, 159, 28, 0.12));
}

.mw-stat--timer.is-urgent .mw-timer-clock,
#mw-timer-text.is-urgent {
  color: #ff6b4a;
  animation: mw-timer-pulse 0.7s ease-in-out infinite;
}

@keyframes mw-timer-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.06);
  }
}

.mw-timer-wrap {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mw-timer-bar {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mw-mint), var(--mw-gold), var(--mw-coral));
  transform-origin: left center;
  transition: transform 0.2s linear;
}

#mw-timer-wrap.is-urgent .mw-timer-bar {
  background: linear-gradient(90deg, #ff9f1c, #ff6b4a, #f72585);
}

.mw-timer-remain {
  position: relative;
  z-index: 1;
  font-family: var(--mw-font-display);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #071820;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

#mw-timer-wrap.is-urgent .mw-timer-remain {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.mw-category {
  text-align: center;
  color: var(--mw-mint);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.mw-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px 0 4px;
}

.mw-tile {
  width: clamp(34px, 8vw, 48px);
  height: clamp(44px, 10vw, 58px);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--mw-font-display);
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  font-weight: 700;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  animation: mw-tile-in 0.4s ease both;
}

.mw-tile.is-blank {
  color: rgba(255, 255, 255, 0.28);
}

.mw-tile.is-lit {
  color: #071820;
  background: linear-gradient(160deg, var(--mw-gold), #ffe29a);
  border-color: transparent;
}

@keyframes mw-tile-in {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.mw-hint {
  min-height: 2.6rem;
  text-align: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.22);
  color: var(--mw-gold);
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.mw-hint.is-visible {
  opacity: 1;
  transform: none;
}

.mw-feedback {
  text-align: center;
  min-height: 1.5rem;
  font-family: var(--mw-font-display);
  font-size: 1.15rem;
  transition: transform 0.2s ease, color 0.2s ease;
}

.mw-feedback.is-correct { color: var(--mw-mint); animation: mw-pop 0.35s ease; }
.mw-feedback.is-wrong { color: var(--mw-coral); }
.mw-feedback.is-almost { color: var(--mw-gold); }
.mw-feedback.is-lost { color: var(--mw-coral); font-size: 1.35rem; }

/* Letter keypad */
.mw-keypad-wrap {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.mw-keypad {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  touch-action: manipulation;
}

.mw-key {
  appearance: none;
  border: none;
  cursor: pointer;
  width: clamp(46px, 11vw, 58px);
  height: clamp(46px, 11vw, 58px);
  border-radius: 16px;
  font-family: var(--mw-font-display);
  font-size: clamp(1.15rem, 4.5vw, 1.45rem);
  font-weight: 700;
  color: #071820;
  background: linear-gradient(160deg, #ffd166, #ff9f1c);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  animation: mw-bob 2.8s ease-in-out infinite;
  transition: transform 0.12s ease, opacity 0.2s ease, filter 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mw-key:nth-child(3n) {
  background: linear-gradient(160deg, #4ecdc4, #7bdff2);
}
.mw-key:nth-child(3n + 1) {
  background: linear-gradient(160deg, #ff6b4a, #ff9f1c);
  color: #fff;
}
.mw-key:nth-child(3n + 2) {
  background: linear-gradient(160deg, #80ed99, #4ecdc4);
}

.mw-key:active:not(:disabled) {
  transform: scale(0.92);
}

.mw-key:disabled,
.mw-key.is-used {
  opacity: 0.25;
  filter: grayscale(0.5);
  pointer-events: none;
  animation: none;
}

.mw-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.mw-undo-btn,
.mw-hint-btn {
  width: auto;
  min-width: 120px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.mw-key.is-hint {
  position: relative;
  z-index: 4;
  color: #071820 !important;
  background: linear-gradient(160deg, #ffe08a, #ffd166 45%, #ff9f1c) !important;
  border: 3px solid #fff !important;
  box-shadow:
    0 0 0 4px rgba(255, 209, 102, 0.55),
    0 0 28px rgba(255, 209, 102, 0.95),
    0 8px 18px rgba(0, 0, 0, 0.35);
  transform: scale(1.12);
}

.mw-key.is-blink {
  animation: mw-key-blink 0.5s ease-in-out infinite;
  z-index: 5;
}

@keyframes mw-key-blink {
  0%,
  100% {
    transform: scale(1.1);
    filter: brightness(1.05);
  }
  50% {
    transform: scale(1.22);
    filter: brightness(1.35);
  }
}

.mw-next-countdown {
  font-family: var(--mw-font-display);
  font-size: 1.15rem;
  color: var(--mw-gold) !important;
}

.mw-tile.is-fill {
  color: #071820;
  background: linear-gradient(160deg, var(--mw-mint), #7bdff2);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(78, 205, 196, 0.45);
}

.mw-tile.is-target {
  outline: 2px solid rgba(255, 209, 102, 0.7);
  outline-offset: 2px;
}

.mw-fly-letter {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--mw-font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: #071820;
  background: linear-gradient(160deg, #ffd166, #ff9f1c);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.42s ease;
  will-change: transform, opacity;
}

@keyframes mw-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* Win / Lose overlay */
.mw-outcome {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(7, 24, 32, 0.55);
  backdrop-filter: blur(5px);
  pointer-events: none;
  animation: mw-screen-in 0.3s ease;
}

.mw-outcome__card {
  pointer-events: none;
  text-align: center;
  padding: 28px 32px;
  border-radius: 24px;
  border: 1px solid var(--mw-stroke);
  background: var(--mw-panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  min-width: min(280px, 86vw);
}

.mw-outcome__card.is-win {
  border-color: rgba(78, 205, 196, 0.5);
  box-shadow: 0 0 40px rgba(78, 205, 196, 0.25);
}

.mw-outcome__card.is-lose {
  border-color: rgba(255, 107, 74, 0.5);
  box-shadow: 0 0 40px rgba(255, 107, 74, 0.2);
}

.mw-outcome__title {
  font-family: var(--mw-font-display);
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.mw-outcome__card.is-win .mw-outcome__title { color: var(--mw-mint); }
.mw-outcome__card.is-lose .mw-outcome__title { color: var(--mw-coral); }

.mw-outcome__detail {
  margin: 0;
  color: var(--mw-muted);
  font-weight: 700;
}

.mw-level-winner-name {
  margin: 8px 0 0;
  font-family: var(--mw-font-display);
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  color: var(--mw-gold);
  text-align: center;
}

.mw-level-list {
  display: grid;
  gap: 8px;
}

.mw-level-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--mw-stroke);
  animation: mw-tile-in 0.35s ease both;
}

.mw-level-row__badge {
  padding: 6px 10px;
  border-radius: 10px;
  font-family: var(--mw-font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #071820;
  background: linear-gradient(135deg, var(--mw-gold), #ffe29a);
  white-space: nowrap;
}

.mw-level-row__name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-level-row__name.is-empty {
  color: var(--mw-muted);
  font-weight: 700;
}

.mw-level-row.is-latest {
  border-color: rgba(255, 209, 102, 0.55);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.15);
}

/* Real-time winner toast for everyone */
.mw-winner-toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(10, 36, 48, 0.92);
  border: 1px solid rgba(255, 209, 102, 0.45);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-family: var(--mw-font-display);
  font-size: 0.95rem;
  white-space: nowrap;
  max-width: 92vw;
  animation: mw-toast-in 0.35s ease;
}

.mw-winner-toast.is-show {
  display: flex;
}

.mw-winner-toast__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: 0 0 auto;
}

@keyframes mw-toast-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.mw-score-pop {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 40;
  pointer-events: none;
  font-family: var(--mw-font-display);
  font-size: 2rem;
  color: var(--mw-gold);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: mw-score-fly 1s ease forwards;
}

@keyframes mw-score-fly {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1); }
}

.mw-solvers {
  text-align: center;
  color: var(--mw-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Results / leaderboard */
.mw-answer-reveal {
  text-align: center;
}

.mw-answer-reveal__label {
  color: var(--mw-muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}

.mw-answer-reveal__word {
  margin: 8px 0 0;
  font-family: var(--mw-font-display);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  letter-spacing: 0.08em;
  background: linear-gradient(120deg, var(--mw-gold), var(--mw-coral));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mw-my-rank {
  text-align: center;
  padding: 14px;
  border-radius: 16px;
  background: rgba(78, 205, 196, 0.1);
  border: 1px solid rgba(78, 205, 196, 0.28);
}

.mw-my-rank strong {
  font-family: var(--mw-font-display);
  font-size: 1.4rem;
  color: var(--mw-mint);
}

.mw-board {
  display: grid;
  gap: 8px;
}

.mw-board-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--mw-stroke);
  animation: mw-tile-in 0.35s ease both;
}

.mw-board-row.is-me {
  border-color: rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.1);
}

.mw-board-rank {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--mw-font-display);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.mw-board-rank.is-1 { background: linear-gradient(135deg, #ffe29a, #ffd166); color: #071820; }
.mw-board-rank.is-2 { background: linear-gradient(135deg, #e8eef2, #b8c4cc); color: #071820; }
.mw-board-rank.is-3 { background: linear-gradient(135deg, #f0b27a, #d9884a); color: #071820; }

.mw-board-name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-board-score {
  font-family: var(--mw-font-display);
  color: var(--mw-gold);
}

.mw-board-row--race {
  grid-template-columns: 42px 1fr auto auto;
}

.mw-board-level {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--mw-mint);
  letter-spacing: 0.04em;
}

.mw-board-level.is-out {
  color: var(--mw-coral);
}

.mw-board-level.is-done {
  color: var(--mw-gold);
}

.mw-live-board {
  margin-top: 8px;
}

/* Final / podium */
.mw-final-art {
  width: min(100%, 360px);
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--mw-stroke);
  background:
    image-set(
      url("../assets/podium.webp") type("image/webp")
    ) center / cover no-repeat,
    radial-gradient(circle at 50% 30%, rgba(255, 209, 102, 0.25), transparent 55%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}

.mw-final-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(7, 24, 32, 0.75));
}

.mw-podium-list {
  display: grid;
  gap: 10px;
  margin-top: -48px;
  position: relative;
  z-index: 2;
}

.mw-podium-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: var(--mw-panel);
  border: 1px solid var(--mw-stroke);
  backdrop-filter: blur(10px);
}

.mw-podium-card.is-1 {
  border-color: rgba(255, 209, 102, 0.55);
  box-shadow: 0 0 30px rgba(255, 209, 102, 0.18);
  transform: scale(1.02);
}

.mw-podium-place {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--mw-font-display);
  font-size: 1.2rem;
  color: #071820;
}

.mw-podium-place.is-1 { background: var(--mw-gold); }
.mw-podium-place.is-2 { background: #cfd8dc; }
.mw-podium-place.is-3 { background: #d9884a; }

.mw-podium-title {
  display: block;
  color: var(--mw-mint);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mw-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.mw-confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: mw-confetti-fall linear forwards;
}

@keyframes mw-confetti-fall {
  to { transform: translateY(110vh) rotate(520deg); opacity: 0.2; }
}

/* Loading / connecting */
.mw-loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(7, 24, 32, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.mw-loading.is-on {
  opacity: 1;
  pointer-events: auto;
}

.mw-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--mw-mint);
  animation: mw-spin 0.7s linear infinite;
}

@keyframes mw-spin {
  to { transform: rotate(360deg); }
}

.mw-empty {
  text-align: center;
  color: var(--mw-muted);
  font-weight: 700;
  padding: 18px 8px;
}

.mw-host-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--mw-muted);
  font-weight: 700;
}

/* Big screen / projector friendly */
@media (min-width: 960px) {
  .mw-screen {
    width: min(880px, 100%);
    padding-top: 28px;
  }

  .mw-brand__title {
    font-size: 4rem;
  }

  .mw-tiles {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
