@font-face {
  font-family: 'Jua';
  src: url('../fonts/Jua-sub.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #3B2418;
  --paper: #FFF7EA;
  --cream: #FFF1D6;
  --latte: #E9C9A0;
  --coffee: #6B4226;
  --pink: #FF8FA3;
  --mint: #7ED9C3;
  --yellow: #FFD35A;
  --sky: #9AD8FF;
  --red: #FF6B5A;
  --shadow: 4px 4px 0 var(--ink);
  --font: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--coffee);
  background-image: radial-gradient(rgba(255,255,255,0.08) 2px, transparent 2.5px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--body);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  word-break: keep-all; overflow-wrap: anywhere;
}
button { font-family: var(--font); color: var(--ink); cursor: pointer; }
input { font-family: var(--body); }

#app {
  position: relative;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--paper);
  background-image: radial-gradient(rgba(59,36,24,0.07) 1.4px, transparent 1.8px);
  background-size: 12px 12px;
  overflow: hidden;
  /* 가로로 누운 폰의 노치·둥근 모서리 */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ---------- 상단 바 ---------- */
#bar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-top)) 10px 6px;
  background: var(--yellow);
  border-bottom: 3px solid var(--ink);
  z-index: 5;
}
#barTitle { flex: 1; margin: 0; font: 22px var(--font); text-align: center; letter-spacing: -0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  border: 2.5px solid var(--ink); border-radius: 12px;
  background: #fff; box-shadow: 2px 2px 0 var(--ink);
  font-size: 22px; line-height: 1; padding: 0;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
#back.hidden { visibility: hidden; }

#screen { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#screen.full { overflow: hidden; }
.pad { padding: 14px 14px calc(24px + var(--safe-bottom)); max-width: 1100px; margin: 0 auto; }

