:root {
  --card: rgba(255, 255, 255, .9);
  --card-solid: #ffffff;
  --field-bg: #f2faef;
  --line: rgba(46, 140, 70, .22);
  --text: #163a22;
  --muted: #5a7b62;
  --ok: #23a34a;
  --ok-2: #3cc567;
  --warn: #ff8a00;
  --op: #f0437a;
  --ready: #22c55e;
  --c0: #1f8bff;
  --c1: #f0437a;
  --c2: #ff9f1c;
  --c3: #22b35e;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  overscroll-behavior: none;
}

/* 맑은 하늘 + 잔디 */
body {
  background:
    radial-gradient(ellipse 60% 40% at 20% 0%, rgba(255, 255, 255, .9), transparent 70%),
    linear-gradient(180deg, #eef9ff 0%, #d4efff 40%, #c9ecc0 72%, #9fd88f 100%);
  background-color: #d4efff;
  background-attachment: fixed;
}

button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 18px 50px rgba(30, 110, 60, .18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin: auto;
}
.card.center { text-align: center; }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { margin: 0 0 4px; font-size: 26px; }
.title-text {
  background: linear-gradient(90deg, #1f9d48, #2bb3a0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2 { margin: 0 0 8px; font-size: 28px; }
.logo { display: inline-block; animation: sway 2.4s ease-in-out infinite alternate; transform-origin: 30% 100%; }
@keyframes sway { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.sub { color: var(--muted); margin: 6px 0 14px; font-size: 14px; word-break: keep-all; overflow-wrap: break-word; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  font-size: 16px; /* iOS 확대 방지 */
  outline: none;
}
.field input::placeholder { color: #9bb8a2; }
.field input:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(35, 163, 74, .18); background: #fff; }

.row { display: flex; gap: 8px; align-items: center; }
.row.gap { justify-content: center; margin-bottom: 8px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.tab { border: 0; background: transparent; padding: 10px; min-height: 44px; border-radius: 9px; color: var(--muted); font-weight: 700; }
.tab.active { background: #fff; color: var(--ok); box-shadow: 0 2px 8px rgba(30, 110, 60, .15); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  flex: 1 0 auto;
  min-width: 56px;
  min-height: 44px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  font-weight: 600;
}
.chips button.active { border-color: var(--ok); background: #fff; color: var(--ok); box-shadow: 0 0 0 2px rgba(35, 163, 74, .15); }

.primary {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ok-2), var(--ok));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  margin-top: 4px;
  box-shadow: 0 8px 22px rgba(35, 163, 74, .32);
}
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .5; }

.ghost {
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ok);
  font-weight: 700;
  margin-top: 8px;
}
.ghost.wide { width: 100%; }

.icon-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
}
.icon-btn.small { width: 36px; height: 36px; font-size: 14px; }

.help-link {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ok);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  min-height: 44px; /* 손가락으로 누르기 쉽게 (2026-11-01) */
}

.rules { margin-top: 18px; font-size: 14px; color: var(--muted); }
.rules summary { cursor: pointer; color: var(--text); font-weight: 700; }
.rules ol { padding-left: 20px; line-height: 1.6; }
.rules b { color: var(--text); }

.conn { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }
.conn.ok::before { content: "● "; color: var(--ready); }
.conn.bad::before { content: "● "; color: var(--op); }

.big-code { font-size: 44px; font-weight: 900; letter-spacing: 6px; margin: 4px 0 10px; word-break: break-all; color: var(--ok); }

.spinner {
  width: 40px;
  height: 40px;
  margin: 14px auto 8px;
  border: 4px solid rgba(35, 163, 74, .15);
  border-top-color: var(--ok);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.dot.c0 { background: var(--c0); } .dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); } .dot.c3 { background: var(--c3); }

