:root {
  --bg: #f6f3ec;
  --ink: #1d1d1b;
  --muted: #6f6a60;
  --line: #d9d2c3;
  --board: #e3c58f;
  --board-line: rgba(60, 40, 10, 0.45);
  --accent: #2f6fde;
  --radius: 10px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 상단: 사이트 이름 + 한국시간 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand { font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; }
.tag { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.clock { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.clock-label { font-size: 12px; color: var(--muted); }
.clock time { font-weight: 700; font-size: 15px; }

/* 광고 자리 */
.ad-slot {
  margin: 12px auto 0;
  width: min(728px, calc(100% - 24px));
  height: 90px;
  border: 1px dashed #b9b2a4;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, #ece7dc, #ece7dc 10px, #e6e0d3 10px, #e6e0d3 20px);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.ad-mobile { display: none; }

/* 광고 아래 메뉴 */
.menu {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 12px 12px 0;
}
.menu a, .menu .soon {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
}
.menu a { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.menu a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.menu .soon { color: #a9a294; border: 1px dashed var(--line); cursor: default; }

main {
  flex: 1;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 16px 12px 24px;
}

/* 입장 화면 */
.join { text-align: center; padding: 40px 0; }
.join h1 { margin: 0 0 6px; font-size: 22px; }
.join p { color: var(--muted); margin: 0 0 18px; }
.join form, .chat { display: flex; gap: 8px; justify-content: center; }

input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-width: 0;
}
button {
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
button:disabled { background: #a9a294; cursor: not-allowed; }

/* 로비 */
.status {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.conn { padding: 2px 8px; border-radius: 999px; background: #eee; }
.conn.ok { background: #dff3e4; color: #1d6b35; }
.conn.bad { background: #fbe3e1; color: #9b2a1f; }

.stage { display: grid; grid-template-columns: 1fr 260px; gap: 12px; }

.board {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 640px;
  border-radius: 8px;
  background-color: var(--board);
  /* 바둑판 줄 */
  background-image:
    linear-gradient(var(--board-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--board-line) 1px, transparent 1px);
  background-size: calc(100% / 18) calc(100% / 18);
  background-position: center;
  box-shadow: inset 0 0 0 6px #c9a86b, 0 4px 14px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  touch-action: manipulation;
  cursor: pointer;
  outline: none;
}
.board:focus-visible { box-shadow: inset 0 0 0 6px #c9a86b, 0 0 0 3px var(--accent); }

.stone {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  transition: left 0.18s linear, top 0.18s linear;
  pointer-events: none;
}
.stone.black { background: radial-gradient(circle at 35% 30%, #555, #111 60%); }
.stone.white { background: radial-gradient(circle at 35% 30%, #fff, #d8d8d8 70%); box-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.stone.me { outline: 3px solid var(--accent); outline-offset: 2px; }

.stone .nick {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
}

/* 말풍선: 5초 동안 떠 있다가 점점 연해지며 사라짐 */
.bubble {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 200px;
  width: max-content;
  padding: 6px 10px;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-all;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  animation: bubble-fade 5s linear forwards;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: #fff;
}
@keyframes bubble-fade {
  0%   { opacity: 1; }
  40%  { opacity: 1; }
  100% { opacity: 0; }
}

/* 채팅 기록 (PC만) */
.chatlog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  max-height: 640px;
  overflow-y: auto;
  font-size: 13px;
}
.chatlog ol { list-style: none; margin: 0; padding: 0; }
.chatlog li { padding: 3px 0; border-bottom: 1px solid #f0ece3; word-break: break-all; }
.chatlog .who { font-weight: 700; margin-right: 4px; }
.chatlog .sys { color: var(--muted); }

.chat { margin-top: 10px; justify-content: stretch; }
.chat input { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.footer a { color: var(--muted); }

/* 모바일: 광고 320x100, 채팅 기록 숨기고 말풍선만 */
@media (max-width: 760px) {
  .ad-slot { width: 320px; height: 100px; }
  .ad-desktop { display: none; }
  .ad-mobile { display: inline; }
  .stage { grid-template-columns: 1fr; }
  .chatlog { display: none; }
  .stone { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
  .stone .nick { top: 31px; font-size: 11px; }
  .bubble { bottom: 36px; max-width: 150px; font-size: 12px; }
}
