:root {
  color-scheme: light;
  --page: #f7f8fb;
  --frame: #ffffff;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #647084;
  --faint: #94a0b3;
  --line: #d4dbe7;
  --soft-line: #e8edf5;
  --blue: #1769ff;
  --blue-dark: #0c54d8;
  --blue-soft: #eef6ff;
  --green: #22c55e;
  --red: #ef4444;
  --wood: #efc47d;
  --wood-deep: #d8a962;
  --grid: rgba(49, 44, 34, 0.62);
  --shadow: 0 14px 36px rgba(29, 42, 64, 0.12);
  font-family:
    "Pretendard",
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96) 0 10%, rgba(247, 248, 251, 0.5) 28%),
    var(--page);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  padding: 8px 18px 18px;
}

.desktop-frame {
  position: relative;
  width: min(1456px, calc(100vw - 36px));
  min-height: min(880px, calc(100vh - 18px));
  margin: 0 auto;
  border: 1px solid #c8d0dd;
  border-radius: 8px;
  background: var(--frame);
  box-shadow: 0 18px 50px rgba(21, 35, 54, 0.13);
  overflow: visible;
}

.top-bar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid #cbd3df;
  background: rgba(255, 255, 255, 0.95);
}

h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 28px;
}

.top-action {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #4b5565;
  font-size: 0.98rem;
  font-weight: 800;
}

.top-action span {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  border: 2px solid #647084;
  border-radius: 50%;
  color: #647084;
  font-size: 0.9rem;
  font-weight: 900;
}

.top-action + .top-action span {
  border: 0;
  font-size: 1.45rem;
}

.content-grid {
  position: relative;
  display: grid;
  grid-template-columns: 448px minmax(0, 1fr);
  min-height: calc(100vh - 82px);
}

.lobby-panel {
  min-height: 100%;
  padding: 44px 30px;
  border-right: 1px solid #d9e0eb;
  background: #fff;
}

.lobby-panel h2 {
  margin: 0;
  font-size: 1.82rem;
  font-weight: 900;
  line-height: 1.2;
}

.start-copy {
  margin: 13px 0 24px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 720;
}

.entry-form {
  display: grid;
  gap: 19px;
}

label {
  display: grid;
  gap: 9px;
  color: #1f2937;
  font-size: 1rem;
  font-weight: 820;
}

input {
  width: 100%;
  min-height: 51px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  padding: 0 18px;
  font-size: 1.08rem;
  font-weight: 650;
  outline: none;
}

input::placeholder {
  color: #9aa4b5;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.16);
}

.primary-action {
  min-height: 55px;
  border: 1px solid var(--blue-dark);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 900;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  color: #4b5565;
  font-weight: 800;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: #d8dee8;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr 91px;
  align-items: end;
  gap: 10px;
}

.join-action {
  min-height: 51px;
  border: 2px solid var(--blue);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font-size: 1.18rem;
  font-weight: 900;
}

.info-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 32px;
  padding: 16px 18px;
  border: 1px solid #cfe3ff;
  border-radius: 7px;
  background: #eef6ff;
  color: #526173;
}

.info-note span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--blue);
  border-radius: 50%;
  color: var(--blue);
  font-weight: 900;
}

.info-note p {
  margin: 0;
  font-size: 0.93rem;
  font-weight: 720;
  line-height: 1.55;
}

.message {
  min-height: 1.4em;
  margin: 22px 0 0;
  color: #d92d20;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.45;
}

.game-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 264px;
  gap: 26px;
  padding: 28px 38px 24px 30px;
  background: #ffffff;
}

.board-area {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  align-content: start;
}

.room-strip {
  display: flex;
  align-items: end;
  gap: 16px;
  margin: 0 0 20px 8px;
}

.room-label {
  margin: 0 0 3px;
  color: #4b5565;
  font-size: 0.88rem;
  font-weight: 900;
}

.room-code {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
}

.copy-icon {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 1.16rem;
}

.board-wrap {
  position: relative;
  width: min(696px, 100%);
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid rgba(109, 76, 39, 0.2);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(121, 81, 37, 0.08) 1px, transparent 1px) 0 0 / 31px 100%,
    linear-gradient(0deg, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.04)),
    var(--wood);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 12px 26px rgba(91, 61, 24, 0.2);
  overflow: hidden;
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 33px 30px 17px 36px;
  background:
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px calc(100% / 14)),
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px calc(100% / 14));
  pointer-events: none;
}

.coords {
  position: absolute;
  z-index: 2;
  color: #1f2937;
  font-size: 1rem;
  font-weight: 520;
}

