/* 팥빙수 똑같이 나눠주기 작전 2탄! — 화면 틀은 1탄(games/bingsoo/style.css)과 같고, 아래쪽에 2탄 전용 도구를 붙였다.
   2026-10-24 사용자: 제빵냥처럼 장면 하나. 마우스 PC는 16:10 장면을 화면 가운데에 맞추고(폭 1280까지),
   폰·태블릿은 화면을 꽉 채운다. 페이지는 어디서도 스크롤되지 않는다. */
:root {
  --ink: #2b1d14;
  --muted: #7c6a5c;
  --bean: #7a2e1a;
  --bean-dark: #4a1a0e;
  --milk: #fffaf3;
  --cream: #fbefe2;
  --line: #efdccb;
  --berry: #ec4899;
  --berry-soft: #fdf2f8;
  --ice: #f3faff;
  --sky: #0284c7;
  --happy: #10b981;
  --upset: #f59e0b;
  --angry: #ef4444;
  --radius-lg: 22px;
  --radius-md: 14px;
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
  --font-title: 'Jua', 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 아이폰 사파리: 입력칸은 글자를 고를 수 있어야 하고, 16px보다 작으면 누를 때 화면이 확대된다 */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
  font-size: 16px;
}

button, a { touch-action: manipulation; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  word-break: keep-all;
  background-color: #fde8ef;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.9) 1.6px, transparent 1.7px),
    radial-gradient(rgba(255, 255, 255, 0.6) 1.2px, transparent 1.3px),
    linear-gradient(160deg, #fde8ef 0%, #e6f4ff 55%, #dff1ff 100%);
  background-size: 34px 34px, 34px 34px, 100% 100%;
  background-position: 0 0, 17px 17px, 0 0;
}

/* ---------- 장면 ---------- */
.game-app {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  background: var(--milk);
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
  gap: 8px;
}

/* 마우스 PC 가로 창: 16:10 장면 하나를 가운데에, 폭 1280까지. 세로로 긴 창은 폰처럼 꽉 채운다 */
@media (hover: hover) and (pointer: fine) and (min-width: 760px) and (min-height: 500px) and (min-aspect-ratio: 5/4) {
  .game-app {
    right: auto;
    bottom: auto;
    left: 50%;
    top: 50%;
    width: min(calc(100vw - 32px), 1280px, calc((100vh - 32px) * 1.6));
    height: min(calc((100vw - 32px) / 1.6), 800px, calc(100vh - 32px));
    transform: translate(-50%, -50%);
    border-radius: 28px;
    padding: 14px 18px 16px;
    gap: 12px;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(122, 46, 26, 0.08), 0 24px 60px -18px rgba(122, 46, 26, 0.35);
  }
}

/* ---------- 위쪽 띠 ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  min-height: 48px;
  position: relative;
  z-index: 2;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-logo {
  width: 46px;
  height: 46px;
  flex: none;
}

.hud-logo svg { width: 100%; height: 100%; display: block; }

.hud-brand h1 {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 1.45rem;
  color: var(--bean);
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-stats {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: none;
}

.hud-chip,
.hud-player {
  position: relative;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 70px;
}

.hud-chip .label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
}

.hud-chip .value {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--bean);
  line-height: 1.1;
  white-space: nowrap;
}

.hud-chip .value small {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.hud-chip.is-score {
  background: var(--berry-soft);
  border-color: #f9a8d4;
}

.hud-chip.is-score .value { color: #be185d; }

.round-gain {
  position: absolute;
  top: -9px;
  right: -8px;
  background: var(--happy);
  color: #fff;
  font-family: var(--font-title);
  font-size: 0.85rem;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.35);
  animation: gain-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.round-gain.is-low { background: var(--upset); box-shadow: 0 3px 8px rgba(245, 158, 11, 0.35); }
.round-gain.is-zero { background: #94a3b8; box-shadow: none; }

@keyframes gain-pop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.hud-player {
  align-items: flex-start;
  min-width: 0;
  max-width: 150px;
  background: var(--cream);
}

.player-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.25;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-id {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- 보드 ---------- */
.game-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.game-board {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--ice);
  border-radius: var(--radius-lg);
  border: 2px solid #d6ecfb;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.85), inset 0 6px 18px rgba(2, 132, 199, 0.06);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

.board-grid-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(2, 132, 199, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(2, 132, 199, 0.07) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center center;
  pointer-events: none;
}

.line-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.elements-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  /* iOS clips transformed children inside overflow:hidden + border-radius
     unless this layer is composited on its own. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ---------- 친구 ---------- */
.student-pin {
  position: absolute;
  -webkit-transform: translate3d(-50%, -50%, 0);
  transform: translate3d(-50%, -50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.student-emoji-box {
  background: #ffffff;
  border: 3.5px solid var(--sky);
  border-radius: 50%;
  width: 58px;
  height: 58px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 6px 14px rgba(43, 29, 20, 0.18);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* 친구 얼굴(shared/halomath-bingsoo-faces.js가 그리는 SVG) */
.student-emoji-box .friend-face {
  width: 100%;
  height: 100%;
  display: block;
}

.student-pin.mood-angry .student-emoji-box {
  border-color: var(--angry) !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.65);
  animation: shake-head 0.4s infinite ease-in-out;
}

.student-pin.mood-happy .student-emoji-box {
  border-color: var(--happy) !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
  transform: scale(1.12);
}

.student-pin.mood-disappointed .student-emoji-box {
  border-color: var(--upset) !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.55);
}

.student-pin.mood-neutral .student-emoji-box {
  border-color: var(--sky) !important;
}

@keyframes shake-head {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* ---------- 내 팥빙수 (점은 그릇 한가운데) ---------- */
.placed-bingsoo-pin {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: auto;
  cursor: grab;
  z-index: 20;
  transition: opacity 0.3s ease;
}

.bingsoo-icon {
  position: absolute;
  left: -28px;
  top: -28px;
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 5px 6px rgba(43, 29, 20, 0.25));
  transition: transform 0.08s ease-out;
}

.bingsoo-icon svg { width: 100%; height: 100%; display: block; }

.bingsoo-label {
  position: absolute;
  top: 27px;
  left: 0;
  transform: translateX(-50%);
  background: var(--bean);
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(74, 26, 14, 0.3);
  transition: background 0.2s ease;
}

.placed-bingsoo-pin.is-answer .bingsoo-label {
  background: var(--happy);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.45);
}

.placed-bingsoo-pin.transparent-mode .bingsoo-icon {
  opacity: 0.88;
}

.placed-bingsoo-pin.is-dragging { cursor: grabbing !important; z-index: 30; }
.placed-bingsoo-pin.is-dragging .bingsoo-icon { transform: scale(1.15); }

/* ---------- 거리 표시 ---------- */
.distance-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--sky);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 12;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(43, 29, 20, 0.15);
}

