/* 무궁화 꽃이 피었습니다 · 눈치 스톱! */
:root {
  --mg-bg: #fdf2f8;
  --mg-surface: #ffffff;
  --mg-ink: #1e293b;
  --mg-muted: #526071;
  --mg-border: #f3d5e5;
  --mg-pink: #db2777;
  --mg-shadow: 0 12px 30px rgba(157, 23, 77, 0.1);
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--mg-bg); color: var(--mg-ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, sans-serif;
}
.mg-app { max-width: 1440px; margin: 0 auto; min-height: 100dvh; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.mg-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.mg-topbar-left, .mg-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mg-brand-title { margin: 0; font-size: 1.15rem; font-weight: 800; }

.mg-btn-ghost, .mg-btn-pill, .mg-btn-primary, .mg-btn-secondary {
  font-family: inherit; cursor: pointer; border: none; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700;
}
.mg-btn-ghost { background: #fff; color: var(--mg-ink); border: 1.5px solid var(--mg-border); border-radius: 12px; padding: 8px 13px; font-size: 0.92rem; min-height: 40px; }
.mg-btn-sm { padding: 7px 12px; font-size: 0.88rem; }
.mg-btn-pill { background: #fff; color: var(--mg-ink); border: 1.5px solid var(--mg-border); border-radius: 999px; padding: 7px 13px; font-size: 0.88rem; min-height: 38px; }
.mg-btn-share { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.mg-btn-primary {
  background: linear-gradient(135deg, #ec4899, #be185d); color: #fff;
  border-radius: 16px; padding: 14px 28px; font-size: 1.05rem; font-weight: 800;
  box-shadow: 0 8px 20px rgba(190, 24, 93, 0.28);
}
.mg-btn-secondary { background: #f1f5f9; color: var(--mg-ink); border: 1.5px solid #cbd5e1; border-radius: 14px; padding: 12px 20px; font-size: 0.96rem; }
.mg-screen[hidden], .mg-modal-backdrop[hidden], .mg-controls[hidden] { display: none !important; }

/* Lobby */
.mg-lobby-card { background: #fff; border: 2px solid var(--mg-border); border-radius: 26px; padding: 22px; box-shadow: var(--mg-shadow); }
.mg-hero { display: grid; grid-template-columns: minmax(260px, 1.05fr) 1fr; gap: 22px; align-items: center; }
.mg-hero-media { border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; background: #fce7f3; }
.mg-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-hero-copy { display: flex; flex-direction: column; gap: 11px; align-items: flex-start; }
.mg-world-tag { background: #fce7f3; color: #9d174d; font-size: 0.84rem; font-weight: 800; padding: 5px 12px; border-radius: 999px; }
.mg-hero-heading { margin: 0; font-size: 1.55rem; line-height: 1.25; }
.mg-hero-desc { margin: 0; color: var(--mg-muted); line-height: 1.55; font-size: 0.96rem; }
.mg-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.mg-mode-card {
  font-family: inherit; cursor: pointer; text-align: left; background: #fffafc;
  border: 2px solid var(--mg-border); border-radius: 16px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.mg-mode-card.is-selected { background: #fdf2f8; border-color: var(--mg-pink); box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.14); }
.mg-mode-card strong { font-size: 1rem; color: var(--mg-ink); }
.mg-mode-card span { font-size: 0.82rem; color: var(--mg-muted); }
.mg-mode-card small { font-size: 0.78rem; font-weight: 700; color: #be185d; }
.mg-btn-start { min-width: 220px; }

/* Play */
.mg-play { display: flex; flex-direction: column; gap: 12px; }
.mg-hud {
  background: #fff; border: 2px solid var(--mg-border); border-radius: 18px;
  padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
}
.mg-hud-left, .mg-hud-right { display: flex; align-items: center; gap: 8px; }
.mg-signal-pill {
  padding: 7px 16px; border-radius: 999px; font-weight: 900; font-size: 0.96rem;
  background: #dcfce7; color: #166534; border: 2px solid #86efac;
}
.mg-signal-pill.is-warn { background: #fef9c3; color: #854d0e; border-color: #facc15; }
.mg-signal-pill.is-red { background: #fee2e2; color: #991b1b; border-color: #f87171; }
.mg-timer-pill { font-weight: 900; font-size: 1rem; font-variant-numeric: tabular-nums; padding: 6px 12px; background: #f8fafc; border-radius: 10px; border: 1.5px solid #e2e8f0; }

.mg-stage-wrap {
  position: relative; width: 100%; border-radius: 22px; overflow: hidden;
  border: 2.5px solid var(--mg-border); box-shadow: var(--mg-shadow); background: #bae6fd;
}
.mg-canvas { width: 100%; height: auto; display: block; }
.mg-chant-bubble {
  position: absolute; top: 14px; right: 20px; background: #fff;
  border: 2.5px solid #ec4899; border-radius: 18px; padding: 8px 16px;
  font-weight: 900; font-size: 1.05rem; color: #9d174d;
  box-shadow: 0 6px 16px rgba(157, 23, 77, 0.16);
}

.mg-controls { display: grid; gap: 12px; }
.mg-controls-duo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mg-hold-btn {
  font-family: inherit; cursor: pointer; border: none; border-radius: 22px;
  padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff; user-select: none; touch-action: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16); transition: transform 0.08s ease;
}
.mg-hold-btn strong { font-size: clamp(1rem, 2.8vw, 1.85rem); font-weight: 900; }
.mg-hold-btn span { font-size: 0.88rem; opacity: 0.92; font-weight: 700; }
.mg-hold-btn.is-holding { transform: scale(0.97); filter: brightness(1.08); }
.mg-hold-solo, .mg-hold-p1 { background: linear-gradient(135deg, #38bdf8, #2563eb); }
.mg-hold-p2 { background: linear-gradient(135deg, #fb923c, #ea580c); }

/* Modals */
.mg-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.mg-modal-card { width: 100%; max-width: 460px; background: #fff; border-radius: 24px; padding: 24px; box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25); }
.mg-result-card { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.mg-res-badge { background: #fce7f3; color: #9d174d; font-weight: 900; padding: 6px 14px; border-radius: 999px; }
.mg-res-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.mg-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.mg-modal-head h2 { margin: 0; font-size: 1.2rem; }
.mg-modal-close { width: 34px; height: 34px; border-radius: 50%; border: none; background: #f1f5f9; font-weight: 800; cursor: pointer; }
.mg-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; line-height: 1.55; color: #334155; }
.mg-modal-foot { display: flex; justify-content: flex-end; }
.mg-qr-desc { margin: 0 0 12px; color: var(--mg-muted); font-size: 0.92rem; }
.mg-qr-box { display: flex; justify-content: center; padding: 12px; background: #f8fafc; border-radius: 16px; margin-bottom: 12px; }
.mg-qr-url-row { display: flex; gap: 8px; }
.mg-qr-url { flex: 1; min-width: 0; border: 1.5px solid #cbd5e1; border-radius: 12px; padding: 8px 10px; font-size: 0.85rem; background: #f8fafc; }
.mg-copy-feedback { margin: 8px 0 0; min-height: 1.2em; font-size: 0.86rem; font-weight: 700; color: #059669; text-align: center; }

@media (max-width: 780px) {
  .mg-hero, .mg-mode-grid { grid-template-columns: 1fr; }
  .mg-chant-bubble { font-size: 0.88rem; padding: 6px 12px; top: 8px; right: 10px; }
}

[data-classroom-game-stage] .cg-guide-entry { display: none; }
[data-game-native-reset][data-play-native-control] { display: none; }

#modal-result { inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; padding: 0; background: transparent; }
#modal-result:not([open]) { display: none; }
#modal-result[open] { position: fixed; display: grid; place-items: center; }
#modal-result::backdrop { background: #10182791; }

.mg-setup-title { margin: 0; font-size: 1.5rem; }
.mg-mode-grid { margin-block: 8px; }
.mg-distance-pill { font-size: .9rem; font-weight: 800; color: #374151; white-space: nowrap; }
html[data-classroom-playing] .mg-app { min-height: calc(100dvh - var(--classroom-play-height)); }
.mg-stage-wrap { box-shadow: 0 14px 28px #8c38832a; }
.mg-controls { width: min(100%, 1180px); margin-inline: auto; }
.mg-hold-btn { min-height: 76px; border: 2px solid #f2f8ff; box-shadow: 0 5px 0 #1935a0; }
.mg-hold-btn:focus-visible { outline: 3px solid #371c71; outline-offset: 2px; }
@media (max-width: 540px) {
  .mg-app { padding-inline: 10px; }
  .mg-hud { justify-content: start; gap: 6px; padding: 8px; }
  .mg-signal-pill { order: 3; flex-basis: 100%; text-align: center; }
  .mg-hold-btn span { font-size: .78rem; }
  .mg-chant-bubble { top: 5px; right: 7px; padding: 4px 8px; font-size: .72rem; }
}

body.mg-body #classroom-play-toolbar h1 { overflow-wrap: normal; word-break: keep-all; }

@media (min-width: 950px) {
  .mg-signal-pill { font-size: 1.2rem; }
  .mg-distance-pill, .mg-timer-pill { font-size: 1rem; }
}
