/*
  조각보 — 보드게임하면서보드카 공통 디자인 시스템.
  모시 바탕 위에 물들인 천 조각을 솔기로 이어 붙인 모양을 기본 문법으로 씁니다.
  강조는 "솔기"(조각 사이의 선) 하나에만 둡니다. 그림자·흐림·그라데이션은 쓰지 않습니다.
*/
@font-face {
  font-family: 'Wanted Sans Variable';
  src: url('/fonts/WantedSansVariable.woff2') format('woff2');
  font-weight: 400 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* 바탕과 조각 */
  --cloth: #dce2dc;          /* 모시: 페이지 바탕 */
  --cloth-deep: #c9d1ca;     /* 그늘진 모시: 눌림·비활성 바탕 */
  --sheet: #f2f4ef;          /* 밝은 조각: 패널·입력 */
  --sheet-hover: #e7ebe5;
  --seam: #8e9a93;           /* 솔기: 조각 사이의 선 */
  --seam-strong: #56635c;    /* 겉솔기: 바깥 테두리·대화상자 */

  /* 먹 */
  --ink: #1b211e;
  --ink-soft: #4a5550;       /* 본문 보조 (바탕·조각 모두 4.5:1 이상) */
  --ink-faint: #6b7670;      /* 18px 이상 또는 장식용 */
  --on-dye: #fbfcfa;         /* 진한 물 위의 글자 */

  /* 물감: 쪽·홍화·치자·쑥 */
  --indigo: #23477d;         /* 주요 행동 */
  --indigo-press: #1a3862;
  --indigo-tint: #d3ddeb;
  --safflower: #b8323f;      /* 경고·위험 */
  --safflower-tint: #f1d5d6;
  --gardenia: #e0a526;       /* 내 차례·지금 할 일 (먹 글자) */
  --gardenia-tint: #f5e3b5;
  --mugwort: #3f7a55;        /* 완료·성공 */
  --mugwort-tint: #d3e3d6;

  /* 블로커스 색 (보드 조각) */
  --piece-blue: #2f5fa8;
  --piece-yellow: #e0a526;
  --piece-red: #c23b47;
  --piece-green: #3f8558;

  --radius: 4px;
  --radius-small: 2px;
  --seam-width: 2px;

  --font: 'Wanted Sans Variable', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-display: clamp(2.25rem, 1.4rem + 3.6vw, 4.25rem);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --quick: 140ms;
  --steady: 240ms;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* 연타해도 화면이 확대되거나 글자가 선택되지 않게:
   - 두 번 톡 확대는 끄고(manipulation), 두 손가락 확대는 그대로 둡니다.
   - 누르는 것(버튼·링크·카드·타일·조각)은 글자 선택·길게 누름 메뉴·탭 강조를 끕니다.
   - 게임 화면은 통째로 선택을 끄고, 입력칸과 대화 내용만 선택할 수 있게 둡니다. */
html { touch-action: manipulation; }
button, .btn, a, label, summary, select, [role="button"], [role="tab"], [draggable="true"], canvas {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.blokus-page, .arcade-page, .halli-page { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.blokus-page :is(input, textarea, [contenteditable="true"], #chatList, .chat-message),
.arcade-page :is(input, textarea, [contenteditable="true"], #arcadeChatList, .chat-message),
.halli-page :is(input, textarea, [contenteditable="true"], #arcadeChatList, .chat-message),
:is(input, textarea, [contenteditable="true"]) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* 휴대폰에서 16px보다 작은 입력칸을 누르면 화면이 확대되므로, 손가락 기기에서는 입력 글자를 16px 이상으로 둡니다. */
@media (pointer: coarse) {
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]), select, textarea { font-size: max(16px, 1em) !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cloth);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 450;
  line-height: 1.55;
  font-synthesis: none;
  letter-spacing: -.005em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 { margin: 0; font-weight: 760; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0; }
a { color: var(--indigo); text-underline-offset: .2em; }
img, svg { display: block; max-width: 100%; }
b, strong { font-weight: 720; }
kbd {
  font: inherit; font-size: var(--text-xs); font-weight: 650;
  padding: 1px 5px; border: 1px solid var(--seam); border-radius: var(--radius-small);
  background: var(--sheet); color: var(--ink-soft);
}

::selection { background: var(--gardenia-tint); color: var(--ink); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ---------- 버튼 ---------- */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 40px; padding: 0 16px;
  border: 1.5px solid var(--seam-strong); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  font-size: var(--text-sm); font-weight: 680; line-height: 1.2; text-decoration: none;
  /* 좁은 줄에서 '규칙'이 '규/칙'처럼 글자마다 꺾이지 않게: 낱말 안에서는 끊지 않고, 칸보다 길 때만 끊습니다. */
  word-break: keep-all; overflow-wrap: break-word;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--quick) var(--ease), border-color var(--quick) var(--ease), color var(--quick) var(--ease);
}
button:hover:not(:disabled), .btn:hover:not(:disabled) { background: var(--sheet-hover); }
button:active:not(:disabled), .btn:active:not(:disabled) { background: var(--cloth-deep); }
button:disabled, .btn:disabled { cursor: not-allowed; color: var(--ink-faint); border-color: var(--seam); background: var(--cloth); }

.btn.primary, button.primary {
  background: var(--indigo); border-color: var(--indigo); color: var(--on-dye);
}
.btn.primary:hover:not(:disabled), button.primary:hover:not(:disabled) { background: var(--indigo-press); border-color: var(--indigo-press); }
.btn.primary:active:not(:disabled), button.primary:active:not(:disabled) { background: var(--indigo-press); }
.btn.primary:disabled, button.primary:disabled { background: var(--cloth-deep); border-color: var(--seam); color: var(--ink-soft); }

.btn.danger, button.danger { background: var(--safflower); border-color: var(--safflower); color: var(--on-dye); }
.btn.danger:hover:not(:disabled), button.danger:hover:not(:disabled) { background: #9c2834; border-color: #9c2834; }

.btn.quiet, button.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover:not(:disabled), button.quiet:hover:not(:disabled) { background: var(--sheet); border-color: var(--seam); }

.btn.wide, button.wide { width: 100%; min-height: 48px; font-size: var(--text-md); }

/* ---------- 입력 ---------- */
input:not([type]), input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1.5px solid var(--seam); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); font-size: var(--text-md);
  transition: border-color var(--quick) var(--ease);
}
textarea { padding: 10px 12px; min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--seam-strong); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--indigo); box-shadow: inset 0 0 0 1px var(--indigo); }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%231b211e' stroke-width='1.8'/%3E%3C/svg%3E");
  background-position: calc(100% - 13px) 50%;
  background-size: 12px 8px; background-repeat: no-repeat;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--indigo); width: 18px; height: 18px; }

label { font-size: var(--text-sm); font-weight: 650; color: var(--ink); }

/* ---------- 대화상자 ---------- */
dialog {
  max-width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: var(--seam-width) solid var(--seam-strong); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  overflow: auto; overscroll-behavior: contain;
}
dialog::backdrop { background: rgb(27 33 30 / .5); }
dialog[open] { animation: patch-in var(--steady) var(--ease); }

/* ---------- 솔기 문법 ----------
   .seamed 안의 직계 조각 사이에 2px 솔기가 보입니다. 조각마다 배경색을 지정하세요. */
.seamed {
  display: grid; gap: var(--seam-width);
  background: var(--seam); border: var(--seam-width) solid var(--seam);
  border-radius: var(--radius); overflow: hidden;
}
.seamed > * { background: var(--sheet); }

/* 알림 한 줄 */
.notice {
  margin: 0; padding: 10px 14px;
  border: 1.5px solid var(--safflower); border-radius: var(--radius);
  background: var(--safflower-tint); color: var(--ink);
  font-size: var(--text-sm); font-weight: 600;
}

@keyframes patch-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
}