/* ---------- 공통 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 8px 18px;
  font: 20px var(--font);
  border: 3px solid var(--ink); border-radius: 16px;
  background: #fff; box-shadow: var(--shadow);
  transition: transform .06s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--pink); color: #fff; text-shadow: 1.5px 1.5px 0 var(--ink); -webkit-text-stroke: 0.6px var(--ink); font-size: 24px; }
.btn.yellow { background: var(--yellow); }
.btn.mint { background: var(--mint); }
.btn.small { min-height: 38px; font-size: 16px; padding: 4px 12px; border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; }

.panel {
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px;
}
.label { font: 18px var(--font); margin: 18px 2px 8px; }
.muted { color: #7a6456; font-size: 13px; }

/* ---------- 홈 ---------- */
.hero { position: relative; text-align: center; padding: 8px 0 4px; }
.hero canvas { display: block; margin: 0 auto; }
.hero .title { font: 44px var(--font); margin: 0; color: #fff; -webkit-text-stroke: 2px var(--ink); text-shadow: 4px 4px 0 var(--ink); letter-spacing: -1px; }
.hero .sub { font: 16px var(--font); margin: 2px 0 0; color: var(--coffee); }

.team-strip { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.team-strip .faces { flex: 1; display: flex; gap: 2px; overflow-x: auto; padding: 2px; }
/* 적으면 가운데, 넘치면 왼쪽부터: 양 끝 자동 여백. 'justify-content: safe center' 는 Chrome 115 전 웹뷰(안드로이드)에서
   그냥 center 처럼 굴어 넘친 왼쪽이 잘린 채 스크롤로도 닿지 않는다 */
.team-strip .faces > :first-child { margin-left: auto; }
.team-strip .faces > :last-child { margin-right: auto; }
.team-strip .faces.muted { justify-content: center; } /* 빈 팀 안내 글자는 요소가 아니라 위 여백이 안 먹는다 */
.team-strip .face { flex: none; text-align: center; width: 54px; }
.team-strip .face canvas { width: 48px; height: 56px; display: block; margin: 0 auto; }
.team-strip .face span { display: block; font: 12px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.games { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  padding: 0; overflow: hidden;
  border: 3px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: var(--shadow);
}
.card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.card canvas { display: block; width: 100%; aspect-ratio: 4 / 3; border-bottom: 3px solid var(--ink); }
.card .meta { padding: 7px 9px 9px; }
.card h3 { margin: 0; font: 19px var(--font); letter-spacing: -0.5px; }
.card p { margin: 2px 0 0; font-size: 12px; color: #6b5547; line-height: 1.35; min-height: 32px; }
.card .tag { position: absolute; top: 7px; left: 7px; max-width: calc(100% - 72px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px var(--font); background: var(--yellow); border: 2px solid var(--ink); border-radius: 10px; padding: 1px 7px; }
.card .num { position: absolute; top: 7px; right: 7px; white-space: nowrap; font: 12px var(--font); background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 1px 7px; }
.home-links { display: flex; gap: 10px; margin-top: 16px; }
.home-links .btn { flex: 1; }
.fair-note { text-align: center; font: 14px var(--font); color: var(--coffee); margin: 16px 0 0; }

/* ---------- 참가자 설정 ---------- */
.member { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 2px dashed #ecd9bf; }
.member:last-child { border-bottom: 0; }
.member.out { opacity: .45; }
.member .av { flex: none; width: 52px; height: 60px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--cream); padding: 0; }
.member .av canvas { width: 100%; height: 100%; display: block; }
.member .who { flex: 1; min-width: 0; }
.member .who input { width: 100%; font-size: 16px; padding: 7px 9px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fffdf8; }
.member .who small { display: block; font: 12px var(--font); color: #8a7162; margin-top: 2px; }
/* 스위치: 안쪽 폭 53 × 높이 29 (58×34 - 테두리). 동그라미 25px 을 세로 가운데에, 켜지면 24px 옆으로 */
.toggle { flex: none; position: relative; width: 58px; height: 34px; padding: 0; border: 2.5px solid var(--ink); border-radius: 17px; background: #ddd; -webkit-appearance: none; appearance: none; overflow: hidden; }
.toggle.on { background: var(--mint); }
.toggle::after { content: ''; position: absolute; top: 50%; left: 2px; width: 25px; height: 25px; margin-top: -12.5px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform .15s; }
.toggle.on::after { transform: translateX(24px); }
.del { flex: none; width: 40px; height: 40px; margin: 0 -6px 0 -4px; border: 0; border-radius: 10px; background: none; font-size: 18px; padding: 0; color: #b08a74; }
.del:active { background: #f5e6d3; }
.opt { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.opt span { flex: 1; font: 16px var(--font); }
.opt small { display: block; font: 12px var(--body); color: #8a7162; }
.start-bar { position: sticky; bottom: 0; padding: 12px 0 calc(8px + var(--safe-bottom)); background: linear-gradient(transparent, var(--paper) 30%); }
.start-bar.two { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; align-items: center; }
.start-bar.two .add-member { min-height: 52px; font-size: 17px; }
.panel .add-member { margin-top: 10px; }
#screen:has(.start-bar) { scroll-padding-bottom: 100px; }
.warn { text-align: center; font: 15px var(--font); color: var(--red); margin: 0 0 8px; }

/* ---------- 캐릭터 고르기 모달 ---------- */
.modal-bg { position: absolute; inset: 0; background: rgba(59,36,24,0.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { width: 100%; max-height: 90%; overflow-y: auto; background: var(--paper); border-top: 3px solid var(--ink); border-radius: 22px 22px 0 0; padding: 16px 14px calc(18px + var(--safe-bottom)); animation: up .2s; }
.modal h2 { margin: 0 0 10px; font: 22px var(--font); text-align: center; }
.char-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.char-grid button { border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; padding: 4px 2px 6px; font: 13px var(--font); line-height: 1.2; }
.char-grid button.sel { background: var(--yellow); }
.char-grid canvas { width: 100% !important; height: auto !important; aspect-ratio: 6 / 7; display: block; }
.char-grid small { display: block; font: 11px var(--body); color: #8a7162; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- 게임 화면 ---------- */
.stage-host { position: absolute; inset: 0; touch-action: none; }
.stage-canvas { display: block; touch-action: none; }
.hud { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(12px + var(--safe-bottom)); display: flex; gap: 10px; justify-content: center; pointer-events: none; }
.hud > * { pointer-events: auto; }
.skip { position: absolute; right: 12px; bottom: calc(14px + var(--safe-bottom)); z-index: 3; }

/* ---------- 찍기 ---------- */
.predict { text-align: center; }
.predict h2 { font: 26px var(--font); margin: 6px 0 4px; }
.predict .q { font: 18px var(--font); margin: 0 0 14px; color: var(--coffee); }
.predict .q b { color: var(--ink); font-weight: normal; background: var(--yellow); padding: 0 6px; border-radius: 6px; }
.pick-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; } /* 인원이 적어도 가운데로 */
.pick-grid button { flex: 0 0 86px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; box-shadow: 3px 3px 0 var(--ink); padding: 4px 2px 6px; font: 14px var(--font); word-break: keep-all; overflow-wrap: anywhere; line-height: 1.2; }
.pick-grid button:active { transform: translate(3px, 3px); box-shadow: none; }
.pick-grid canvas { width: 64px; height: 75px; display: block; margin: 0 auto; }

/* ---------- 결과 ---------- */
.result { position: absolute; inset: 0; display: flex; flex-direction: column; }
.result .reveal { position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.result .sheet {
  flex: none; background: var(--paper); border-top: 3px solid var(--ink); border-radius: 22px 22px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom)); margin-top: -18px; position: relative; z-index: 2;
  animation: up .35s; max-height: 62%; overflow-y: auto;
}
/* 긴 이름이어도 단어 중간에서 끊기지 않게 (이름 덩어리는 통째로, 너무 길면 이름 안에서만 줄바꿈) */
.sheet .who { text-align: center; font: 26px var(--font); margin: 0; word-break: keep-all; line-height: 1.25; }
.sheet .who em { font-style: normal; color: #fff; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 3px 3px 0 var(--ink); font-size: 32px; overflow-wrap: anywhere; }
.sheet .who em.long { font-size: 24px; }
@media (max-width: 380px) { .sheet .who { font-size: 21px; } .sheet .who em { font-size: 26px; } .sheet .who em.long { font-size: 20px; } }
.sheet .extra { text-align: center; font: 15px var(--font); color: var(--coffee); margin: 6px 0 0; }
.final-ranking { margin: 12px 0 2px; padding: 10px 12px; background: rgba(255,255,255,.68); border: 2px solid var(--ink); border-radius: 13px; }
.final-ranking h3 { margin: 0 0 5px; font: 18px var(--font); }
.final-rank { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 7px; min-height: 30px; border-top: 1px dashed #ddc9ad; font: 15px var(--font); }
.final-rank:first-of-type { border-top: 0; }
.final-rank .place { text-align: center; }
.final-rank .person { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-rank small { color: #75513b; font: 11px var(--font); white-space: nowrap; }
.final-rank.loser { color: #b54036; }
.sheet .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sheet .btns .span2 { grid-column: span 2; }
.cafe-find { margin: 14px 0 4px; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; }
.cafe-find p { margin: 0 0 10px; font: 17px var(--font); }
.cafe-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cafe-maps .btn { text-decoration: none; justify-content: center; min-height: 48px; font-size: 17px; }
.cafe-maps .cafe-kakao { background: #FEE500; color: #191919; }
.cafe-maps .cafe-naver { background: #03C75A; color: #FFFFFF; }
.comic-thumb { display: block; width: 100%; border: 3px solid var(--ink); border-radius: 12px; margin-top: 12px; background: #fff; }

/* ---------- 기록 ---------- */
.rec .cols { row-gap: 18px; }
.rec .label { margin-top: 4px; }
.rec .panel { padding: 6px 16px; }
.rec .empty { margin: 10px 0; }
.rank-item { padding: 11px 0; border-bottom: 2px dashed #ecd9bf; }
.rank-item:last-child { border-bottom: 0; }
.rank { display: flex; align-items: center; gap: 10px; font: 17px var(--font); }
.rank .n { width: 28px; flex: none; text-align: center; font-size: 20px; }
.rank .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .bar { height: 12px; max-width: 24vw; flex: none; background: var(--pink); border: 2px solid var(--ink); border-radius: 6px; }
.titles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.rank-item .titles { margin: 8px 0 0 38px; }
.chip { font: 13px var(--font); background: var(--cream); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 8px; }
.hist { font-size: 14px; padding: 10px 0; border-bottom: 1px solid #efdcc3; display: flex; gap: 10px; align-items: baseline; }
.hist:last-child { border-bottom: 0; }
.hist time { color: #9a7f6e; flex: none; min-width: 7.6em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist span { min-width: 0; }
.rec-foot { text-align: center; margin-top: 22px; }
.rec-foot .muted { margin: 0 0 10px; }

/* ---------- 도움말 ---------- */
.help h2 { font: 22px var(--font); margin: 18px 0 6px; }
.help p, .help li { font-size: 15px; line-height: 1.6; }

/* ---------- 토스트 ---------- */
#toasts { position: fixed; left: 50%; top: calc(64px + var(--safe-top)); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { font: 17px var(--font); background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink); padding: 8px 14px; animation: up .25s; text-align: center; }

/* ---------- 갤러리 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; }
.gallery .pair { display: flex; gap: 4px; }
.gallery .pair > div { flex: 1; text-align: center; font-size: 10px; color: #8a7162; }
.gallery canvas, .gallery img { width: 100%; aspect-ratio: 1; object-fit: contain; background: repeating-conic-gradient(#f3e8d8 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: block; }
.gallery figcaption { font-size: 11px; margin-top: 4px; word-break: break-all; }
.gallery .ok { color: #2d9a6a; }
.gallery .no { color: #c0563f; }

/* ---------- 각자 폰 모드 (방) ---------- */
.room-cta { margin-top: 14px; flex-direction: column; gap: 0; min-height: 60px; font-size: 21px; }
.room-cta small { font: 13px var(--body); color: var(--ink); opacity: .8; }
.invite { display: flex; gap: 14px; align-items: center; }
.qr-box { flex: none; width: 132px; height: 132px; border: 2.5px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; display: grid; place-items: center; }
.qr-box canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.invite-text { flex: 1; min-width: 0; }
.room-code { margin: 0; font: clamp(30px, 9vw, 40px) var(--font); letter-spacing: 6px; color: #fff; -webkit-text-stroke: 1.6px var(--ink); text-shadow: 3px 3px 0 var(--ink); }
.invite-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.net-status { margin: 8px 0 0; font: 13px var(--font); }
.me-row { display: flex; align-items: center; gap: 10px; }
.me-row .av { flex: none; width: 52px; height: 60px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--cream); padding: 0; }
.me-row .who { flex: 1; min-width: 0; }
.me-row input { width: 100%; font-size: 16px; padding: 7px 9px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fffdf8; }
.me-row small, .member .who small { display: block; font: 12px var(--font); color: #8a7162; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member span.av { display: block; }
.m-name { font: 17px var(--font); font-weight: normal; }
.dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #cbbfb3; border: 2px solid var(--ink); margin-right: 6px; }
.dot.on { background: #4CD68A; }
.net-games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.net-game b { max-width: 100%; }
.net-game { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; box-shadow: 3px 3px 0 var(--ink); }
.net-game.sel { background: var(--yellow); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.net-game .e { font-size: 28px; line-height: 1.1; }
.net-game b { font: 17px var(--font); font-weight: normal; }
.net-game small { font: 12px var(--body); color: #6b5547; }
/* 고를 게임이 하나뿐이면(지금은 출근길 달리기만) 한 줄 전체로, 아래 패널·버튼과 좌우를 맞춘다. 누른 듯 밀리는 효과도 없앤다 */
.net-game:only-child { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; padding: 12px 14px; }
.net-game:only-child.sel { transform: none; box-shadow: var(--shadow); }
.net-game:only-child .e { font-size: 26px; }
.waiting { text-align: center; }
.waiting p:first-child { font: 19px var(--font); margin: 6px 0; }
.pick-grid button.sel { background: var(--yellow); }
.count-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,247,234,0.92); z-index: 3; }
.count-overlay b { font: 110px var(--font); font-weight: normal; color: var(--yellow); -webkit-text-stroke: 3px var(--ink); text-shadow: 6px 6px 0 var(--ink); }
.cheer-btn { font-size: 20px; }
.cheer-pop { position: absolute; right: 10px; top: calc(58px + var(--safe-top)); z-index: 8; display: none; gap: 6px; padding: 6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; box-shadow: 3px 3px 0 var(--ink); animation: up .15s; }
.cheer-pop.open { display: flex; }
.cheer-pop button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--cream); font-size: 22px; padding: 0; }
.cheer-pop button:active { transform: scale(.9); }
.cheer-float { position: absolute; bottom: 90px; z-index: 4; pointer-events: none; display: flex; flex-direction: column; align-items: center; animation: floatUp 1.8s ease-out forwards; }
.cheer-float .e { font-size: 38px; }
.cheer-float .n { font: 12px var(--font); background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; }
@keyframes floatUp { from { transform: translateY(0) scale(.6); opacity: 0; } 15% { transform: translateY(-20px) scale(1.1); opacity: 1; } to { transform: translateY(-240px) scale(1); opacity: 0; } }
@media (min-width: 720px) { .net-games { grid-template-columns: repeat(3, 1fr); } .qr-box { width: 168px; height: 168px; } }

/* ---------- 반응형: 태블릿·데스크톱 ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 22px; align-items: start; }
.cols > * { min-width: 0; }
@media (min-width: 720px) {
  .hero canvas { max-width: 560px !important; }
  .hero .title { font-size: 60px; }
  .hero .sub { font-size: 19px; }
  .games { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .card h3 { font-size: 21px; }
  .card p { font-size: 13px; }
  .home-links, .fair-note { max-width: 640px; margin-left: auto; margin-right: auto; }
  .modal { max-width: 620px; border: 3px solid var(--ink); border-bottom: 0; }
  .predict { max-width: 820px; margin: 0 auto; }
  .pick-grid button { flex-basis: 112px; }
  .pick-grid canvas { width: 84px; height: 98px; }
  /* 얼굴 줄을 패널 정중앙에 (왼쪽 여백을 팀 편집 버튼 폭만큼 잡아 준다) */
  .team-strip { display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; }
  .team-strip::before { content: ''; }
  .team-strip > .btn { justify-self: end; white-space: nowrap; }
  #toasts { top: calc(72px + var(--safe-top)); }
}
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cols .start-bar { position: static; background: none; padding-top: 18px; }
  .help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  #bar { padding-left: 18px; padding-right: 18px; }
  #barTitle { font-size: 24px; }
}
/* 가로로 넓은 화면의 결과: 왼쪽 공개 무대, 오른쪽 시트 */
@media (min-width: 560px) and (min-aspect-ratio: 1/1) {
  .result { flex-direction: row; }
  .result .sheet {
    width: min(440px, 42%); max-height: none; margin: 0; overflow-y: auto;
    border-top: 0; border-left: 3px solid var(--ink); border-radius: 0;
    animation: slide .35s;
  }
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* ---------- 좁은 폰 (320~380) ---------- */
@media (max-width: 380px) {
  #bar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  #barTitle { font-size: 19px; }
  .pad { padding-left: 10px; padding-right: 10px; }
  .hero .title { font-size: 38px; }
  .games { gap: 10px; }
  .card h3 { font-size: 16px; }
  .card p { font-size: 11px; min-height: 30px; }
  .card .tag, .card .num { font-size: 11px; padding: 0 5px; }
  .card .tag { max-width: calc(100% - 64px); }
  .home-links .btn { font-size: 17px; padding: 8px 10px; white-space: nowrap; }
  .member { gap: 6px; }
  .member .av { width: 46px; height: 54px; }
  .toggle { width: 54px; }
  .toggle.on::after { transform: translateX(20px); }
  /* 방 초대: QR 을 위로, 글자는 아래 가운데 */
  .invite { flex-direction: column; text-align: center; }
  .qr-box { width: 150px; height: 150px; }
  .invite-btns { justify-content: center; }
  .net-game { padding: 8px 4px; }
  .net-game b { font-size: 15px; }
}

/* ---------- 가로로 누운 폰 (높이 낮음) ---------- */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #bar { padding-top: calc(3px + var(--safe-top)); padding-bottom: 3px; }
  #barTitle { font-size: 19px; }
  .icon-btn { width: 40px; height: 36px; font-size: 19px; }
  .hero canvas { max-width: 300px !important; }
  .hero .title { font-size: 34px; }
  .hero .sub { font-size: 14px; }
  .modal { max-height: 96%; }
  .char-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .count-overlay b { font-size: 80px; }
  .cheer-pop { top: calc(48px + var(--safe-top)); }
}

/* ---------- 폰을 가로로 들었을 때 게임 중이면: 세로로 돌려 달라고 안내 ---------- */
/* 게임은 세로 폰 기준이라 가로 폰에서는 무대가 절반 크기로 작아진다. 태블릿 가로(높이 500 이상)는 그대로 둔다 */
.rotate-hint { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  #app:has(#screen.full .stage-host):not(.rotate-ok) .rotate-hint {
    display: flex; position: absolute; inset: 0; z-index: 30; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    background: rgba(255,247,234,0.94); text-align: center; padding: 16px;
  }
}
.rotate-hint .phone { font-size: 54px; animation: tilt 1.6s ease-in-out infinite; }
.rotate-hint b { font: 24px var(--font); font-weight: normal; }
.rotate-hint p { margin: 0; font: 15px var(--font); color: var(--coffee); }
@keyframes tilt { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }

/* 게임별 싱글 / 멀티 진입 */
.mode-entry { max-width: 560px; margin: 0 auto; text-align: center; }
.mode-cover { width: 100%; max-width: 280px; aspect-ratio: 4/3; border: 3px solid #3b2418; border-radius: 24px; }
.mode-choice { display: block; margin: 12px 0; padding: 20px 14px; }
.mode-choice small { display: block; margin-top: 8px; font-size: 15px; line-height: 1.5; }
.mode-entry .panel { margin: 18px 0; text-align: left; padding: 20px; }
.mode-entry label { display: block; margin-bottom: 8px; }
.mode-entry input { box-sizing: border-box; width: 100%; margin-bottom: 14px; min-height: 48px; }

/* Single-sport launch; archived games remain available in the source. */
.games.race-release { grid-template-columns:minmax(0,640px); justify-content:center; }

/* 준비 버튼의 그림자와 안내 문구 사이 여백 */
.ready-hint { display: block; margin-top: 14px; line-height: 1.6; }

/* 캐릭터 선택 카드와 소리 확인 버튼 사이 여백 */
.entry-sound-check { margin-top: 20px; }

/* ---------- 토스 미니앱 (앱인토스) ---------- */
/* 게임 유형은 투명 내비게이션 바에 토스 ⋯·✕ 버튼만 오른쪽 위(안전 영역 아래 5–10px)에 뜬다.
   그 자리(약 100px)를 비우고, 소리 버튼은 JS 가 뒤로 버튼 옆으로 옮긴다. 안전 영역은 SDK 값으로 --safe-top/bottom 을 채운다 */
.toss #bar { padding-right: 112px; }
.toss #barTitle { text-align: left; padding-left: 2px; }
.toss #back.hidden { display: none; }
.toss #app { padding-bottom: var(--safe-bottom); }
.toss .pad { padding-bottom: 24px; }
/* 로컬 미리보기(?toss=1): 노치 영역과 토스 버튼 흉내 */
.toss-preview body::before { content: ''; position: fixed; z-index: 60; left: 0; right: 0; top: 0; height: var(--safe-top); background: rgba(0, 0, 0, 0.12); pointer-events: none; }
.toss-preview body::after { content: ''; position: fixed; z-index: 60; left: 50%; bottom: 8px; width: 134px; height: 5px; margin-left: -67px; border-radius: 3px; background: rgba(0, 0, 0, 0.35); pointer-events: none; }
.toss-fake-nav { position: fixed; z-index: 61; top: calc(var(--safe-top) + 5px); right: 10px; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 17px; background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(0, 0, 0, 0.1); font: 18px/1 -apple-system, sans-serif; color: #333; pointer-events: none; }
.toss-fake-nav i { width: 1px; height: 16px; background: rgba(0, 0, 0, 0.15); }

/* ---------- 검색용 소개글 (index.html) ---------- */
/* 자바스크립트가 돌면 boot.js 가 html.js 를 붙여 바로 숨긴다. 검색 로봇·자바스크립트 꺼진 브라우저만 본다 */
.js .seo-intro { display: none; }
.seo-intro { color: var(--ink); line-height: 1.7; font-size: 15px; }
.seo-intro h1 { font: 26px var(--font); margin: 8px 0 12px; }
.seo-intro h2 { font: 19px var(--font); margin: 20px 0 6px; }
.seo-intro dt { font-weight: 700; margin-top: 8px; }
.seo-intro dd { margin: 2px 0 0; }