/* ---------- 라운드 점수 알림 ---------- */
.score-popup {
  position: absolute;
  top: 70px; /* 안내 말풍선 아래 */
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  pointer-events: none;
}

.score-card-inner {
  background: #fff;
  border: 3px solid #fbcfe8;
  border-radius: 20px;
  padding: 10px 30px 12px;
  text-align: center;
  box-shadow: 0 14px 30px -8px rgba(122, 46, 26, 0.35);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: auto;
  cursor: pointer;
}

@keyframes zoomIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.rating-badge {
  background: var(--berry-soft);
  color: #be185d;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.score-number {
  font-family: var(--font-title);
  font-size: 3rem;
  color: var(--bean);
  line-height: 1.05;
}

.distance-info {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- 아래쪽 띠 ---------- */
.controls-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
}

/* 지금 할 일: 원래처럼 보드 위쪽 가운데에 뜬 짙은 말풍선(2026-10-24 사용자).
   친구는 이 말풍선 아래에만 놓인다(game.js isPointInside의 +48) */
.instruction-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: 92%;
  width: max-content;
  background: rgba(43, 29, 20, 0.9);
  color: #fff8ef;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  word-break: keep-all;
  padding: 7px 18px;
  border-radius: 18px;
  box-shadow: 0 6px 16px -6px rgba(43, 29, 20, 0.55);
  pointer-events: none;
  animation: banner-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), pulse-bounce 2s 0.35s infinite ease-in-out;
}

.instruction-banner b {
  font-family: var(--font-title);
  font-weight: 400;
  color: #fbcfe8;
  font-size: 1.1em;
}

