/* 자석글자 놀이터 '자석글자 놀이' (js/play-magnet.js) */
.mg { padding-top: 40px; padding-bottom: 48px; }
.mg-jump { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.mg-jump a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--color-line); background: #fff; color: var(--color-text); font-weight: 700; font-size: 14px; text-decoration: none; }
.mg-jump a:hover { background: var(--color-surface); }

.mg-main { display: grid; gap: 16px; }
.mg-main > * { min-width: 0; }
.mg-card { background: #fff; border: 1px solid var(--color-line); border-radius: var(--radius-card); padding: 18px; box-shadow: 0 6px 24px rgba(136, 106, 96, .08); scroll-margin-top: 90px; }
.mg-card h3 { font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.mg-card > p.sub { font-size: 14px; margin: 0 0 12px; }
.mg-red { color: #E2391F; }
.mg-blue { color: #123E93; }

/* 버튼 공통 */
.mg-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.mg-btns button, .mg-tools button { flex: 1 1 auto; min-height: 46px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--color-primary-strong); background: #fff; color: var(--color-primary-strong); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.mg-btns button:hover, .mg-tools button:hover { background: var(--color-surface); }
.mg-btns .mg-go { background: var(--color-primary-strong); color: #fff; flex-basis: 100%; }
.mg-btns .mg-go:hover { background: var(--color-primary-hover); }

/* 오늘의 낱말 미션 */
.mg-cats { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; }
.mg-cats button { flex: 0 0 auto; min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--color-line); background: #fff; font: inherit; font-size: 14px; font-weight: 700; color: var(--color-text-sub); cursor: pointer; }
.mg-cats button[aria-pressed="true"] { background: var(--color-primary-strong); border-color: var(--color-primary-strong); color: #fff; }
.mg-mcard { position: relative; margin-top: 6px; border-radius: 20px; background: linear-gradient(160deg, #FFF8EC, #FBF3E8); border: 2px dashed #E4D3C3; padding: 16px 12px 14px; text-align: center; }
.mg-mcard.mg-flip { animation: mg-flip .45s ease; }
@keyframes mg-flip { 0% { transform: rotateY(90deg) scale(.95); opacity: .3; } 100% { transform: none; opacity: 1; } }
.mg-memoji { font-size: 64px; line-height: 1.1; }
.mg-mword { font-size: 40px; font-weight: 900; letter-spacing: 2px; margin-top: 2px; }
.mg-mword.mg-hide { color: transparent; text-shadow: 0 0 14px rgba(0, 0, 0, .35); user-select: none; }
.mg-pieces { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.mg-pieces span { min-width: 34px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: #fff; border: 1px solid var(--color-line); font-size: 22px; font-weight: 900; }
.mg-pieces i { width: 8px; }
.mg-mcount { margin: 8px 0 0; font-size: 13px; color: var(--color-text-sub); }
.mg-hint { position: absolute; top: 8px; right: 8px; border: 0; background: rgba(255, 255, 255, .8); border-radius: 999px; font: inherit; font-size: 12px; font-weight: 700; color: var(--color-text-sub); padding: 6px 10px; cursor: pointer; }
.mg-name { margin-top: 10px; }
.mg-name label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.mg-name div { display: flex; gap: 8px; }
.mg-name input { flex: 1; min-width: 0; min-height: 46px; border: 1px solid var(--color-line); border-radius: 12px; padding: 0 12px; font: inherit; font-size: 18px; }
.mg-name button { min-height: 46px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--color-primary-strong); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.mg-name .caption { margin-top: 6px; }
.mg-real-btn { width: 100%; margin-top: 10px; min-height: 46px; border-radius: 14px; border: 2px solid #F2C14E; background: #FFF6D8; color: #7A5A00; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; }
.mg-real-btn:hover { background: #FFEFB8; }

/* 냉장고 */
.mg-fridge-wrap { position: relative; }
.mg-fridge { position: relative; aspect-ratio: 4 / 3; border-radius: 22px; background: linear-gradient(135deg, #FFFFFF 0%, #F3F5F7 55%, #E8ECEF 100%); border: 2px solid #DCE1E5; box-shadow: inset -10px 0 0 rgba(0, 0, 0, .025), 0 8px 18px rgba(0, 0, 0, .06); overflow: visible; touch-action: pan-y; --mg-size: 44px; }
.mg-handle { position: absolute; right: 12px; top: 14%; width: 8px; height: 32%; border-radius: 6px; background: linear-gradient(90deg, #C9CFD4, #E9ECEE); pointer-events: none; }
.mg-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #A2AAB0; font-size: 15px; font-weight: 700; padding: 20px; pointer-events: none; }
.mg-empty[hidden] { display: none; }
.mg-mag { position: absolute; width: var(--mg-size); height: var(--mg-size); display: flex; align-items: center; justify-content: center; font-size: calc(var(--mg-size) * .92); font-weight: 900; line-height: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; text-shadow: 0 2px 0 rgba(0, 0, 0, .18), 0 4px 8px rgba(0, 0, 0, .16); transition: transform .12s; animation: mg-stick .32s cubic-bezier(.3, 1.7, .5, 1); }
.mg-mag.is-drag { cursor: grabbing; transform: scale(1.18) rotate(-4deg); z-index: 5; transition: none; text-shadow: 0 6px 10px rgba(0, 0, 0, .25); }
.mg-mag.is-out { opacity: .35; }
@keyframes mg-stick { 0% { transform: scale(1.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.mg-mag.mg-turn { animation: mg-turn .3s ease; }
@keyframes mg-turn { 0% { transform: rotate(-90deg); } 100% { transform: none; } }
.mg-read { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--color-surface); min-height: 56px; }
.mg-read > span { font-size: 12px; font-weight: 700; color: var(--color-text-sub); flex: 0 0 auto; }
.mg-read b { flex: 1; font-size: 22px; font-weight: 900; word-break: keep-all; }
.mg-read b small { font-size: 14px; font-weight: 600; color: var(--color-text-sub); }
.mg-read button { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--color-primary-strong); color: #fff; font-size: 20px; cursor: pointer; }
.mg-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.mg-tools button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 12px; padding: 4px 2px; min-height: 54px; line-height: 1.2; }
.mg-tools button span { font-size: 18px; }
.mg-tray { margin-top: 12px; }
.mg-tray h4 { font-size: 13px; font-weight: 700; margin: 8px 0 4px; color: var(--color-text-sub); }
.mg-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.mg-row button { flex: 0 0 auto; width: 46px; height: 50px; border-radius: 12px; border: 1px solid var(--color-line); background: #fff; font: inherit; font-size: 28px; font-weight: 900; cursor: pointer; text-shadow: 0 2px 0 rgba(0, 0, 0, .12); transition: transform .1s; }
.mg-row button:active { transform: scale(.9); }
.mg-tip { margin-top: 6px; }

/* 축하 */
.mg-yay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: rgba(255, 255, 255, .86); border-radius: 22px; z-index: 8; text-align: center; animation: mg-yay .4s ease; }
.mg-yay b { font-size: 34px; font-weight: 900; }
.mg-yay span { font-size: 15px; font-weight: 700; color: var(--color-text-sub); }
.mg-yay button { margin-top: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--color-primary-strong); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
@keyframes mg-yay { 0% { opacity: 0; transform: scale(.9); } 100% { opacity: 1; transform: none; } }
.mg-confetti { position: absolute; top: -10px; font-size: 24px; pointer-events: none; z-index: 9; animation: mg-fall 1.6s ease-in forwards; }
@keyframes mg-fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(260px) rotate(300deg); opacity: 0; } }
.mg-toast { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: #fff; border: 1px solid var(--color-line); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 15px; box-shadow: 0 4px 12px rgba(0, 0, 0, .1); z-index: 7; white-space: nowrap; animation: mg-yay .3s ease; pointer-events: none; }

/* 받침 바꾸기 마법 */
.mg-magic { margin-top: 16px; }
.mg-bases, .mg-jongs { display: flex; gap: 6px; flex-wrap: wrap; }
.mg-bases button, .mg-jongs button { min-width: 48px; min-height: 48px; border-radius: 14px; border: 2px solid var(--color-line); background: #fff; font: inherit; font-size: 22px; font-weight: 900; cursor: pointer; }
.mg-bases button[aria-pressed="true"], .mg-jongs button[aria-pressed="true"] { border-color: var(--color-primary-strong); background: var(--color-surface); }
.mg-jongs button { color: #E2391F; }
.mg-jongs .mg-none { color: var(--color-text-sub); font-size: 14px; }
.mg-magic-stage { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 14px 0; padding: 14px 8px; border-radius: 20px; background: linear-gradient(160deg, #F4F0FF, #FBF3E8); text-align: center; }
.mg-big { font-size: 76px; font-weight: 900; line-height: 1; }
.mg-big.mg-pop { animation: mg-stick .4s cubic-bezier(.3, 1.7, .5, 1); }
.mg-arrow { font-size: 26px; }
.mg-res-emoji { font-size: 44px; line-height: 1.1; min-height: 48px; }
.mg-res-note { font-size: 13px; color: var(--color-text-sub); margin-top: 4px; word-break: keep-all; }
.mg-eq { font-size: 20px; font-weight: 800; margin-top: 6px; }
.mg-eq i { font-style: normal; color: var(--color-text-sub); font-weight: 500; margin: 0 3px; }
.mg-step { font-size: 13px; font-weight: 700; color: var(--color-text-sub); margin: 12px 0 6px; }

/* 별 모으기 + 진짜 자석으로 */
.mg-stars { margin-top: 16px; text-align: center; }
.mg-starrow { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 8px 0; font-size: 26px; }
.mg-starrow span { filter: grayscale(1); opacity: .25; transition: .3s; }
.mg-starrow span.on { filter: none; opacity: 1; animation: mg-stick .4s; }
.mg-real { margin-top: 16px; border-radius: var(--radius-card); background: var(--color-surface); padding: 20px 18px; text-align: center; }
.mg-real h3 { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.mg-real p { margin: 0 0 14px; font-size: 14px; color: var(--color-text-sub); word-break: keep-all; }
.mg-real .mg-links { display: flex; flex-direction: column; gap: 8px; }

@media (min-width: 1024px) {
  .mg-main { grid-template-columns: 380px 1fr; align-items: start; gap: 24px; }
  .mg-card { padding: 28px; }
  .mg-fridge { aspect-ratio: 16 / 10; }
  .mg-row { flex-wrap: wrap; overflow: visible; }
  .mg-magic-stage { padding: 20px; }
  .mg-big { font-size: 110px; }
  .mg-real .mg-links { flex-direction: row; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-mag, .mg-mcard.mg-flip, .mg-big.mg-pop, .mg-yay, .mg-toast, .mg-starrow span.on { animation: none; }
  .mg-confetti { display: none; }
}