.coords-top {
  left: 36px;
  right: 30px;
  top: 10px;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  text-align: center;
}

.coords-left {
  top: 28px;
  bottom: 12px;
  left: 10px;
  display: grid;
  grid-template-rows: repeat(15, 1fr);
  align-items: center;
}

.star-points {
  position: absolute;
  inset: 33px 30px 17px 36px;
  z-index: 3;
  pointer-events: none;
}

.star-points i {
  position: absolute;
  left: calc(var(--col) * 100% / 14);
  top: calc(var(--row) * 100% / 14);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #111827;
  transform: translate(-50%, -50%);
}

.board {
  position: absolute;
  inset: 33px 30px 17px 36px;
  z-index: 4;
}

.cell {
  position: absolute;
  left: calc(var(--col) * 100% / 14);
  top: calc(var(--row) * 100% / 14);
  width: calc(100% / 14);
  height: calc(100% / 14);
  border: 0;
  background: transparent;
  padding: 0;
  transform: translate(-50%, -50%);
}

.cell::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(74%, 32px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.75);
}

.cell.black::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.5), transparent 0.72rem),
    radial-gradient(circle at 70% 75%, #05070a, #151922 58%, #30394a 100%);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.45);
}

.cell.white::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  background:
    radial-gradient(circle at 32% 28%, #ffffff, transparent 0.88rem),
    radial-gradient(circle at 72% 76%, #cdd4de, #f8fafc 62%, #ffffff 100%);
  border: 1px solid rgba(99, 110, 126, 0.18);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.18);
}

.cell.win::after {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.cell:focus-visible {
  outline: 3px solid rgba(23, 105, 255, 0.42);
  outline-offset: -3px;
}

.toolbar {
  width: min(990px, 100%);
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.38fr;
  margin: 16px auto 0;
  border: 1px solid #dfe5ef;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.tool-button {
  min-width: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-right: 1px solid #e4e9f1;
  background: #fff;
  color: #374151;
  font-size: 0.98rem;
  font-weight: 780;
}

.tool-button:last-child {
  border-right: 0;
}

.tool-button span {
  color: #5f6b7c;
  font-size: 1.45rem;
  font-weight: 500;
}

.tool-button b,
.tool-button i {
  font-style: normal;
  font-weight: 780;
}

.tool-button:disabled,
.outline-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.side-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 80px;
}

.turn-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.current-room-card,
.open-rooms-card {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
}

.current-room-card strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #111827;
  font-size: 1.1rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-room-card span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 760;
}

.players {
  display: grid;
  gap: 16px;
}

.player {
  position: relative;
  min-height: 85px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
}

.player.is-turn {
  border-color: #b5d1ff;
  background: #f5f9ff;
}

.player-empty {
  background: #fbfcfe;
}

.stone-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.stone-preview.black {
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 0.55), transparent 0.7rem),
    radial-gradient(circle at 70% 78%, #05070a, #141821 58%, #30394a 100%);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.32);
}

.stone-preview.white {
  background:
    radial-gradient(circle at 32% 25%, #fff, transparent 0.8rem),
    radial-gradient(circle at 72% 78%, #cdd4de, #f8fafc 62%, #ffffff 100%);
  border: 1px solid rgba(99, 110, 126, 0.18);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.14);
}

.player strong,
.player span,
.player em {
  display: block;
}

.player strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.08rem;
  font-weight: 820;
}

.player span {
  margin-top: 4px;
  color: #374151;
  font-size: 0.94rem;
  font-weight: 600;
}

.player em {
  align-self: start;
  margin-top: 7px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eaf3ff;
  color: var(--blue);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.player.is-turn strong {
  color: var(--blue);
}

.rules-card,
.timer-card {
  padding: 20px 8px 18px 8px;
  border-top: 1px solid #e4e9f1;
}

.rules-card h2,
.timer-card h2 {
  margin: 0 0 10px;
  color: #5f6b7c;
  font-size: 0.98rem;
  font-weight: 760;
}

.rules-card p,
.timer-card p {
  margin: 0;
  padding-left: 28px;
  color: #1f2937;
  font-size: 1rem;
  font-weight: 760;
  line-height: 1.6;
}

.control-row {
  display: grid;
  gap: 14px;
  margin-top: auto;
}

.open-rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.open-rooms-head h2 {
  margin: 0;
  color: #5f6b7c;
  font-size: 0.98rem;
  font-weight: 900;
}

.open-rooms {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
}

.open-room {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
  color: #111827;
  text-align: left;
}

.open-room:hover,
.open-room.is-current {
  border-color: #b5d1ff;
  background: #eef6ff;
}

.open-room strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-room span,
.empty-open-room {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
}

.outline-action {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 7px;
  background: #fff;
  font-size: 1.04rem;
  font-weight: 900;
}

.restart-action {
  border: 1.5px solid #1d5edc;
  color: #0f55cc;
}

.leave-action {
  border: 1.5px solid var(--red);
  color: #e11d48;
}

.undo-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #b5d1ff;
  border-radius: 8px;
  background: #f5f9ff;
}

