/* Multiplayer widget styles - theme aware via CSS variables from host game
   Compact card in widget-rail + floating expand panel
   Uses only CSS custom properties: --accent, --accent-2, --ink, --muted, --card, --bg, --border
*/

/* ===== Compact card in widget-rail (same style as hits/ko-fi) ===== */
.mg-mp-card {
  --mp-w: 268px;
  width: var(--mp-w);
  flex: 0 0 auto;
  min-height: 76px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 13px 15px;
  box-shadow: 0 24px 70px rgba(58, 68, 130, 0.14), 0 2px 8px rgba(58, 68, 130, 0.06);
  color: var(--ink);
  position: relative;
  overflow: hidden;
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
  user-select: none;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.mg-mp-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120px 80px at 92% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(120px 80px at -10% 118%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%);
  pointer-events: none;
}
.mg-mp-card > * { position: relative; }
.mg-mp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 22%, transparent);
}
.mg-mp-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Card header row ===== */
.mg-mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mg-mp-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
}
.mg-mp-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  flex: 0 0 auto;
  animation: mp-blink 1.6s ease-in-out infinite;
}
.mg-mp-dot.connected {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 18%, transparent);
  animation: mp-blink-green 1.6s ease-in-out infinite;
}
@keyframes mp-blink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes mp-blink-green { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.mg-mp-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== Floating panel ===== */
.mg-mp-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 340px;
  max-width: 100%;
  transform: translateX(100%);
  transition: transform 320ms ease;
  background: var(--card);
  color: var(--ink);
  z-index: 1000;
  box-shadow: -8px 0 24px rgba(0,0,0,0.12);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  font-family: inherit;
  font-size: 14px;
}
.mg-mp-panel.open { transform: translateX(0%); }

/* full screen on mobile */
@media (max-width: 767px) {
  .mg-mp-panel { width: 100%; }
}

/* ===== Panel header ===== */
.mg-mp-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.mg-mp-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.mg-mp-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color .2s ease, background .2s ease;
}
.mg-mp-close:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.mg-mp-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Tabs ===== */
.mg-mp-tabs { display: flex; gap: 0; padding: 8px 12px 0; }
.mg-mp-tab {
  flex: 1 1 0;
  background: transparent;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: color .2s ease, background .2s ease;
}
.mg-mp-tab:hover { color: var(--ink); }
.mg-mp-tab.active { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }

/* ===== Content ===== */
.mg-mp-content { padding: 12px 16px; overflow-y: auto; flex: 1 1 auto; }
.mg-mp-tab-pane { display: none; }
.mg-mp-tab-pane.active { display: block; }

.mg-mp-label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.mg-mp-input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
.mg-mp-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.mg-mp-action {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: box-shadow .25s ease, transform .2s ease;
}
.mg-mp-action:hover { transform: translateY(-1px); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 20%, transparent); }
.mg-mp-action:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.mg-mp-info { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.4; word-break: break-word; }

/* ===== HUD (shown when in a room) ===== */
.mg-mp-hud { padding: 10px 16px; border-top: 1px solid var(--border); display: none; }
.mg-mp-hud[aria-hidden="false"] { display: block; }
.mg-mp-hud-inner {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.mg-mp-turn { font-weight: 700; margin-bottom: 4px; }
.mg-mp-players { margin-bottom: 4px; }
.mg-mp-player { font-size: 12px; color: var(--muted); }
.mg-mp-state { font-size: 12px; color: var(--muted); }

/* ===== Overlay (game over) ===== */
.mg-mp-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  z-index: 5;
  visibility: hidden; opacity: 0;
  transition: opacity 200ms ease;
}
.mg-mp-overlay[aria-hidden="false"] { visibility: visible; opacity: 1; }
.mg-mp-overlay-inner {
  background: var(--card);
  padding: 16px;
  border-radius: 14px;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  text-align: center;
}
.mg-mp-overlay-text { margin-bottom: 12px; font-weight: 600; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .mg-mp-card { transition: none; }
  .mg-mp-card:hover { transform: none; }
  .mg-mp-panel { transition: none; }
  .mg-mp-action:hover { transform: none; }
}
