:root {
  --mga-cyan: #72edf2;
  --mga-cyan-2: #2cb9d4;
  --mga-violet: #8d68ff;
  --mga-gold: #f0ca72;
  --mga-red: #ff7182;
  --mga-ink: #050914;
  --mga-panel: rgba(8, 14, 29, .94);
  --mga-line: rgba(114, 237, 242, .24);
}

#mg-auth[hidden], #mg-connection[hidden], #mg-global-actions[hidden], #mg-auth [hidden] { display: none !important; }

#mg-auth {
  position: fixed;
  inset: 0;
  z-index: 110100;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  overflow: auto;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(3, 7, 18, .3), rgba(2, 5, 13, .93)),
    url('/img/minigames/tetra/generated/tetra-main-menu-bg-v2.png') center / cover no-repeat,
    #030611;
}

.mga-atmosphere { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.mga-atmosphere::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 78px, rgba(100, 224, 244, .025) 79px 80px), repeating-linear-gradient(0deg, transparent 0 78px, rgba(100, 224, 244, .02) 79px 80px);
  mask-image: linear-gradient(to bottom, transparent, #000 35%, #000);
}
.mga-atmosphere i { position: absolute; width: 32vw; height: 32vw; min-width: 260px; min-height: 260px; border-radius: 50%; filter: blur(70px); opacity: .18; animation: mga-drift 10s ease-in-out infinite alternate; }
.mga-atmosphere i:nth-child(1) { left: -8vw; top: -12vw; background: #2cb9d4; }
.mga-atmosphere i:nth-child(2) { right: -10vw; top: 18%; background: #8d68ff; animation-delay: -3s; }
.mga-atmosphere i:nth-child(3) { left: 32%; bottom: -24vw; background: #e95477; animation-delay: -6s; }

.mga-card {
  position: relative;
  width: min(430px, 100%);
  box-sizing: border-box;
  padding: 30px 32px 28px;
  overflow: hidden;
  border: 1px solid var(--mga-line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(16, 28, 52, .96), var(--mga-panel) 52%, rgba(5, 9, 20, .97));
  box-shadow: 0 32px 90px rgba(0, 0, 0, .7), 0 0 54px rgba(44, 185, 212, .09), inset 0 1px rgba(255, 255, 255, .07);
}
.mga-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, transparent, var(--mga-cyan), var(--mga-violet), transparent); opacity: .85; }
.mga-card::after { content: ''; position: absolute; width: 160px; height: 160px; right: -80px; top: -80px; border: 1px solid rgba(114, 237, 242, .14); transform: rotate(45deg); pointer-events: none; }

.mga-brand-wrap { position: relative; z-index: 1; margin-bottom: 25px; text-align: center; }
.mga-brand { font-size: clamp(30px, 6vw, 40px); line-height: 1; font-weight: 950; letter-spacing: .28em; padding-left: .28em; color: #eefcff; text-shadow: 0 0 24px rgba(114, 237, 242, .6), 2px 0 rgba(141, 104, 255, .5); }
.mga-brand-line { width: 112px; height: 2px; margin: 11px auto 8px; background: linear-gradient(90deg, transparent, var(--mga-cyan), transparent); box-shadow: 0 0 12px var(--mga-cyan); }
.mga-brand-wrap p { margin: 0; color: #8297b9; font-size: 11px; letter-spacing: .15em; }

.mga-view { position: relative; z-index: 1; animation: mga-view-in .2s ease-out both; }
.mga-view h1 { margin: 0 0 7px; text-align: center; color: #f4f8ff; font-size: 21px; letter-spacing: .04em; }
.mga-lead { min-height: 18px; margin: 0 0 19px; text-align: center; color: #8ea3c4; font-size: 12.5px; line-height: 1.5; }

.mga-field { display: block; margin-bottom: 12px; }
.mga-field > span { display: block; margin: 0 0 6px 3px; color: #9bb0d0; font-size: 11px; font-weight: 750; letter-spacing: .05em; }
.mga-field input {
  display: block;
  width: 100%;
  height: 47px;
  box-sizing: border-box;
  border: 1px solid rgba(135, 161, 204, .25);
  border-radius: 11px;
  outline: 0;
  padding: 0 14px;
  background: rgba(3, 8, 19, .82);
  color: #edf8ff;
  font: 650 14px/1 sans-serif;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.mga-field input:focus { border-color: rgba(114, 237, 242, .75); background: rgba(5, 14, 29, .95); box-shadow: 0 0 0 3px rgba(44, 185, 212, .1), 0 0 18px rgba(44, 185, 212, .12); }

.mga-primary, .mga-secondary, .mga-provider, .mga-register-card, .mga-links button, .mga-logout {
  appearance: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  transition: transform .13s ease, filter .13s ease, border-color .13s ease, box-shadow .13s ease;
}
.mga-primary, .mga-secondary { width: 100%; min-height: 45px; border-radius: 11px; font-size: 14px; font-weight: 850; letter-spacing: .04em; }
.mga-primary { color: #041016; background: linear-gradient(180deg, #9af7f5, #42c9dc); box-shadow: inset 0 1px rgba(255, 255, 255, .65), 0 9px 25px rgba(44, 185, 212, .2); }
.mga-primary:hover { filter: brightness(1.08) saturate(1.08); box-shadow: inset 0 1px rgba(255,255,255,.7), 0 0 24px rgba(114,237,242,.28); }
.mga-secondary { margin-top: 12px; border: 1px solid rgba(135, 161, 204, .25); color: #b8c6dd; background: rgba(11, 19, 36, .72); }
.mga-secondary:hover { border-color: rgba(114, 237, 242, .4); color: #e4faff; }
.mga-primary:active, .mga-secondary:active, .mga-provider:active, .mga-register-card:active, .mga-logout:active { transform: translateY(1px) scale(.985); }
.mga-primary:disabled, .mga-secondary:disabled, .mga-provider:disabled, .mga-register-card:disabled { cursor: wait; filter: grayscale(.35); opacity: .55; }

.mga-divider { display: flex; align-items: center; gap: 10px; margin: 19px 0 13px; color: #61718d; font-size: 10px; letter-spacing: .1em; }
.mga-divider::before, .mga-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(128, 153, 193, .24)); }
.mga-divider::after { transform: scaleX(-1); }
.mga-provider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mga-provider { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 9px; border-radius: 10px; font-size: 12px; font-weight: 850; }
.mga-provider.mga-google, .mga-register-card.mga-google { color: #172033; background: #f6f8fc; }
.mga-provider.mga-kakao, .mga-register-card.mga-kakao { color: #211d08; background: #fee500; }
.mga-provider:hover, .mga-register-card:hover { filter: brightness(1.06); box-shadow: 0 0 22px rgba(255, 255, 255, .12); }
.mga-google-mark, .mga-kakao-mark { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; font-size: 13px; font-weight: 950; }
.mga-google-mark { color: #356ed8; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.mga-kakao-mark { color: #fee500; background: #241f08; border-radius: 50%; }

.mga-register-card { position: relative; width: 100%; min-height: 72px; margin-bottom: 10px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; border-radius: 13px; padding: 12px 14px; }
.mga-register-card > span { grid-row: 1 / 3; }
.mga-register-card b { font-size: 14px; }
.mga-register-card small { opacity: .7; font-size: 10.5px; line-height: 1.35; }

.mga-links { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 17px; }
.mga-links button { padding: 2px; background: none; color: #8499b8; font-size: 11px; }
.mga-links button:hover { color: var(--mga-cyan); }
.mga-links span { width: 1px; height: 10px; background: rgba(137, 158, 190, .25); }

.mga-message { position: relative; z-index: 1; min-height: 17px; margin: 13px 0 0; text-align: center; color: var(--mga-red); font-size: 11.5px; line-height: 1.45; }
.mga-message.ok { color: #73e5af; }
.mga-account-list { display: grid; gap: 8px; max-height: 190px; overflow: auto; margin: 0 0 14px; }
.mga-account-item { display: flex; align-items: center; gap: 10px; min-height: 41px; box-sizing: border-box; padding: 9px 12px; border: 1px solid rgba(114, 237, 242, .18); border-radius: 10px; background: rgba(6, 14, 28, .72); color: #e5f4ff; font-size: 13px; font-weight: 750; }
.mga-account-item input { accent-color: var(--mga-cyan-2); }

.mga-logout { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid rgba(255, 113, 130, .35); border-radius: 10px; background: rgba(19, 9, 18, .86); color: #ffb5bf; box-shadow: 0 8px 24px rgba(0,0,0,.36); font-size: 10.5px; font-weight: 900; letter-spacing: .12em; backdrop-filter: blur(9px); }
.mga-logout:hover { border-color: rgba(255, 113, 130, .72); color: #fff; box-shadow: 0 0 20px rgba(255, 113, 130, .16); }
.mga-logout-mark { position: relative; width: 13px; height: 14px; border: 1.5px solid currentColor; border-right: 0; border-radius: 2px 0 0 2px; }
.mga-logout-mark::before { content: ''; position: absolute; width: 8px; height: 1.5px; top: 5px; left: 6px; background: currentColor; box-shadow: 4px -3px 0 -1px currentColor, 4px 3px 0 -1px currentColor; }

#mg-connection { position: fixed; inset: 0; z-index: 110200; display: grid; place-items: center; box-sizing: border-box; padding: 20px; background: rgba(2, 5, 13, .82); backdrop-filter: blur(10px); }
.mgc-card { width: min(410px, 92vw); box-sizing: border-box; padding: 29px 30px 25px; border: 1px solid rgba(255, 113, 130, .32); border-radius: 20px; text-align: center; background: linear-gradient(155deg, rgba(24, 17, 34, .98), rgba(7, 12, 25, .98)); box-shadow: 0 28px 80px rgba(0,0,0,.7), 0 0 45px rgba(255,113,130,.08); }
.mgc-signal { height: 43px; display: flex; align-items: end; justify-content: center; gap: 5px; margin-bottom: 15px; }
.mgc-signal i { width: 7px; border-radius: 4px; background: var(--mga-red); box-shadow: 0 0 12px rgba(255, 113, 130, .65); animation: mgc-signal 1.1s ease-in-out infinite alternate; }
.mgc-signal i:nth-child(1) { height: 13px; }
.mgc-signal i:nth-child(2) { height: 25px; animation-delay: -.35s; }
.mgc-signal i:nth-child(3) { height: 39px; animation-delay: -.7s; }
#mg-connection[data-mode="connecting"] .mgc-card, #mg-connection[data-mode="restoring"] .mgc-card { border-color: rgba(114, 237, 242, .34); box-shadow: 0 28px 80px rgba(0,0,0,.7), 0 0 45px rgba(114,237,242,.1); }
#mg-connection[data-mode="connecting"] .mgc-signal i, #mg-connection[data-mode="restoring"] .mgc-signal i { background: var(--mga-cyan); box-shadow: 0 0 12px rgba(114, 237, 242, .65); }
.mgc-card h1 { margin: 0 0 10px; color: #fff; font-size: 22px; letter-spacing: .04em; }
.mgc-card p { margin: 0; color: #a9b7cc; font-size: 13px; line-height: 1.6; }
.mgc-attempt { min-height: 19px; padding: 9px 0 14px; color: var(--mga-cyan) !important; font-variant-numeric: tabular-nums; }
.mgc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mgc-actions .mga-secondary { margin-top: 0; }

@keyframes mga-view-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes mga-drift { to { transform: translate3d(3vw, 2vw, 0) scale(1.1); } }
@keyframes mgc-signal { from { opacity: .25; transform: scaleY(.55); } to { opacity: 1; transform: scaleY(1); } }

@media (max-width: 520px) {
  .mga-card { padding: 25px 20px 22px; border-radius: 18px; }
  .mga-provider-grid { grid-template-columns: 1fr; }
  .mga-links { gap: 6px; }
  #mg-global-actions { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .mga-logout { min-height: 32px; padding: 0 9px; }
  .mgc-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .mga-atmosphere i, .mgc-signal i, .mga-view { animation: none !important; }
  .mga-primary, .mga-secondary, .mga-provider, .mga-register-card, .mga-logout { transition: none !important; }
}