@keyframes banner-pop {
  0% { transform: translateX(-50%) scale(0.92); opacity: 0.4; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes pulse-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

.controls-buttons {
  flex: none;
  display: flex;
  gap: 8px;
}

/* ---------- 단추 ---------- */
.btn {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: inherit;
}

.btn-primary {
  background: linear-gradient(180deg, #8f3b22, var(--bean));
  color: #fff7ee;
  box-shadow: 0 4px 0 var(--bean-dark), 0 8px 16px -6px rgba(74, 26, 14, 0.5);
}

.btn-accent {
  background: linear-gradient(180deg, #fcd34d, #fbbf24);
  color: #5a3300;
  box-shadow: 0 4px 0 #b7791f, 0 8px 16px -6px rgba(183, 121, 31, 0.55);
}

.btn-secondary {
  background: #0d9488;
  color: #fff;
  box-shadow: 0 4px 0 #0f5f58;
}

.btn-primary:active:not(:disabled),
.btn-accent:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled),
  .btn-accent:hover:not(:disabled) { filter: brightness(1.06); }
}

.controls-buttons .btn {
  min-width: 170px;
  min-height: 48px;
  font-size: 1.05rem;
}

.btn-outline {
  background: #fff;
  border: 2px solid var(--line);
  color: var(--ink);
}

@media (hover: hover) {
  .btn-outline:hover { background: var(--cream); }
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ---------- 창 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 29, 20, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
}

.modal-card {
  background: var(--milk);
  border: 3px solid #fff;
  border-radius: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 20px;
  box-shadow: 0 30px 60px -20px rgba(43, 29, 20, 0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card.modal-lg { max-width: 640px; }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-header {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modal-trophy { font-size: 1.6rem; }

.modal-header h2 {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 1.7rem;
  color: var(--bean);
}

.modal-footer.centered-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* 첫 창: 1위·게임 소개·이름 */
.modal-opening {
  max-width: 440px;
  text-align: center;
  gap: 10px;
}

.opening-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.opening-banner h2 {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 1.3rem;
  color: var(--bean);
}

.opening-subtitle {
  font-size: 0.74rem;
  font-weight: 800;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 10px;
  border-radius: 999px;
}

.champ-card {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, #fff7d6, #fde68a);
  border: 2px solid #f6c453;
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  overflow: hidden;
}

.champ-gold-shimmer {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  transform: rotate(30deg);
  animation: gold-sweep 3.5s infinite;
  pointer-events: none;
}

@keyframes gold-sweep {
  0% { transform: translateX(-100%) rotate(30deg); }
  100% { transform: translateX(100%) rotate(30deg); }
}

.champ-trophy { font-size: 1.7rem; z-index: 2; }

.champ-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  z-index: 2;
}

.champ-name {
  font-size: 1rem;
  font-weight: 800;
  color: #78350f;
}

.champ-id {
  font-size: 0.74rem;
  color: #92400e;
  font-weight: 700;
}

.champ-score {
  font-family: var(--font-title);
  font-size: 1.7rem;
  color: #b45309;
  z-index: 2;
}

.champ-score small { font-size: 0.9rem; }

.style-toggle-btn {
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 999px;
}

.opening-leaderboard-box {
  width: 100%;
  margin-top: 4px;
}

.opening-leaderboard-box .leaderboard-table-wrapper {
  max-height: 34vh;
  overflow-y: auto;
}

.game-guide-box.short-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 8px 12px;
  text-align: left;
}

.guide-bowl {
  flex: none;
  width: 44px;
  height: 44px;
}

.guide-bowl svg { width: 100%; height: 100%; display: block; }

.game-guide-box.short-banner .guide-title {
  font-family: var(--font-title);
  font-size: 1.08rem;
  color: var(--bean);
}

.game-guide-box.short-banner .guide-desc {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  margin-bottom: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink);
}

.form-input {
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.form-input:focus { border-color: #f9a8d4; }

.profile-lead {
  margin: 0 0 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.profile-err {
  margin: 6px 0 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  font-weight: 700;
  color: #b91c1c;
}

.style-sparkle-btn { width: 100%; }

.privacy-link-btn {
  display: inline-block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: underline;
}

.privacy-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.84rem;
  color: #3f3128;
  line-height: 1.5;
  text-align: left;
}

/* 끝 창 */
.final-score-box {
  background: linear-gradient(160deg, #8f3b22, var(--bean));
  color: #fff7ee;
  border-radius: 18px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.final-label {
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0.9;
}

.final-score {
  font-family: var(--font-title);
  font-size: 3rem;
  line-height: 1;
}

.final-score small {
  font-size: 1rem;
  opacity: 0.8;
}

.new-record-badge {
  background: #fbbf24;
  color: #5a3300;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.send-action-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-locked-player-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border: 2px solid var(--line);
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 0.86rem;
  color: var(--ink);
}

.locked-text strong { color: var(--bean); }

.api-status-msg {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  min-height: 18px;
}

.api-status-msg.success { color: #15803d; }
.api-status-msg.error { color: #dc2626; }

.leaderboard-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-header h3,
.round-breakdown h3 {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
}

.leaderboard-table-wrapper {
  border-radius: 12px;
  border: 2px solid var(--line);
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.84rem;
}

.leaderboard-table th {
  background: var(--cream);
  color: var(--bean);
  padding: 6px;
  font-weight: 800;
  position: sticky;
  top: 0;
}

.leaderboard-table td {
  padding: 6px 8px;
  border-top: 1px solid #f4e7da;
  background: #fff;
}

.leaderboard-table tr.current-player-row td {
  background: var(--berry-soft) !important;
  font-weight: 800;
  color: #be185d;
}

@keyframes lb-skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.lb-skeleton-row td { vertical-align: middle; }

.lb-skeleton-bar {
  display: block;
  height: 0.85em;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(160, 130, 110, 0.2) 25%, rgba(160, 130, 110, 0.4) 37%, rgba(160, 130, 110, 0.2) 63%);
  background-size: 400% 100%;
  animation: lb-skeleton-shimmer 1.15s ease-in-out infinite;
}

.lb-skeleton-bar.w-xs { width: 22%; }
.lb-skeleton-bar.w-sm { width: 36%; }
.lb-skeleton-bar.w-md { width: 58%; }
.lb-skeleton-bar.w-lg { width: 44%; }

.champ-name .lb-skeleton-bar,
.champ-id .lb-skeleton-bar,
.champ-score .lb-skeleton-bar { margin: 0.15em 0; }

.rank-1 { color: #d97706; font-weight: 800; }
.rank-2 { color: #64748b; font-weight: 800; }
.rank-3 { color: #b45309; font-weight: 800; }

/* 라운드별 성적: 다섯 칸 한 줄 */
.history-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.history-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 6px 2px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.history-item .round-tag {
  font-weight: 800;
  color: var(--bean);
  font-size: 0.68rem;
}

.history-item .score-tag {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: #be185d;
  order: -1;
}

.hidden { display: none !important; }

/* ---------- 폰 세로·좁은 화면 ---------- */
@media (max-width: 640px) {
  .hud { gap: 6px; min-height: 0; }
  .hud-brand h1 { display: none; }
  .hud-logo { width: 40px; height: 40px; }
  .hud-stats { flex: 1 1 auto; min-width: 0; gap: 4px; justify-content: flex-end; }
  .hud-chip { min-width: 0; flex: 0 1 64px; padding: 3px 6px; }
  .hud-chip .value { font-size: 1.05rem; }
  .hud-player { flex: 0 1 92px; padding: 3px 8px; }
  .round-gain { top: auto; bottom: -9px; right: -6px; font-size: 0.72rem; padding: 2px 6px; }
  .player-name { font-size: 0.78rem; }

  .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .instruction-banner {
    font-size: 0.84rem;
    padding: 6px 12px;
  }
  .score-popup { top: 62px; }
  .controls-buttons .btn { flex: 1 1 auto; min-width: 0; }

  .student-emoji-box { width: 46px; height: 46px; border-width: 3px; }
  .bingsoo-icon { left: -24px; top: -24px; width: 48px; height: 48px; }
  .bingsoo-label { top: 23px; }
  .score-number { font-size: 2.4rem; }
  .score-card-inner { padding: 8px 22px 10px; }

  .modal-card { padding: 14px 14px; gap: 10px; }
  .history-item .score-tag { font-size: 0.95rem; }
}

/* ---------- 낮은 화면(폰 가로) ---------- */
@media (max-height: 520px) {
  .game-app { gap: 6px; }
  .hud { min-height: 0; }
  .hud-logo { width: 34px; height: 34px; }
  .hud-brand h1 { font-size: 1.15rem; }
  .hud-chip { padding: 2px 10px; }
  .hud-chip .label { font-size: 0.62rem; }
  .hud-chip .value { font-size: 1rem; }
  .controls-bar { min-height: 0; flex-direction: row; align-items: center; }
  .instruction-banner { top: 6px; font-size: 0.8rem; padding: 4px 12px; }
  .score-popup { top: 52px; }
  .controls-buttons .btn { min-height: 40px; min-width: 150px; padding: 6px 16px; flex: none; }
  .student-emoji-box { width: 44px; height: 44px; border-width: 3px; }
  .bingsoo-icon { left: -22px; top: -22px; width: 44px; height: 44px; }
  .bingsoo-label { top: 21px; font-size: 0.66rem; }
  .score-number { font-size: 2rem; }
  .score-card-inner { padding: 6px 18px 8px; }

  /* 창 안을 내리지 않게 두 칸으로 */
  .modal-card { padding: 12px 16px; gap: 8px; }
  .modal-card.modal-opening { max-width: 760px; }
  #player-modal .modal-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    column-gap: 16px;
  }
  #player-modal .opening-banner { grid-column: 1; grid-row: 1 / span 2; }
  #player-modal .game-guide-box { grid-column: 2; grid-row: 1; }
  #player-modal .modal-body { grid-column: 2; grid-row: 2; }
  #player-modal .opening-leaderboard-box .leaderboard-table-wrapper { max-height: 40vh; }
  .opening-banner h2 { font-size: 1.1rem; }

  /* 왼쪽: 제목·점수·참가자·라운드별, 오른쪽: 순위표와 새 게임 단추 */
  #result-modal .modal-card {
    max-width: 820px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-rows: auto auto auto 1fr;
    column-gap: 14px;
    row-gap: 6px;
    align-items: start;
  }
  #result-modal .modal-body { display: contents; }
  #result-modal .modal-header { grid-column: 1; grid-row: 1; }
  #result-modal .modal-header h2 { font-size: 1.2rem; }
  #result-modal .modal-trophy { font-size: 1.2rem; }
  #result-modal .final-score-box { grid-column: 1; grid-row: 2; padding: 6px; }
  #result-modal .send-action-box { grid-column: 1; grid-row: 3; }
  #result-modal .round-breakdown { grid-column: 1; grid-row: 4; }
  #result-modal .leaderboard-section { grid-column: 2; grid-row: 1 / span 3; }
  #result-modal .leaderboard-table-wrapper { max-height: 55vh; overflow-y: auto; }
  #result-modal .modal-footer { grid-column: 2; grid-row: 4; align-self: end; }
  #result-modal .modal-footer .btn { width: 100%; padding: 9px 20px; }
  .final-score { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .instruction-banner,
  .student-pin.mood-angry .student-emoji-box,
  .champ-gold-shimmer,
  .lb-skeleton-bar { animation: none; }
}

/* =====================================================================
   2탄 전용: 직각자 도구줄·직각자·세밀조정판·정답 위치·내 제출 위치
   ===================================================================== */
.ruler-toolbar {
  flex: none;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--bean);
}

.tool-btn {
  background: #fff;
  border: 2px solid var(--line);
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (hover: hover) {
  .tool-btn:hover { background: var(--cream); }
}

.tool-btn.active {
  background: var(--berry-soft);
  border-color: #f9a8d4;
  color: #be185d;
}

.tool-lock-icon {
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
}

.tool-btn-short,
.btn-label-short {
  display: none;
}

.toolbar-right {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.guide-tip strong { color: var(--bean); }

.ruler-chip-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ruler-chip {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 3px;
  border-radius: 11px;
  border: 2px solid #cbd5e1;
  background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.ruler-chip-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.12));
}

.ruler-chip .chip-body {
  fill: rgba(255, 255, 255, 0.15);
  stroke-width: 2;
  stroke-linejoin: round;
}

.ruler-chip .chip-inner {
  fill: rgba(255, 255, 255, 0.72);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.ruler-chip .chip-corner {
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.ruler-chip-lock {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  background: rgba(15, 23, 42, 0.42);
  border-radius: 9px;
  pointer-events: none;
  z-index: 2;
}

.ruler-chip-blue {
  border-color: #0284c7;
  background: linear-gradient(145deg, #e0f2fe 0%, #bae6fd 100%);
}

.ruler-chip-blue .chip-body {
  fill: rgba(56, 189, 248, 0.45);
  stroke: #0284c7;
}

.ruler-chip-blue .chip-inner {
  fill: rgba(224, 242, 254, 0.95);
  stroke: rgba(2, 132, 199, 0.55);
}

.ruler-chip-blue .chip-corner {
  stroke: #0369a1;
}

.ruler-chip-green {
  border-color: #059669;
  background: linear-gradient(145deg, #d1fae5 0%, #a7f3d0 100%);
}

.ruler-chip-green .chip-body {
  fill: rgba(52, 211, 153, 0.45);
  stroke: #059669;
}

.ruler-chip-green .chip-inner {
  fill: rgba(209, 250, 229, 0.95);
  stroke: rgba(5, 150, 105, 0.55);
}

.ruler-chip-green .chip-corner {
  stroke: #047857;
}

.ruler-chip-orange {
  border-color: #ea580c;
  background: linear-gradient(145deg, #ffedd5 0%, #fed7aa 100%);
}

.ruler-chip-orange .chip-body {
  fill: rgba(251, 146, 60, 0.45);
  stroke: #ea580c;
}

.ruler-chip-orange .chip-inner {
  fill: rgba(255, 237, 213, 0.95);
  stroke: rgba(234, 88, 12, 0.55);
}

.ruler-chip-orange .chip-corner {
  stroke: #c2410c;
}

.ruler-chip.is-selected {
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.28), 0 4px 10px rgba(2, 132, 199, 0.18);
  transform: translateY(-1px);
}

.ruler-chip.is-locked .ruler-chip-lock {
  display: flex;
}

.ruler-chip.is-locked {
  opacity: 0.92;
}

.ruler-chip.is-hidden {
  opacity: 0.38;
  filter: grayscale(0.45);
}

.ruler-chip.is-hidden .ruler-chip-svg {
  opacity: 0.5;
}

.ruler-chip.is-hidden::after {
  content: '';
  position: absolute;
  inset: 6px;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    #64748b calc(50% - 1px),
    #64748b calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
  z-index: 1;
}

/* SVG Geometry Layer */
.geometry-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Canvas Layer */
.line-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* HTML Elements Layer */
.elements-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  /* iOS clips transformed children inside overflow:hidden + border-radius
     unless this layer is composited on its own. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Rulers Layer */
.rulers-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

/* ----------------------------------------------------
   SET SQUARE (직각자) UI & INTERACTIVE CONTROLS
   ---------------------------------------------------- */
.set-square-container {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  transform-origin: 0px 0px; /* Pivots at right-angle corner */
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
  transition: filter 0.2s ease, opacity 0.2s ease;
  opacity: 0.82;
}

.set-square-container:hover {
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.22));
  opacity: 1;
}

.set-square-container.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 12px 24px rgba(2, 132, 199, 0.35));
  z-index: 100 !important;
  opacity: 1;
}

.set-square-container.is-locked {
  cursor: default;
  pointer-events: none;
  opacity: 0.88;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}

.set-square-container.is-selected:not(.is-dragging) {
  opacity: 1;
  filter: drop-shadow(0 10px 20px rgba(2, 132, 199, 0.28));
  z-index: 24;
}

.set-square-container.is-locked .ruler-rotate-handle {
  display: none;
}

.set-square-svg {
  display: block;
  overflow: visible;
}

/* Ruler Theme Variants */
.ruler-theme-blue .ruler-body {
  fill: rgba(14, 165, 233, 0.22);
  stroke: #0284c7;
  stroke-width: 2.5;
}
.ruler-theme-blue .ruler-inner-cutout {
  fill: rgba(255, 255, 255, 0.35);
  stroke: rgba(2, 132, 199, 0.6);
  stroke-width: 1.5;
}
.ruler-theme-blue .ruler-ticks {
  stroke: #0369a1;
  stroke-width: 1.2;
}
.ruler-theme-blue .ruler-right-angle-mark {
  stroke: #0284c7;
  stroke-width: 2;
  fill: none;
}

.ruler-theme-blue .ruler-angle-label {
  fill: #0369a1;
}

.ruler-theme-green .ruler-body {
  fill: rgba(16, 185, 129, 0.22);
  stroke: #059669;
  stroke-width: 2.5;
}
.ruler-theme-green .ruler-inner-cutout {
  fill: rgba(255, 255, 255, 0.35);
  stroke: rgba(5, 150, 105, 0.6);
  stroke-width: 1.5;
}
.ruler-theme-green .ruler-ticks {
  stroke: #047857;
  stroke-width: 1.2;
}
.ruler-theme-green .ruler-right-angle-mark {
  stroke: #059669;
  stroke-width: 2;
  fill: none;
}

.ruler-theme-green .ruler-angle-label {
  fill: #047857;
}

.ruler-theme-orange .ruler-body {
  fill: rgba(249, 115, 22, 0.22);
  stroke: #ea580c;
  stroke-width: 2.5;
}
.ruler-theme-orange .ruler-inner-cutout {
  fill: rgba(255, 255, 255, 0.35);
  stroke: rgba(234, 88, 12, 0.6);
  stroke-width: 1.5;
}
.ruler-theme-orange .ruler-ticks {
  stroke: #c2410c;
  stroke-width: 1.2;
}
.ruler-theme-orange .ruler-right-angle-mark {
  stroke: #ea580c;
  stroke-width: 2;
  fill: none;
}

.ruler-theme-orange .ruler-angle-label {
  fill: #c2410c;
}

.ruler-lock-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fbbf24;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  z-index: 106;
  border: 2px solid rgba(251, 191, 36, 0.65);
}

/* Rotation Knob Handle */
.ruler-rotate-handle {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #10b981;
  color: #059669;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  z-index: 105;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease, background 0.15s ease;
}

.ruler-rotate-handle:hover {
  transform: translate(-50%, -50%) scale(1.2);
  background: #ecfdf5;
}

.ruler-rotate-handle:active,
.ruler-rotate-handle.is-rotating {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.25);
  background: #10b981;
  color: #ffffff;
}


/* Floating Touch D-Pad Controller (Draggable) */
.dpad-controller {
  position: absolute;
  right: 14px;
  bottom: 14px;
  background: #ffffff;
  border: 2px solid rgba(2, 132, 199, 0.45);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  z-index: 45;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  cursor: grab;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.dpad-controller:hover {
  border-color: #0284c7;
}

.dpad-controller.is-dragging {
  cursor: grabbing;
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.35);
  z-index: 70 !important;
}

.dpad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
  cursor: grab;
}

.dpad-controller.is-dragging .dpad-header {
  cursor: grabbing;
}

.dpad-drag-handle {
  font-size: 0.9rem;
  color: #94a3b8;
  letter-spacing: -1px;
  cursor: grab;
}

.dpad-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: #0369a1;
}

.dpad-step-btn {
  background: #e0f2fe;
  border: 1px solid #0284c7;
  color: #0369a1;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dpad-step-btn:hover {
  background: #0284c7;
  color: #ffffff;
}

.dpad-cross {
  display: grid;
  grid-template-columns: 32px 32px 32px;
  grid-template-rows: 32px 32px 32px;
  gap: 3px;
  justify-items: center;
  align-items: center;
}

.dpad-btn {
  width: 32px;
  height: 32px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  color: #0369a1;
  font-size: 0.82rem;
  font-weight: 900;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dpad-btn:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  transform: translateY(-1px);
}

.dpad-btn:active,
.dpad-btn.is-pressed {
  background: #0284c7;
  border-color: #0369a1;
  color: #ffffff;
  transform: scale(0.92);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
}

.dpad-center-dot {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.85rem;
  font-weight: 800;
  color: #ef4444;
  display: flex;
  justify-content: center;
  align-items: center;
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
}

/* 2탄 보드 위 층 순서: 삼각형 SVG < 선 < 친구·팥빙수 < 직각자 */
.student-pin { z-index: 12; }
.distance-badge { z-index: 14; }
.placed-bingsoo-pin { z-index: 30; }

/* 팥빙수 한가운데 십자: 점이 정확히 어디인지 보이게 그릇 위에 겹친다 */
.bingsoo-center-crosshair {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  pointer-events: none;
  z-index: 2;
}

.bingsoo-center-crosshair .crosshair-h,
.bingsoo-center-crosshair .crosshair-v {
  position: absolute;
  background: #ef4444;
  box-shadow: 0 0 2px #fff, 0 0 4px rgba(239, 68, 68, 0.7);
}

.bingsoo-center-crosshair .crosshair-h { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); }
.bingsoo-center-crosshair .crosshair-v { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }

.bingsoo-center-crosshair .crosshair-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
}

.bingsoo-center-crosshair.target-crosshair { left: -12px; top: -12px; width: 24px; height: 24px; }

.bingsoo-center-crosshair.target-crosshair .crosshair-h,
.bingsoo-center-crosshair.target-crosshair .crosshair-v {
  background: var(--happy);
  box-shadow: 0 0 2px #fff, 0 0 4px rgba(16, 185, 129, 0.7);
}

.bingsoo-center-crosshair.target-crosshair .crosshair-dot {
  background: var(--happy);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
}

/* 정답 확인 뒤: 내 제출 위치(흐린 팥빙수)와 정답 위치. 점 한가운데가 자리다 */
.original-submitted-pin,
.target-circumcenter-pin {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.original-submitted-pin { z-index: 24; }
.target-circumcenter-pin { z-index: 25; }

.original-ghost-box {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border: 2px dashed #f59e0b;
  border-radius: 50%;
  background: rgba(254, 243, 199, 0.6);
  animation: pin-pop 0.35s ease;
}

.original-ghost-box svg { width: 100%; height: 100%; display: block; opacity: 0.55; }

.target-icon-box {
  position: absolute;
  left: -20px;
  top: -20px;
  width: 40px;
  height: 40px;
  background: #ecfdf5;
  border: 2.5px solid var(--happy);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  animation: pin-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.original-ghost-label,
.target-label {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 내 팥빙수 이름표와 겹치지 않게 위쪽에 */
.original-ghost-label { bottom: 24px; background: rgba(180, 83, 9, 0.92); }
.target-label { top: 22px; background: var(--happy); }

@keyframes pin-pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* 내 제출 위치로: 보조 단추 */
.btn-secondary {
  background: #fff;
  color: var(--bean);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 #e6cdb5;
}

/* ---------- 2탄 폰 세로·좁은 화면 ---------- */
@media (max-width: 640px) {
  .toolbar-label,
  .toolbar-right,
  .tool-btn-full,
  .btn-label-full { display: none; }

  .tool-btn-short,
  .btn-label-short { display: inline; }

  .ruler-toolbar { padding: 4px 6px; gap: 4px; }
  .toolbar-left { width: 100%; gap: 4px; flex-wrap: nowrap; }
  .ruler-chip-group { flex: 1; gap: 4px; }
  .ruler-chip { flex: 1; min-width: 0; height: 38px; width: auto; padding: 2px; }
  .ruler-chip-lock { font-size: 1rem; }
  .ruler-lock-badge { width: 32px; height: 32px; font-size: 1.05rem; }
  .tool-btn { flex: 0 0 auto; justify-content: center; padding: 6px 8px; font-size: 0.72rem; }
  #btn-lock-all-rulers { min-width: 54px; }

  .controls-buttons { gap: 6px; }
  .controls-buttons .btn { font-size: 0.95rem; padding: 8px 10px; }

  .dpad-controller { right: 8px; bottom: 8px; padding: 5px 6px; gap: 4px; }
  .dpad-cross { grid-template-columns: 30px 30px 30px; grid-template-rows: 30px 30px 30px; gap: 2px; }
  .dpad-btn { width: 30px; height: 30px; font-size: 0.72rem; }
  .ruler-rotate-handle { width: 36px; height: 36px; }
  .set-square-container { opacity: 0.72; }
  .set-square-container.is-dragging,
  .set-square-container:hover { opacity: 1; }
}

/* ---------- 2탄 낮은 화면(폰 가로): 직각자 도구줄을 위쪽 띠 옆으로 ---------- */
@media (max-height: 520px) {
  .game-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .ruler-toolbar { grid-column: 1; grid-row: 1; padding: 2px 6px; }
  .hud { grid-column: 2; grid-row: 1; }
  .hud-brand { display: none; }
  .game-container { grid-column: 1 / -1; grid-row: 2; }
  .controls-bar { grid-column: 1 / -1; grid-row: 3; }
  .toolbar-label,
  .toolbar-right { display: none; }
  .ruler-chip { width: 34px; min-width: 34px; height: 34px; }
  .tool-btn { padding: 4px 8px; }
  .controls-buttons .btn { min-width: 0; }
  .dpad-cross { grid-template-columns: 26px 26px 26px; grid-template-rows: 26px 26px 26px; }
  .dpad-btn { width: 26px; height: 26px; }
}

/* ---------- 폰 가로 안내: 「세로로 돌려 주세요」 ----------
   폰(손가락 터치)을 가로로 들어 화면 높이가 500 이하일 때만 덮는다.
   태블릿은 가로여도 높이가 600 이상이라, PC는 마우스라 나오지 않는다 */
.rotate-guide { display: none; }

@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate-guide {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(43, 29, 20, 0.88);
    touch-action: none;
  }
}

.rotate-guide-card {
  background: var(--milk);
  border: 3px solid #fff;
  border-radius: 24px;
  padding: 18px 28px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}

.rotate-guide-phone {
  width: 72px;
  height: 72px;
  display: block;
  margin: 0 auto 6px;
  transform: rotate(-90deg);
  animation: rotate-phone 2.4s ease-in-out infinite;
}

@keyframes rotate-phone {
  0%, 20% { transform: rotate(-90deg); }
  55%, 100% { transform: rotate(0deg); }
}

.rotate-guide-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--bean);
}

.rotate-guide-desc {
  margin-top: 4px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-guide-phone { animation: none; transform: none; }
}