.undo-card strong {
  color: #0f55cc;
  font-size: 0.92rem;
  font-weight: 900;
}

.undo-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.45;
}

.undo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.move-record {
  margin: 12px auto 0;
  width: min(990px, 100%);
  padding: 12px;
  border: 1px solid #dfe5ef;
  border-radius: 8px;
  background: #fff;
}

.move-record h2 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 900;
}

.move-record ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  max-height: 96px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.move-record li {
  display: grid;
  grid-template-columns: 1.8rem 2.6rem minmax(0, 1fr) 2.6rem;
  gap: 5px;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 820;
}

.move-record li span,
.move-record li b {
  color: var(--ink);
}

.move-record li em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.empty-record {
  grid-column: 1 / -1;
  display: block !important;
  text-align: center;
}

.chat-panel {
  margin: 12px auto 0;
  width: min(990px, 100%);
  padding: 12px;
  border: 1px solid #dfe5ef;
  border-radius: 8px;
  background: #fff;
}

.chat-head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-head h2,
.modal-head h2 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 900;
}

.ghost-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
  color: #4b5565;
  font-size: 0.78rem;
  font-weight: 900;
}

.chat-messages {
  display: grid;
  gap: 8px;
  max-height: 150px;
  margin: 10px 0;
  overflow: auto;
}

.empty-chat {
  margin: 0;
  padding: 14px;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 780;
}

.chat-message {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid #e5eaf2;
  border-radius: 7px;
  background: #f8fafc;
}

.chat-message.mine {
  border-color: #cfe3ff;
  background: #eef6ff;
}

.chat-message div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-message strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2937;
  font-size: 0.78rem;
  font-weight: 900;
}

.chat-message span {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 780;
}

.chat-message p {
  margin: 0;
  color: #374151;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 8px;
}

.chat-form input,
.chat-form .join-action {
  min-height: 42px;
  font-size: 0.88rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
}

.modal {
  width: min(430px, 100%);
  padding: 20px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-body {
  margin-top: 16px;
  color: #374151;
}

.modal-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.55;
}

.setting-row {
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
}

.setting-row input {
  min-height: auto;
  width: 18px;
  height: 18px;
  padding: 0;
}

.setting-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
  line-height: 1.5;
}

@media (max-width: 1160px) {
  .phone-preview {
    display: none;
  }

  .desktop-frame {
    width: min(100%, 1010px);
    margin: 0 auto;
  }

  .content-grid {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .game-panel {
    grid-template-columns: 1fr;
  }

  .side-panel {
    padding-top: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .desktop-frame {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .top-bar {
    height: 48px;
    padding: 0 16px;
  }

  h1 {
    font-size: 1.25rem;
  }

  .top-actions {
    gap: 12px;
  }

  .top-action {
    font-size: 0;
  }

  .top-action span {
    width: 24px;
    height: 24px;
    font-size: 0.78rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .lobby-panel {
    min-height: auto;
    padding: 22px 16px;
    border-right: 0;
    border-bottom: 1px solid #d9e0eb;
  }

  .lobby-panel h2 {
    font-size: 1.25rem;
  }

  .start-copy {
    font-size: 0.78rem;
  }

  input,
  .primary-action,
  .join-action {
    min-height: 38px;
    font-size: 0.86rem;
  }

  label {
    font-size: 0.78rem;
  }

  .game-panel {
    padding: 18px 16px 20px;
    gap: 18px;
  }

  .room-strip {
    margin-left: 0;
  }

  .room-code {
    font-size: 1.25rem;
  }

  .board-wrap {
    width: 100%;
  }

  .coords {
    font-size: 0.68rem;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .tool-button {
    min-height: 48px;
    font-size: 0.82rem;
  }

  .players {
    gap: 10px;
  }

  .player {
    min-height: 74px;
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .stone-preview {
    width: 34px;
    height: 34px;
  }

  .move-record ol {
    grid-template-columns: 1fr;
  }
}

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