/* MemeWeft — built on ww2-tokens.css + the shared .btn/.input-field rules in style.css. */

body.mw {
    font-family: var(--ww-body);
    background: var(--ww-bg-0) var(--ww-surface-glow) no-repeat;
}

.mw-wrap {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(16px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.mw-wrap-wide { max-width: 640px; }

.mw-topbar { display: flex; align-items: center; justify-content: space-between; }
.mw-back {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.mw-linkbtn { background: none; border: none; cursor: pointer; padding: 0; font: inherit; }
.mw-icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

/* hero */
.mw-hero { text-align: center; padding: 18px 0 4px; }
.mw-hero-small { padding-top: 8px; }
.mw-logo { font-size: 64px; line-height: 1; filter: drop-shadow(0 8px 24px var(--ww-violet-glow)); }
.mw-wordmark {
    font-family: var(--ww-display);
    font-weight: 800;
    font-size: 44px;
    letter-spacing: -0.02em;
    margin-top: 8px;
}
.mw-wordmark span { color: var(--ww-gold); }
.mw-tagline { color: var(--text-secondary); margin-top: 4px; }

.mw-h2 { font-family: var(--ww-display); font-size: 26px; font-weight: 800; }
.mw-h3 { font-family: var(--ww-display); font-size: 17px; font-weight: 700; margin-top: 6px; }
.mw-sub, .mw-hint { color: var(--text-muted); font-size: 14px; }
.mw-dim { color: var(--text-muted); font-weight: 500; }
.mw-center { text-align: center; }
.mw-label { display: block; color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.mw-error { color: var(--ww-coral); font-size: 13px; }
.mw-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
}
.mw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* profile chip + home actions */
.mw-profile-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
}
.mw-chip-avatar { font-size: 26px; }
.mw-chip-name { flex: 1; text-align: left; font-weight: 700; }
.mw-chip-edit { color: var(--text-muted); font-size: 13px; }
.mw-actions { display: flex; flex-direction: column; gap: 12px; }
.mw-join-row { display: flex; gap: 10px; }
.mw-code-input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--ww-mono);
    font-weight: 700;
}
.mw-join-btn { padding: 0 22px; height: 52px; }
.mw-watch-btn { padding: 0 12px; height: 52px; white-space: nowrap; }
.mw-watching { font-size: 13px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.mw-watching.hidden { display: none; }
.mw-spectate { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-secondary); border: 1px dashed var(--border); color: var(--text-secondary); }
.mw-card:disabled { cursor: default; opacity: 1; }
.mw-howto {
    margin-top: 8px;
    padding: 14px 16px 14px 34px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* avatar picker */
.mw-avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.mw-avatar {
    aspect-ratio: 1;
    font-size: 22px;
    border-radius: var(--radius-xs);
    border: 2px solid transparent;
    background: var(--bg-card);
    cursor: pointer;
}
.mw-avatar.on { border-color: var(--ww-violet-400); background: var(--bg-input); }

/* lobby */
.mw-code-card {
    text-align: center;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--ww-shadow-card);
}
.mw-code-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.mw-room-code {
    font-family: var(--ww-mono);
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 0.12em;
    margin: 4px 0 10px;
    color: var(--ww-gold-soft);
}
.mw-player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.mw-player {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}
.mw-player.mw-off { opacity: 0.45; }
.mw-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mw-av { font-size: 22px; }
.mw-pname { flex: 1; font-weight: 600; }
.mw-pname em { color: var(--text-muted); font-style: normal; font-weight: 500; }
.mw-tag { font-size: 11px; font-weight: 700; color: var(--ww-gold); text-transform: uppercase; }
.mw-settings { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.mw-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mw-seg { display: inline-flex; border-radius: var(--radius-xs); overflow: hidden; border: 1px solid var(--border); }
.mw-seg button {
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    cursor: pointer;
}
.mw-seg button.on { background: var(--ww-violet-400); color: #fff; }

/* play */
.mw-play-head { display: flex; align-items: center; gap: 10px; }
.mw-phase { flex: 1; font-family: var(--ww-display); font-weight: 800; font-size: 18px; }
.mw-timer { font-family: var(--ww-mono); font-weight: 700; font-size: 18px; min-width: 3ch; text-align: right; }
.mw-timer.urgent { color: var(--ww-coral); }
.mw-timebar { height: 4px; border-radius: 4px; background: var(--bg-card); overflow: hidden; }
#mw-timebar-fill { height: 100%; width: 100%; background: var(--ww-violet-400); transition: width 0.4s linear; }

.mw-stage, .mw-gal-stage {
    position: relative;
    margin: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    box-shadow: var(--ww-shadow-raised);
}
.mw-stage img, .mw-gal-stage img {
    display: block;
    width: 100%;
    max-height: 46vh;
    object-fit: contain;
    background: #000;
}
.mw-gal-stage img { max-height: none; }
/* Classic meme lettering: white Impact with a black outline, bottom of frame. */
.mw-overlay {
    position: absolute;
    left: 4%; right: 4%; bottom: 4%;
    text-align: center;
    color: #fff;
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Anton", sans-serif;
    font-size: clamp(18px, 5.2vw, 32px);
    line-height: 1.12;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    overflow-wrap: anywhere;
    -webkit-text-stroke: 1.5px #000;
    paint-order: stroke fill;
    text-shadow: 2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000;
    pointer-events: none;
}
.mw-overlay.hidden { display: none; }

.mw-panel { display: flex; flex-direction: column; gap: 10px; }
.mw-panel.hidden { display: none; }
.mw-caption-input { resize: none; font-size: 17px; min-height: 64px; }
.mw-submit { height: 44px; padding: 0 24px; }
.mw-done { text-align: center; color: var(--ww-emerald); font-weight: 600; }

.mw-cards { display: flex; flex-direction: column; gap: 8px; }
.mw-card {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: left;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}
.mw-card:hover:not(.own):not(.revealed) { border-color: var(--ww-violet-300); }
.mw-card:focus-visible { outline: 3px solid var(--ww-violet-200); outline-offset: 2px; }
.mw-card.own { opacity: 0.55; cursor: default; }
.mw-card.chosen { border-color: var(--ww-violet-400); background: var(--bg-input); }
.mw-card.revealed { flex-direction: column; align-items: flex-start; gap: 4px; cursor: default; }
.mw-card.winner { border-color: var(--ww-gold); box-shadow: 0 0 0 3px rgba(232,166,62,0.18); }
.mw-card-letter {
    flex: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--bg-input);
    font-weight: 800; font-size: 13px;
}
.mw-card-text { flex: 1; overflow-wrap: anywhere; }
.mw-card-tag { flex: none; font-size: 12px; color: var(--text-muted); font-weight: 700; }
.mw-card-by { font-size: 13px; color: var(--text-muted); }

.mw-status { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.mw-status li {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    opacity: 0.6;
}
.mw-status li.done { opacity: 1; border-color: var(--ww-emerald); }
.mw-status li.off { opacity: 0.25; }
.mw-status li i {
    position: absolute; right: -4px; bottom: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--ww-emerald); color: #fff;
    font-size: 11px; font-style: normal; font-weight: 800;
    display: grid; place-items: center;
}
.mw-scores { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.mw-scores.hidden { display: none; }
.mw-scores li {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    font-size: 14px;
}
.mw-scores b { color: var(--ww-gold-soft); }
.mw-leave-play { align-self: center; }

/* final */
.mw-board { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.mw-board li {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}
.mw-board li.me { outline: 2px solid var(--ww-violet-400); }
.mw-board b { font-family: var(--ww-mono); font-size: 18px; color: var(--ww-gold-soft); }
.mw-rank { width: 28px; text-align: center; font-size: 20px; }
.mw-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mw-gal-item { margin: 0; }
.mw-gal-item .mw-overlay { font-size: 18px; -webkit-text-stroke: 1px #000; }
.mw-gal-by { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

.mw-toast {
    position: fixed;
    left: 50%; bottom: calc(24px + var(--safe-bottom));
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background: var(--ww-bg-3);
    color: var(--text-primary);
    box-shadow: var(--ww-shadow-raised);
    font-weight: 600;
    z-index: 50;
}
.mw-toast.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
    #mw-timebar-fill { transition: none; }
}

.mw-paused {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(232,166,62,0.12);
    border: 1px solid var(--ww-gold);
    color: var(--ww-gold-soft);
    font-weight: 600;
    font-size: 14px;
}
.mw-paused.hidden { display: none; }
.mw-tie { font-style: normal; font-size: 11px; font-weight: 700; color: var(--ww-gold); text-transform: uppercase; margin-left: 4px; }