.wait-list { list-style: none; margin: 6px auto 0; padding: 0; max-width: 260px; text-align: left; }
.wait-list li { padding: 8px 12px; margin: 6px 0; border-radius: 10px; background: var(--field-bg); border: 1px solid var(--line); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-list li.empty { color: #9fb9a6; font-weight: 500; border-style: dashed; }

/* ---- 조작법 ---- */
.help-card { max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.help-card h2 { font-size: 24px; text-align: center; }
.help-figure {
  display: block;
  width: 100%;
  height: auto;
  margin: 4px 0 8px;
  border-radius: 14px;
  background: radial-gradient(ellipse 90% 120% at 30% -30%, rgba(255, 255, 255, .35), transparent 70%), linear-gradient(180deg, #5cb85a, #469b45);
}
.help-steps { list-style: none; padding: 0; margin: 0 0 12px; }
.help-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.5;
}
.help-steps li:last-child { border-bottom: 0; }
.help-steps .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(35, 163, 74, .1); font-size: 17px; }
.help-steps b { color: var(--text); }
.help-steps .op { color: var(--op); font-weight: 700; }
.help-steps .warn { color: var(--warn); font-weight: 700; }
.help-steps .grav { color: #2346c7; font-weight: 700; }
.sci-title { margin: 6px 0 2px; font-size: 16px; color: var(--ok); }
.sci-steps .ico { background: rgba(43, 179, 160, .14); }
.device { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: rgba(35, 163, 74, .1); color: var(--ok); font-weight: 700; margin-right: 4px; }

/* ---- 게임 화면 ---- */
#game {
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: #bfe3ff;
}

#hud {
  display: grid;
  grid-template-columns: 1fr minmax(0, 1.4fr) 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.hud-left, .hud-right { min-width: 0; }
.hud-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hole-label { font-weight: 900; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.hud-mid { text-align: center; min-width: 0; }
.turn-label { font-weight: 900; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-bar { height: 6px; border-radius: 4px; background: #dcebdc; overflow: hidden; margin: 4px auto 3px; max-width: 220px; }
.turn-fill { height: 100%; width: 0; background: var(--ok); transition: background .2s; }
.turn-fill.urgent { background: var(--op); }
.stroke-label { font-weight: 900; font-size: 15px; white-space: nowrap; }
.board-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 800; color: var(--ok); white-space: nowrap; }

#stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: block;
}
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.tag.c0 { background: var(--c0); } .tag.c1 { background: var(--c1); } .tag.c2 { background: var(--c2); } .tag.c3 { background: var(--c3); }
.tag.turn { outline: 2px solid #fff; font-size: 12px; }
.flabel {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.flabel.force { color: #c25e00; border: 2px solid var(--warn); }
.flabel.force.over { color: #d10000; border-color: #ff2020; }

.banner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  animation: pop .35s ease-out;
  max-width: 92%;
}
.banner #bannerText { font-size: 40px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .18), 0 0 18px rgba(0, 0, 0, .25); white-space: nowrap; }
.banner #bannerSub { font-size: 15px; font-weight: 800; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .45); margin-top: 2px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.nogl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 700; padding: 20px; }

#footbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 10px;
  background: rgba(255, 255, 255, .92);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.band-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.band-title { font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.band-chips { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 420px; }
.band-chips button {
  border: 1px solid var(--line);
  background: var(--field-bg);
  border-radius: 10px;
  padding: 5px 4px;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.band-chips button.active { background: #fff; border-color: var(--ok); color: var(--ok); box-shadow: 0 0 0 2px rgba(35, 163, 74, .15); }
.band-swatch { display: block; width: 26px; border-radius: 3px; margin-bottom: 3px; }
.band-swatch.b0 { height: 3px; background: #8fd14f; }
.band-swatch.b1 { height: 5px; background: #f2b134; }
.band-swatch.b2 { height: 8px; background: #7a4bc2; }
.help-q { color: var(--ok); font-weight: 900; font-size: 17px; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(200, 235, 205, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
}
.overlay.soft { background: rgba(200, 235, 205, .3); backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; }
.overlay.fixed { position: fixed; }
.overlay .card { max-height: calc(100% - 8px); overflow-y: auto; }

.res-list { list-style: none; margin: 8px 0; padding: 0; text-align: left; }
.res-list li { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
.res-list li:last-child { border-bottom: 0; }
.res-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-list .sc { font-weight: 900; }
.res-list .lb { font-size: 12px; color: var(--muted); margin-left: 6px; min-width: 56px; text-align: right; }
.note { background: #eefaf6; border: 1px solid rgba(43, 179, 160, .35); border-radius: 12px; padding: 10px 12px; text-align: left; font-size: 14px; }
.note b { color: #1f7f86; }
.note p { margin: 4px 0 0; line-height: 1.5; }

.board-card { max-width: 560px; }
.table-wrap { overflow-x: auto; margin: 8px 0 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); }
td.nm { text-align: left; font-weight: 800; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
td.tot { font-weight: 900; }
tr.me td { background: rgba(35, 163, 74, .08); }
tr.win td.nm::after { content: " 👑"; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 74px));
  transform: translateX(-50%);
  background: var(--card-solid);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 10px 30px rgba(30, 110, 60, .2);
}
.toast.warn { background: #fff4e6; border-color: var(--warn); color: #8a4a00; }

/* 가로로 짧은 화면(가로 모드 휴대폰) */
@media (max-height: 480px) {
  #hud { padding: 3px 12px; }
  .turn-label { font-size: 15px; }
  #footbar { padding: 3px 12px 4px; }
  .band-chips button { padding: 2px 4px; flex-direction: row; gap: 4px; justify-content: center; }
  .band-swatch { display: none; }
  .banner #bannerText { font-size: 30px; }
}
@media (max-width: 480px) {
  #hud { grid-template-columns: 1fr 1.5fr 1fr; padding: 6px 8px; gap: 4px; }
  .hole-label { font-size: 14px; }
  .turn-label { font-size: 15px; }
  .stroke-label { font-size: 13px; }
  .band-title { display: none; }
  .banner #bannerText { font-size: 32px; }
}

/* 계정 칩 (아이디 · 골드 · 상점) */
.acct-slot { display: flex; justify-content: flex-end; margin: -6px -4px 10px; min-height: 44px; }
.acct-slot:empty { display: none; }
/* 🎵 음악 단추: 로비는 계정 칩 왼쪽, 경기 중은 아래 줄 (2026-10-31) */
.acct-row { display: flex; align-items: flex-start; gap: 8px; margin: -6px -4px 10px; }
.acct-row .acct-slot { flex: 1; min-width: 0; margin: 0; }
.acct-row .mus { margin-top: 0; width: 44px; height: 44px; } /* 누르기 쉽게 44px (2026-11-07) */
.icon-btn.mus { font-size: 16px; padding: 0; }
.icon-btn.mus.off { opacity: .6; }
.kit-root h2 { font-size: 22px; }
.gold-line { margin: 4px 0 10px; font-weight: 800; color: #b87400; min-height: 1em; }
.gold-line:empty { display: none; }

/* 버튼 크기 설정 (프로필 → 버튼 크기): --kit-btn-scale 0.8 / 1 / 1.25 / 1.5 */
#footbar .icon-btn.small { width: calc(36px * var(--kit-btn-scale, 1)); height: calc(36px * var(--kit-btn-scale, 1)); font-size: calc(14px * var(--kit-btn-scale, 1)); border-radius: calc(12px * var(--kit-btn-scale, 1)); }
#footbar .icon-btn.small { min-width: 44px; min-height: 44px; } /* 컴퓨터에서도 44px (2026-11-07) */
#footbar .help-q { font-size: calc(17px * var(--kit-btn-scale, 1)); }
.band-chips button { font-size: calc(13px * var(--kit-btn-scale, 1)); min-height: calc(36px * var(--kit-btn-scale, 1)); justify-content: center; }
.band-chips { max-width: calc(420px * var(--kit-btn-scale, 1)); }
.board-btn { font-size: calc(12px * var(--kit-btn-scale, 1)); padding: calc(3px * var(--kit-btn-scale, 1)) calc(10px * var(--kit-btn-scale, 1)); }
@media (max-height: 480px) {
  .band-chips button { min-height: calc(28px * var(--kit-btn-scale, 1)); }
}

/* 휴대폰: 판 중 고무줄·점수표 단추를 누르는 칸 44px (보이는 모양은 그대로, 가로 화면에서 판이 작아지지 않게 ::after 로만 넓힘) */
@media (pointer: coarse) {
  .band-chips button, .board-btn { position: relative; }
  .band-chips button::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: max(100%, 44px); transform: translateY(-50%); }
  .board-btn::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
}
@media (pointer: coarse) and (min-height: 481px) {
  .band-chips button { min-height: max(44px, calc(36px * var(--kit-btn-scale, 1))); }
}

/* ---------- ⚡ 빠른 대전 (2026-11-03) ---------- */
.quick-btn { width: 100%; min-height: 56px; margin: 4px 0 12px; padding: 8px 12px; border: 0; border-radius: 14px; display: grid; gap: 1px; justify-items: center; cursor: pointer; color: #2a2f55; background: linear-gradient(135deg, #ffe08a, #ff9a5c); box-shadow: 0 8px 20px rgba(255, 154, 92, .3); font: inherit; }
.quick-btn b { font-size: 17px; font-weight: 900; }
.quick-btn small { font-size: 12px; font-weight: 700; color: rgba(42, 47, 85, .78); }
.quick-btn:active { transform: scale(.98); }
/* 빠른 대전 대기실: 초대 단추·지금 시작 없이 (서버가 짝을 정해 줌) */
#waiting.qm .row.gap, #waiting.qm #startNow { display: none; }
/* 낮은 가로 화면(휴대폰 가로): 💬 채팅 창은 단추 오른쪽 위에 화면 높이만큼 */
@media (max-height: 520px) and (orientation: landscape) {
  .qm-panel { top: max(8px, env(safe-area-inset-top)) !important; left: calc(68px + env(safe-area-inset-left)) !important; max-height: calc(100dvh - 16px) !important; }
}

/* ---------- 🎬 첫 화면 배경 (kit/title.css 위에 새총 골프 색·하늘과 언덕·떠다니는 구름·깃발·공, 2026-11-10) ---------- */
#title { --lt-a: #2fb455; --lt-b: #1fb6d9; --lt-ink: #163a22; --lt-muted: #4f6e57; --lt-brand: #23a34a; --lt-sh: #178a6e; --lt-glow: rgba(35, 163, 74, .35); --lt-bgc: #dff6e3;
  background-image: linear-gradient(180deg, #b9ecff 0%, #dff6ff 38%, #bdeab0 38.2%, #8fd77f 100%); }
#title .sg-hill, #title .sg-sand { position: absolute; border-radius: 50%; }
#title .sg-h1 { left: -30%; right: -10%; top: 34%; height: 80%; background: #a6e294; }
#title .sg-h2 { left: -10%; right: -40%; top: 58%; height: 80%; background: #86d273; }
#title .sg-sand { right: 10%; bottom: 8%; width: 160px; height: 40px; background: #f2df9b; }
#title .lt-o { filter: drop-shadow(0 6px 10px rgba(20, 70, 35, .25)); }
#title .sg-e { font-size: 44px; }
#title .c1 { top: 7%; left: 4%; } #title .c2 { top: 16%; right: 6%; }
#title .f1 { top: 30%; right: 9%; } #title .s1 { top: 33%; left: 6%; --r: -8deg; }
#title .b1 { top: 13%; left: 42%; } #title .f2 { bottom: 9%; left: 12%; }
#title .b2 { bottom: 17%; right: 12%; } #title .b3 { bottom: 17%; left: 10%; }
#title .e1 { bottom: 6%; right: 12%; font-size: 46px; } #title .e2 { bottom: 3%; left: 45%; font-size: 34px; }
@media (orientation: landscape) and (max-height: 500px) {
  #title .lt-o svg { transform: scale(.75); transform-origin: 0 0; }
  #title .sg-e { font-size: 34px; } #title .e2 { font-size: 26px; }
  #title .c1 { top: 4%; left: 3%; } #title .c2 { top: 22%; right: 4%; } #title .b1 { top: 4%; left: 30%; }
  #title .f1 { top: 40%; right: 12%; } #title .s1 { top: 36%; left: 10%; }
  #title .b2 { bottom: 22%; right: 22%; } #title .b3 { bottom: 24%; left: 22%; } #title .f2 { bottom: 6%; left: 8%; }
  #title .e2 { bottom: 4%; left: 30%; }
}
