:root {
  --ink: #4a3b6b;
  --ink-soft: #7b6c9c;
  --paper: #fffaf3;
  --pink: #ff7ab6;
  --pink-dark: #e0508f;
  --blue: #5fb8ff;
  --blue-dark: #3a8fd6;
  --yellow: #ffd84d;
  --line: #e7dcff;
  --shadow: 0 6px 0 rgba(74, 59, 107, .18), 0 12px 30px rgba(74, 59, 107, .18);
  --font: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #2b2340;
  font-family: var(--font); color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* 화면 공통 */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.panel-screen { background: rgba(43, 35, 64, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { background: var(--paper); border-radius: 26px; box-shadow: var(--shadow); padding: 20px 22px; width: min(520px, 100%);
  max-height: 100%; overflow: auto; text-align: center; border: 4px solid #fff; }
.panel h2 { margin: 0 0 10px; font-size: 26px; font-weight: normal; color: var(--pink-dark); }

.topbar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 18px; color: #fff; text-decoration: none; letter-spacing: 1px; text-shadow: 0 2px 0 rgba(74,59,107,.35); }
.brand span { color: var(--yellow); }

.title-box { text-align: center; margin-top: -40px; }
.logo { margin: 0; font-weight: normal; font-size: clamp(40px, 9vw, 76px); color: #fff; line-height: 1.05;
  text-shadow: 0 4px 0 var(--pink-dark), 0 8px 0 rgba(74,59,107,.25); letter-spacing: 2px; }
.logo span { color: #fff2a8; text-shadow: 0 4px 0 #e8a92c, 0 8px 0 rgba(74,59,107,.25); }
.sub { color: #fff; margin: 6px 0 14px; font-size: clamp(15px, 2.6vw, 20px); text-shadow: 0 2px 0 rgba(74,59,107,.4); }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.title-box .menu { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.who { color: #fff; font-size: 14px; margin: 10px 0 0; text-shadow: 0 1px 0 rgba(74,59,107,.5); min-height: 1em; }
.title-foot { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left)); display: flex; gap: 8px; }

.btn { border: 0; border-radius: 18px; padding: 10px 18px; font-size: 18px; background: #fff; color: var(--ink);
  box-shadow: 0 4px 0 #d9cdf2; transition: transform .08s; min-height: 44px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9cdf2; }
.btn.big { font-size: 22px; padding: 12px 26px; background: var(--yellow); box-shadow: 0 5px 0 #d9a22a; }
.btn.big:active { box-shadow: 0 2px 0 #d9a22a; }
.btn.blue { background: var(--blue); color: #fff; box-shadow: 0 5px 0 var(--blue-dark); }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 5px 0 var(--pink-dark); }
.btn.small { font-size: 15px; padding: 8px 12px; min-height: 40px; }
.btn small { display: block; font-size: 12px; opacity: .85; }
.btn:disabled { opacity: .5; }
.chip { border: 0; border-radius: 999px; padding: 7px 14px; font-size: 14px; background: rgba(255,255,255,.85); color: var(--ink); min-height: 36px; }

.join-box { background: rgba(255,255,255,.92); border-radius: 20px; padding: 10px 16px 14px; margin: 0 auto 12px; display: inline-block; }
.join-box p { margin: 0 0 8px; }

.stage-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stage-list button, .stage-pick button { border: 3px solid var(--line); background: #fff; border-radius: 16px; padding: 10px; font-size: 16px; color: var(--ink); }
.stage-list button small, .stage-pick button small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.stage-list button:disabled { opacity: .45; }
.stage-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0; }
.stage-pick button { padding: 6px 10px; font-size: 14px; }
.stage-pick button.on { border-color: var(--pink); background: #fff0f7; }

.code-line { margin: 0 0 8px; font-size: 18px; }
.code-line b { font-size: 30px; letter-spacing: 6px; color: var(--blue-dark); }
.invite { display: flex; gap: 6px; margin-bottom: 12px; }
.invite input { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 12px; padding: 0 10px; font: 14px var(--font); color: var(--ink); user-select: text; }
.slots { display: flex; gap: 10px; justify-content: center; margin-bottom: 6px; }
.slot { width: 104px; border-radius: 18px; background: #f6f1ff; padding: 6px 4px 8px; border: 3px dashed var(--line); }
.slot.on { border-style: solid; background: #fff; }
.slot canvas { width: 72px; height: 72px; display: block; margin: 0 auto; }
.slot p { margin: 2px 0 0; font-size: 14px; }
.slot small { color: var(--ink-soft); }
.hint { color: var(--ink-soft); font-size: 14px; margin: 6px 0; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 10px; }
.stats div { background: #f6f1ff; border-radius: 14px; padding: 8px; }
.stats b { display: block; font-size: 24px; color: var(--pink-dark); font-weight: normal; }

/* 대화창 */
.dialog { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom)); width: min(760px, calc(100% - 24px));
  display: flex; gap: 12px; align-items: center; background: var(--paper); border: 4px solid #fff; border-radius: 24px;
  box-shadow: var(--shadow); padding: 10px 16px 10px 10px; cursor: pointer; }
.dialog canvas { width: 92px; height: 92px; flex: none; background: #f3ecff; border-radius: 18px; }
.dialog-body { flex: 1; min-width: 0; }
.skip-btn { position: absolute; right: 12px; top: -46px; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 36px;
  font: 14px var(--font); color: #fff; background: rgba(74, 59, 107, .78); box-shadow: 0 3px 0 rgba(43, 35, 64, .35); }
.skip-btn:active { transform: translateY(2px); }
.dlg-name { margin: 0; color: var(--pink-dark); font-size: 17px; min-height: 1em; }
.dlg-text { margin: 2px 0 0; font-size: clamp(16px, 2.4vw, 20px); line-height: 1.45; min-height: 2.9em; }
.dlg-hint { margin: 2px 0 0; text-align: right; font-size: 13px; color: var(--ink-soft); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.banner { position: fixed; z-index: 15; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; color: #fff; pointer-events: none;
  text-shadow: 0 3px 0 var(--pink-dark), 0 6px 0 rgba(74,59,107,.3); animation: banner 2.6s ease forwards; }
.banner small { display: block; font-size: 18px; }
.banner span { font-size: clamp(34px, 7vw, 56px); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -20px) scale(.9); } 15%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; } }

.pause-btn { position: fixed; z-index: 12; top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.75); color: var(--ink); font-size: 18px; }

.rotate { position: fixed; inset: 0; z-index: 50; background: #7fd4ff; color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 48px; }
.rotate p { font-size: 22px; margin: 8px 0 0; text-shadow: 0 2px 0 rgba(74,59,107,.3); }

.toast { position: fixed; z-index: 60; left: 50%; top: max(60px, calc(env(safe-area-inset-top) + 50px)); transform: translateX(-50%) translateY(-10px);
  background: rgba(74,59,107,.92); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 15px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }

@media (max-height: 430px) {
  .title-box { margin-top: 0; }
  .logo { font-size: 44px; }
  .sub { margin: 2px 0 8px; }
  .btn.big { font-size: 18px; padding: 9px 18px; }
  .panel { padding: 12px 16px; }
  .panel h2 { font-size: 21px; margin-bottom: 6px; }
  .slot canvas { width: 54px; height: 54px; }
  .dialog canvas { width: 68px; height: 68px; }
}

/* 게임 중에는 GameNow 공유 버튼이 터치 버튼(점프)을 가리지 않게 숨긴다. 첫 화면·대기실·결과에서는 보인다 */
body.playing #gamenow-share-launcher { display: none !important; }
