:root {
  --bg: #f2f4f0;
  --panel: #ffffff;
  --ink: #20241f;
  --muted: #66706a;
  --line: #29231a;
  --board: #d9a85f;
  --board-deep: #ba7a31;
  --accent: var(--rb-main-color, #AA20FF);
  --accent-dark: var(--rb-sub-color, var(--rb-point-color, #25282B));
  --action-bg: #e6f4f1;
  --action-hover: #d8eee9;
  --action-border: #8fc7bd;
  --action-ink: #14524a;
  --action-shadow: 0 8px 18px rgba(20, 82, 74, 0.14);
  --danger: #a13d36;
  --shadow: 0 18px 45px rgba(28, 33, 30, 0.15);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.baduk-gnuboard-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  column-gap: 20px;
  row-gap: 14px;
  align-items: start;
}

.baduk-gnuboard-app > :not(.lobby-users-panel):not(.rank-modal):not(.sr-only):not(.invite-dialog):not(.lobby-flow-panel):not(.main-layout):not(.baduk-rb-module) {
  grid-column: 1;
}

.baduk-gnuboard-app > .lobby-flow-panel {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: stretch;
}

.baduk-gnuboard-app > .lobby-panel {
  grid-row: 3;
}

.baduk-gnuboard-app > .baduk-index-intro {
  grid-column: 1 / -1 !important;
  grid-row: 2;
}

.baduk-rb-module {
  grid-column: 1 / -1;
  position: relative;
  z-index: 30;
  width: 100%;
  max-width: 100%;
  flex: 0 0 100%;
  min-width: 0;
  min-height: 1px;
  margin: 0;
  overflow: visible !important;
}

.baduk-rb-module:not(:empty)::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -18px;
  bottom: -18px;
  z-index: -1;
  pointer-events: auto;
}

.baduk-gnuboard-app > .baduk-rb-module {
  grid-column: 1 / -1 !important;
  justify-self: stretch;
}

.baduk-rb-module > * {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
}

.baduk-rb-module .rb_section,
.baduk-rb-module .rb_module,
.baduk-rb-module .rb_widget,
.baduk-rb-module .rb_box,
.baduk-rb-module .rb_inner,
.baduk-rb-module .rb_module_inner,
.baduk-rb-module .rb_widget_inner {
  width: 100% !important;
  max-width: none !important;
  overflow: visible !important;
}

.baduk-rb-top {
  grid-row: 1;
}

.baduk-rb-module:not(:empty) {
  margin: 0;
}

.baduk-rb-top:not(:empty) {
  margin-bottom: 0;
}

.baduk-rb-top .content_box,
.baduk-rb-top .rb_layout_box {
  margin-bottom: 0 !important;
}

.baduk-rb-top,
.baduk-rb-top > *,
.baduk-rb-top .rb_layout_box,
.baduk-rb-top .content_box,
.baduk-rb-top .flex_box_inner,
.baduk-rb-top .add_module_wrap,
.baduk-rb-top .rb_section,
.baduk-rb-top .rb_module,
.baduk-rb-top .rb_widget,
.baduk-rb-top .rb_box,
.baduk-rb-top .rb_inner,
.baduk-rb-top .rb_module_inner,
.baduk-rb-top .rb_widget_inner {
  padding: 0 !important;
  box-sizing: border-box;
}

section.co_gap_pc_20 .baduk-rb-top,
.co_gap_pc_20 .baduk-rb-top,
.co_gap_pc_20 .baduk-rb-top.flex_box {
  width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
}

section.co_gap_pc_20 .baduk-rb-top .content_box,
.co_gap_pc_20 .baduk-rb-top .content_box,
.co_gap_pc_20 .baduk-rb-top .add_module_wrap {
  padding: 0 !important;
}

.baduk-rb-bottom {
  display: flex;
}

.baduk-rb-module:empty {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.top-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(34, 37, 34, 0.08);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

.game-facts,
.score-list,
.result-grid {
  margin: 0;
}

.game-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  gap: 8px;
}

.game-facts div,
.score-list div,
.result-grid div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  font-weight: 800;
}

.status-message {
  margin: 0;
  padding: 12px 14px;
  color: #123a38;
  background: #e5f2ef;
  border: 1px solid #bddbd4;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.45;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 390px);
  gap: 20px;
  align-items: start;
}

body.baduk-playing .baduk-gnuboard-app {
  display: block;
}

body.baduk-playing .baduk-index-intro {
  display: none;
}

body.baduk-playing .lobby-users-panel,
body.baduk-playing #lobbyListView,
body.baduk-playing #roomCreateView,
body.baduk-playing #settingsPanel,
body.baduk-playing .lobby-flow-panel,
body.baduk-playing .lobby-flow {
  display: none !important;
}

body.baduk-playing .main-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: stretch;
}

body.baduk-playing .board-area {
  grid-column: 1;
  grid-row: 1 / 3;
  min-width: 0;
  padding: 12px;
}

body.baduk-playing .board-chat {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 14px;
}

body.baduk-playing .focus-room-ticker {
  display: none;
}

body.baduk-playing .board-chat h2 {
  flex: 0 0 auto;
}

body.baduk-playing .chat-messages {
  flex: 1 1 auto;
  height: auto;
  min-height: 120px;
}

body.baduk-playing .chat-form {
  flex: 0 0 auto;
  grid-template-columns: 108px minmax(0, 1fr) auto;
}

body.baduk-playing .chat-form label {
  display: none;
}

body.baduk-room-chat .main-layout {
  position: static;
  grid-column: 2;
  grid-row: 3 / 5;
  display: block;
  width: 320px;
  height: var(--baduk-room-chat-height, auto);
  align-self: stretch;
}

body.baduk-room-chat .baduk-gnuboard-app {
  grid-template-columns: minmax(0, 1fr) 320px;
  row-gap: 12px;
}

body.baduk-room-chat .lobby-flow-panel,
body.baduk-room-chat .lobby-panel,
body.baduk-room-chat .settings-panel {
  margin-bottom: 0;
}

body.baduk-room-chat .board-area,
body.baduk-room-chat .side-panel {
  display: none;
}

body.baduk-room-chat .board-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: var(--baduk-room-chat-height, calc(100vh - 40px));
  margin: 0;
  padding: 14px;
}

body.baduk-room-chat .chat-messages {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

body.baduk-room-chat .chat-form {
  flex: 0 0 auto;
  grid-template-columns: 96px minmax(0, 1fr) auto;
}

body.baduk-room-chat .chat-form label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body.baduk-room-chat .settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.baduk-room-chat .settings-grid label,
body.baduk-room-chat .settings-grid select,
body.baduk-room-chat .settings-grid input[type="number"] {
  min-width: 0;
  max-width: 100%;
}

body.baduk-playing .side-panel {
  display: contents;
}

body.baduk-playing .side-panel section {
  padding: 14px;
}

body.baduk-playing .control-panel,
body.baduk-playing .info-panel {
  min-width: 0;
}

body.baduk-playing .control-panel {
  grid-column: 2;
  grid-row: 2;
}

body.baduk-playing .info-panel {
  grid-column: 1 / -1;
  grid-row: 3;
}

body.baduk-playing .result-panel,
body.baduk-playing .history-panel {
  grid-column: 1 / -1;
}

body.baduk-playing .button-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.baduk-playing .score-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

body.baduk-playing .score-list div {
  min-height: 54px;
  padding: 8px;
}

.member-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.member-panel > div {
  padding: 16px;
  background: var(--panel);
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(34, 37, 34, 0.08);
}

.rank-editor {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.rank-editor label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rank-editor select,
.rank-editor button {
  min-height: 38px;
  border-radius: 8px;
}

.rank-editor select {
  padding: 0 10px;
  border: 1px solid #ccd7cf;
  background: #fff;
}

.rank-editor button {
  padding: 0 12px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  cursor: pointer;
  flex: 0 0 auto;
  font-weight: 800;
}

.rank-modal[hidden] {
  display: none;
}

.rank-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 28, 25, 0.58);
}

.rank-modal-card {
  width: min(460px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.rank-modal-card h1 {
  margin-bottom: 12px;
}

.rank-lock-notice {
  margin: 0 0 18px;
  color: #34433c;
  line-height: 1.6;
}

.record-list {
  max-height: 120px;
  margin: 0;
  padding-left: 18px;
  overflow: auto;
  color: #30362f;
  line-height: 1.6;
}

.compact-settings {
  margin: 0 0 8px;
  padding: 8px 10px;
  color: #173f3c;
  background: #e5f2ef;
  border: 1px solid #bddbd4;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.settings-panel,
.lobby-panel,
.board-chat,
.board-area,
.side-panel section {
  background: var(--panel);
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(34, 37, 34, 0.08);
}

.settings-panel {
  margin-bottom: 20px;
  padding: 16px;
}

.lobby-flow-panel,
.lobby-panel {
  margin-bottom: 20px;
  padding: 16px;
}

.lobby-flow-panel {
  width: 100%;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.lobby-title {
  margin: 0 0 10px;
}

.lobby-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lobby-flow li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: center;
  min-height: 86px;
  padding: 12px 12px;
  text-align: center;
  color: #25312d;
  background: #f5f8f6;
  border: 1px solid #dce5df;
  border-radius: 8px;
}

.lobby-flow li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -8px;
  z-index: 1;
  width: 8px;
  height: 2px;
  background: #d6ddd7;
  transform: translateY(-50%);
}

.lobby-flow li.is-complete:not(:last-child)::after {
  background: var(--action-border);
}

.lobby-flow li.is-active:not(:last-child)::after {
  background: var(--action-border);
}

.lobby-flow strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: #4b5563;
  background: #dce5df;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.lobby-flow li.is-complete strong {
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
}

.lobby-flow li.is-active strong {
  color: var(--action-ink);
  background: var(--action-hover);
  border: 1px solid var(--action-border);
  box-shadow: 0 0 0 4px rgba(20, 82, 74, 0.08);
}

.lobby-flow span {
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.lobby-flow .flow-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  align-items: center;
}

.lobby-flow .flow-options > span {
  display: block;
  min-height: 0;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  word-break: keep-all;
}

.lobby-flow .flow-single {
  display: flex;
  align-items: center;
  min-height: 28px;
  word-break: keep-all;
}

.lobby-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}

.lobby-header:has(.room-ticker:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.lobby-header > p {
  margin: 0;
  max-width: 100%;
  line-height: 1.45;
}

.room-main-status {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.room-rule-help {
  margin: -4px 0 0;
  padding: 8px 10px;
  color: #71420b;
  background: #fff4cc;
  border: 1px solid #eadb82;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  word-break: keep-all;
}

.room-ticker {
  display: grid;
  gap: 8px;
  align-content: stretch;
  min-height: 112px;
  padding: 12px 14px;
  color: #4cff8d;
  text-align: left;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    #101512;
  border: 1px solid #2c3930;
  border-radius: 8px;
  box-shadow: inset 0 0 22px rgba(34, 197, 94, 0.14), 0 8px 22px rgba(15, 23, 42, 0.18);
}

.room-ticker-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.room-ticker-turn {
  color: #d7ffe3;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.room-ticker-sub {
  min-width: 0;
  overflow: hidden;
  color: #9df7bb;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-clock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.room-clock {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 9px 10px;
  color: #4cff8d;
  background: rgba(6, 13, 9, 0.9);
  border: 1px solid rgba(76, 255, 141, 0.24);
  border-radius: 7px;
  box-shadow: inset 0 0 18px rgba(76, 255, 141, 0.08);
}

.room-clock-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #d7ffe3;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.room-clock-stone {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.room-clock-black .room-clock-stone {
  background: radial-gradient(circle at 35% 30%, #555, #0b0d0d 68%, #000);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.16),
    0 0 8px rgba(255, 255, 255, 0.42),
    0 1px 4px rgba(0, 0, 0, 0.55);
}

.room-clock-white .room-clock-stone {
  background: radial-gradient(circle at 35% 30%, #fff, #e8e8e2 64%, #bfc3bd);
  border: 1px solid #ccd2cc;
}

.room-clock-time {
  min-width: 0;
  overflow: hidden;
  color: #4cff8d;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 10px rgba(76, 255, 141, 0.45);
  white-space: nowrap;
}

.room-clock-sub {
  min-width: 0;
  overflow: hidden;
  color: #9df7bb;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-clock.is-active {
  border-color: rgba(76, 255, 141, 0.7);
  box-shadow: inset 0 0 20px rgba(76, 255, 141, 0.14), 0 0 0 2px rgba(76, 255, 141, 0.12);
}

.room-clock.is-byoyomi {
  border-color: rgba(255, 209, 102, 0.56);
  box-shadow: inset 0 0 20px rgba(255, 209, 102, 0.12);
}

.room-clock.is-byoyomi .room-clock-time,
.room-clock.is-warning .room-clock-time {
  color: #ffd166;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.45);
}

.room-clock.is-warning {
  border-color: rgba(255, 209, 102, 0.76);
}

.room-clock.is-danger {
  border-color: rgba(255, 90, 90, 0.82);
  box-shadow: inset 0 0 24px rgba(255, 90, 90, 0.16), 0 0 0 2px rgba(255, 90, 90, 0.14);
}

.room-clock.is-danger .room-clock-time {
  color: #ff5a5a;
  text-shadow: 0 0 12px rgba(255, 90, 90, 0.58);
}

.room-ready-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ready-badge {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #d6ddd7;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  word-break: keep-all;
  cursor: pointer;
}

.ready-badge:hover {
  filter: brightness(0.98);
}

.ready-badge:focus-visible {
  outline: 3px solid rgba(55, 118, 109, 0.24);
  outline-offset: 2px;
}

.ready-stone {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
}

.ready-badge-black .ready-stone {
  background: radial-gradient(circle at 35% 30%, #555, #0b0d0d 68%, #000);
  border: 1px solid #050505;
}

.ready-badge-white .ready-stone {
  background: radial-gradient(circle at 35% 30%, #fff, #e8e8e2 64%, #bfc3bd);
  border: 1px solid #c5cac2;
}

.ready-badge.is-ready {
  color: #71420b;
  background: #fff4cc;
  border-color: #eadb82;
  box-shadow: 0 8px 18px rgba(113, 66, 11, 0.10);
}

.ready-badge.is-waiting {
  color: #69736c;
  background: #f4f7f4;
  border-color: #d6ddd7;
}

#blackTimer,
#whiteTimer {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
}

#blackTimer.timer-active,
#whiteTimer.timer-active {
  color: #123a38;
  background: #e5f2ef;
}

#blackTimer.timer-byoyomi,
#whiteTimer.timer-byoyomi {
  color: #5d3d00;
  background: #fff4cc;
}

#blackTimer.timer-warning,
#whiteTimer.timer-warning {
  color: #8a4f00;
  background: #ffedd5;
}

#blackTimer.timer-danger,
#whiteTimer.timer-danger {
  color: #fff;
  background: #dc2626;
}

.lobby-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.lobby-actions button,
.room-create-form button,
.room-item button,
.lobby-user-item {
  min-height: 36px;
  padding: 0 12px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
}

.lobby-actions button:disabled,
.room-item button:disabled,
.room-create-form button:disabled,
.lobby-user-item:disabled {
  color: #78827c;
  background: #e7ece8;
  border-color: #d6ddd7;
  cursor: not-allowed;
}

.rank-editor button:hover:not(:disabled),
.lobby-actions button:hover:not(:disabled):not(.is-start-ready):not(.room-end-action),
.room-create-form button:hover:not(:disabled),
.room-pagination button:hover:not(:disabled),
.lobby-users-meta button:hover:not(:disabled),
.lobby-user-invite:hover:not(:disabled),
.invite-dialog-actions button:hover:not(:disabled),
.player-rank-edit button:hover:not(:disabled),
.settings-header button:hover:not(:disabled),
.board-mode-toolbar button:hover:not(:disabled),
.chat-form button:hover:not(:disabled),
.button-grid button:hover:not(:disabled):not(.danger) {
  background: var(--action-hover);
  box-shadow: var(--action-shadow);
}

.lobby-actions #readyRoomBtn:not(:disabled) {
  color: var(--action-ink);
  background: var(--action-hover);
  border-color: var(--action-border);
  box-shadow: var(--action-shadow);
}

.lobby-actions #readyRoomBtn.is-ready-next:not(:disabled) {
  color: #71420b;
  background: #fff4cc;
  border-color: #eadb82;
  box-shadow: 0 8px 18px rgba(113, 66, 11, 0.12);
}

.lobby-actions #readyRoomBtn.is-ready-next:hover:not(:disabled) {
  background: #ffedaa;
  border-color: #dfc766;
}

.lobby-actions #autoRuleBtn:not(:disabled):not(.is-rule-ready) {
  color: #71420b;
  background: #fff4cc;
  border-color: #eadb82;
  box-shadow: 0 8px 18px rgba(113, 66, 11, 0.12);
}

.lobby-actions #autoRuleBtn:hover:not(:disabled):not(.is-rule-ready) {
  background: #ffedaa;
  border-color: #dfc766;
}

.lobby-actions #autoRuleBtn.is-opponent-rule-complete:disabled {
  color: #6f7a73;
  background: #e7ece8;
  border-color: #d6ddd7;
  box-shadow: none;
  opacity: 1;
}

.lobby-actions #readyRoomBtn.is-cancel-ready:not(:disabled) {
  color: #4b5563;
  background: #eef1ef;
  border-color: #cfd8d0;
  box-shadow: 0 8px 18px rgba(75, 85, 99, 0.10);
}

.lobby-actions button.is-start-ready {
  color: #fff;
  background: #7f1d1d;
  border-color: #5f1717;
  box-shadow: 0 10px 22px rgba(127, 29, 29, 0.34);
}

.lobby-actions .room-end-action:not(:disabled) {
  color: #fff;
  background: #dc2626;
  border-color: #991b1b;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.28);
}

.lobby-actions button.is-start-ready:hover:not(:disabled),
.lobby-actions .room-end-action:hover:not(:disabled) {
  background: #681818;
  border-color: #4c1212;
}

.room-create-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 92px 140px 96px 96px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.room-create-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.room-create-form #roomPasswordWrap {
  grid-column: 3;
  min-width: 0;
}

.room-create-form #roomPasswordWrap span,
.room-create-form label[for="roomTitleInput"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.room-create-form label[for="roomVisibilitySelect"] {
  color: transparent;
  font-size: 0;
}

.room-create-form label[for="roomVisibilitySelect"] select {
  width: 100%;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

#roomTitleInput {
  grid-column: 1;
}

#cancelCreateRoomBtn,
#createRoomSubmitBtn {
  width: 96px;
  justify-self: stretch;
}

#cancelCreateRoomBtn {
  grid-column: 4;
}

#createRoomSubmitBtn {
  grid-column: 5;
}

#roomPasswordInput {
  width: 100%;
  max-width: none;
}

@media (max-width: 860px) {
  .room-create-form {
    grid-template-columns: minmax(160px, 1fr) 92px 140px;
  }

  #cancelCreateRoomBtn {
    grid-column: 2;
  }

  #createRoomSubmitBtn {
    grid-column: 3;
  }
}

.room-create-form input,
.room-create-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #ccd7cf;
  border-radius: 8px;
  font: inherit;
}

.room-create-form button {
  min-height: 44px;
  padding: 0 10px;
}

.room-list {
  display: grid;
  gap: 8px;
}

#lobbyListView {
  margin-bottom: 14px;
}

.room-list-tools,
.room-search,
.room-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
}

.room-list-tools {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.room-list-tools .room-search {
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: 260px;
  margin-top: 0;
}

.room-list-tools > label[for="roomSortSelect"] {
  margin-left: auto;
}

.room-list-tools label,
.room-search label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.room-list-tools select,
.room-search input {
  min-height: 38px;
  margin-left: 6px;
  padding: 0 10px;
  border: 1px solid #ccd7cf;
  border-radius: 8px;
  font: inherit;
}

.room-list-count {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.room-pagination {
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.room-pagination button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid #d7e0d9;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.room-pagination button[aria-current="page"] {
  color: var(--action-ink);
  background: var(--action-bg);
  border-color: var(--action-border);
}

.room-pagination button:disabled {
  color: #8a948d;
  background: #eef2ef;
  cursor: not-allowed;
}

.room-search input {
  width: min(360px, 100%);
}

.room-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #f6f8f6;
  border: 1px solid #e0e7e1;
  border-radius: 8px;
}

.room-item strong,
.room-item span,
.room-item .room-host {
  display: block;
  min-width: 0;
}

.room-item span,
.room-item .room-host {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.room-item .room-host {
  width: fit-content;
  min-height: auto;
  padding: 0;
  color: #28352f;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  cursor: default;
}

.room-item .room-host:hover {
  text-decoration: underline;
}

.room-item .room-condition {
  color: #173f3c;
  font-size: 13px;
  font-weight: 800;
}

.lobby-users-panel {
  position: sticky;
  top: 20px;
  grid-column: 2;
  grid-row: 3 / span 4;
  width: 260px;
  max-height: calc(100vh - 40px);
  padding: 14px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(28, 33, 30, 0.15);
}

.lobby-users-panel.is-room-open {
  top: 20px;
}

.lobby-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.lobby-users-header h3 {
  margin: 0;
  font-size: 16px;
}

.lobby-users-header span {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.lobby-users-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lobby-users-meta button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.lobby-user-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.lobby-user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  width: 100%;
  gap: 8px;
  justify-content: stretch;
  min-height: 40px;
  padding: 0 10px;
  text-align: left;
}

.lobby-user-nick {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  height: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  overflow: hidden;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-user-nick:hover {
  text-decoration: underline;
}

.lobby-user-state {
  display: inline-flex;
  align-items: center;
  height: 100%;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.9;
}

.lobby-user-invite {
  min-height: 28px;
  padding: 0 8px;
  color: var(--action-ink);
  background: #fff;
  border: 1px solid rgba(143, 199, 189, 0.9);
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.invite-dialog {
  position: fixed;
  top: 120px;
  left: 50%;
  z-index: 3000;
  width: min(430px, calc(100vw - 24px));
  overflow: hidden;
  background: #fff;
  border: 2px solid var(--action-border);
  border-radius: 12px;
  box-shadow: 0 22px 55px rgba(24, 22, 31, 0.28);
  transform: translateX(-50%);
}

.invite-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  color: #fff;
  background: #2f655d;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.invite-dialog.is-dragging .invite-dialog-header {
  cursor: grabbing;
}

.invite-dialog-header strong {
  font-size: 17px;
}

.invite-dialog-header button {
  width: 30px;
  height: 30px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.invite-dialog-body {
  padding: 20px 18px 14px;
  background: linear-gradient(180deg, #fff, #f8fbf9);
}

.invite-dialog-body p {
  margin: 0;
  color: #20241f;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.invite-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 18px;
  background: #f8fbf9;
}

.invite-dialog-actions button {
  min-height: 40px;
  padding: 0 16px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.invite-dialog-actions button.secondary {
  color: var(--accent-dark);
  background: #fff;
  border-color: #d7e0d9;
}

.player-profile-dialog {
  position: fixed;
  top: 110px;
  right: max(20px, calc((100vw - 1024px) / 2 + 20px));
  z-index: 4100;
  width: min(360px, calc(100vw - 24px));
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--action-border);
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(28, 33, 30, 0.18);
}

.player-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: var(--action-ink);
  background: var(--action-bg);
  font-weight: 900;
}

.player-profile-head button {
  width: 30px;
  height: 30px;
  color: var(--action-ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--action-border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.player-profile-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.player-profile-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.player-profile-summary strong {
  grid-column: 1 / -1;
  font-size: 18px;
}

.player-profile-summary span,
.player-rank-edit,
.player-recent-games li {
  padding: 9px 10px;
  background: #f6f8f6;
  border: 1px solid #dce3dd;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.player-rank-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.player-rank-edit select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #cfd8d0;
  border-radius: 8px;
  font-weight: 800;
}

.player-rank-edit button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.player-rank-edit button:disabled {
  color: #78827c;
  background: #e7ece8;
  border-color: #d6ddd7;
  cursor: not-allowed;
}

.player-rank-edit p {
  grid-column: 1 / -1;
  margin: 0;
}

.player-recent-games {
  display: grid;
  gap: 7px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.settings-header {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-header button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-grid select,
.settings-grid input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd7cf;
  border-radius: 8px;
  font: inherit;
}

.settings-grid .check-setting {
  display: flex;
  min-height: 38px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink);
  background: #f6f8f6;
  border: 1px solid #e0e7e1;
  border-radius: 8px;
}

.board-area {
  padding: clamp(10px, 2vw, 24px);
}

.board-mode-toolbar {
  display: none;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.board-mode-toolbar button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

#boardNormalBtn {
  display: none;
  color: #20241f;
  background: #eef1ef;
  border-color: #cfd8d0;
}

.board-frame {
  width: min(100%, var(--play-board-max, calc(100vh - 180px)));
  min-width: 280px;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 20px);
  background: linear-gradient(135deg, #e6ba72, var(--board) 55%, var(--board-deep));
  border: 2px solid #8d5621;
  border-radius: 8px;
  box-shadow: var(--shadow), inset 0 0 22px rgba(88, 48, 16, 0.22);
}

.board-chat {
  position: static;
  width: auto;
  min-width: 0;
  margin: 0 0 20px;
  padding: 16px;
  transform: none;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1px;
  height: clamp(150px, 22vh, 220px);
  max-height: none;
  min-height: 120px;
  margin-bottom: 8px;
  overflow: auto;
  color: #252b26;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.25;
}

.chat-messages:empty::before {
  content: "아직 채팅이 없습니다.";
  color: var(--muted);
}

.chat-messages > div {
  display: flex;
  gap: 3px;
  align-items: baseline;
  min-width: 0;
}

.chat-meta {
  flex: 0 0 auto;
  color: var(--accent-dark);
  font-size: 11.5px;
  font-weight: 800;
}

.chat-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.chat-system .chat-meta,
.chat-system .chat-text {
  color: var(--muted);
  font-weight: 800;
}

.chat-form {
  display: grid;
  grid-template-columns: auto 108px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.chat-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chat-form select,
.chat-form input,
.chat-form button {
  min-height: 38px;
  border-radius: 8px;
}

.chat-form select {
  width: 100%;
  min-width: 0;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd7cf;
  font-size: 12px;
  font-weight: 800;
}

.chat-form input {
  width: 100%;
  padding: 0 11px;
  border: 1px solid #ccd7cf;
}

.chat-form button {
  padding: 0 14px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  cursor: pointer;
  font-weight: 800;
}

.baduk-board {
  --board-size: 19;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--board-size), minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
}

.board-grid-lines {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.board-grid-lines line {
  stroke: var(--line);
  stroke-width: 1px;
  stroke-linecap: square;
}

.board-point {
  position: relative;
  z-index: 1;
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.board-point::before,
.board-point::after {
  display: none;
}

.board-point::before {
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  transform: translateY(-50%);
}

.board-point::after {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}

.board-point.edge-left::before {
  left: 50%;
}

.board-point.edge-right::before {
  right: 50%;
}

.board-point.edge-top::after {
  top: 50%;
}

.board-point.edge-bottom::after {
  bottom: 50%;
}

.board-point:focus-visible {
  outline: 3px solid #2e7bd1;
  outline-offset: -3px;
}

.star-point {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  background: var(--line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.stone {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 86%;
  height: 86%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.stone-black {
  background: radial-gradient(circle at 32% 28%, #5e5e5e 0, #1d1d1d 38%, #030303 100%);
  box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.52), 0 3px 7px rgba(0, 0, 0, 0.38);
}

.stone-white {
  background: radial-gradient(circle at 32% 28%, #ffffff 0, #f1eee6 45%, #c8c3b8 100%);
  border: 1px solid rgba(45, 38, 28, 0.28);
  box-shadow: inset -5px -8px 13px rgba(120, 110, 94, 0.25), 0 3px 7px rgba(0, 0, 0, 0.25);
}

.board-point.is-last .stone::after {
  content: "";
  width: 28%;
  height: 28%;
  border: 2px solid #e8473f;
  border-radius: 50%;
}

.stone-dead {
  opacity: 0.45;
}

.dead-mark {
  position: absolute;
  color: #d72e28;
  font-size: clamp(13px, 2vw, 22px);
  font-weight: 900;
  line-height: 1;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.side-panel section {
  padding: 16px;
}

.score-list,
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-list div,
.result-grid div {
  padding: 10px;
  background: #f6f8f6;
  border: 1px solid #e0e7e1;
  border-radius: 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.score-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f6f8f6;
  border: 1px solid #e0e7e1;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.score-switch input {
  width: 42px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.button-grid button {
  min-height: 42px;
  padding: 9px 10px;
  color: var(--action-ink);
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button-grid button:hover:not(:disabled) {
  background: var(--action-hover);
}

.button-grid button:disabled {
  color: #8b958d;
  background: #e6ebe7;
  border-color: #d1d9d3;
  cursor: not-allowed;
}

.button-grid .danger {
  color: #fff;
  background: var(--danger);
  border-color: #75312d;
}

.button-grid .danger:hover:not(:disabled) {
  background: #87352f;
  border-color: #642823;
}

body.baduk-board-focus {
  overflow: hidden;
}

.baduk-board-focus .top-panel,
.baduk-board-focus .member-panel,
.baduk-board-focus .lobby-panel,
.baduk-board-focus .settings-panel {
  display: none;
}

.baduk-board-focus .side-panel {
  display: block;
}

.baduk-board-focus .side-panel section:not(.control-panel) {
  display: none;
}

.baduk-board-focus .app {
  width: 100vw;
  max-width: none;
  padding: 0;
}

.baduk-board-focus .main-layout {
  display: block;
}

.baduk-board-focus .board-area {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px calc(var(--baduk-focus-chat-width, 340px) + 24px) 12px 12px;
  background: var(--bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.baduk-board-focus .board-mode-toolbar {
  position: fixed;
  top: var(--baduk-focus-header-top, 12px);
  left: var(--baduk-focus-chat-left, auto);
  right: auto;
  z-index: 10001;
  display: flex;
  justify-content: flex-end;
  width: var(--baduk-focus-chat-width, 340px);
  margin: 0;
}

.baduk-board-focus #boardFocusBtn {
  display: none;
}

.baduk-board-focus #boardNormalBtn {
  display: inline-block;
}

.baduk-board-focus .room-ticker {
  display: none !important;
}

.baduk-board-focus .focus-room-ticker {
  position: fixed;
  top: var(--baduk-focus-header-top, 12px);
  left: var(--baduk-focus-chat-left, auto);
  z-index: 10001;
  display: grid !important;
  width: calc(var(--baduk-focus-chat-width, 380px) - 104px);
  min-height: 78px;
  padding: 8px 10px;
  text-align: left;
}

.baduk-board-focus .focus-room-ticker .room-clock-grid {
  gap: 6px;
}

.baduk-board-focus .focus-room-ticker .room-clock {
  padding: 7px 8px;
}

.baduk-board-focus .focus-room-ticker .room-clock-time {
  font-size: 21px;
}

.baduk-board-focus .focus-room-ticker .room-clock-sub,
.baduk-board-focus .focus-room-ticker .room-ticker-sub {
  font-size: 11px;
}

.baduk-board-focus .board-frame {
  width: min(calc(100vw - 24px), var(--play-board-max, calc(100vh - 190px)));
  min-width: 0;
  margin: auto;
  padding: clamp(8px, 1.4vw, 18px);
}

.baduk-board-focus .board-chat {
  position: fixed;
  top: var(--baduk-focus-chat-top, 132px);
  left: var(--baduk-focus-chat-left, auto);
  right: auto;
  bottom: auto;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  width: var(--baduk-focus-chat-width, 340px);
  height: var(--baduk-focus-chat-height, calc(100vh - 76px));
  min-width: 0;
  margin: 0;
  padding: 10px;
  background: #f6f8f6;
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(26, 31, 28, 0.22);
  transform: none;
}

.baduk-board-focus .side-panel .control-panel {
  position: fixed;
  top: var(--baduk-focus-control-top, auto);
  left: var(--baduk-focus-chat-left, auto);
  right: auto;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  width: var(--baduk-focus-chat-width, 340px);
  height: var(--baduk-focus-control-height, auto);
  min-width: 0;
  margin: 0;
  padding: 10px;
  overflow: auto;
  background: #f6f8f6;
  border: 1px solid #dce3dd;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(26, 31, 28, 0.18);
  transform: none;
}

.baduk-board-focus .control-panel h2 {
  margin-bottom: 8px;
  font-size: 16px;
}

.baduk-board-focus .control-panel .score-switch {
  min-height: 34px;
  margin-bottom: 8px;
}

.baduk-board-focus .control-panel .button-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.baduk-board-focus .control-panel .button-grid button {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
}

.baduk-board-focus .chat-messages {
  flex: 1 1 auto;
  height: auto;
  max-height: none;
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.winner {
  display: block;
  margin-top: 12px;
  padding: 12px;
  color: #173f3c;
  background: #e5f2ef;
  border: 1px solid #bddbd4;
  border-radius: 8px;
  font-size: 18px;
}

.move-history {
  max-height: 230px;
  margin: 0;
  padding-left: 24px;
  overflow: auto;
  color: #30362f;
  line-height: 1.7;
}

.move-history:empty::before {
  content: "아직 수순이 없습니다.";
  margin-left: -24px;
  color: var(--muted);
}

.result-panel[hidden],
.history-panel {
  display: none;
}

@media (max-width: 980px) {
  .baduk-gnuboard-app {
    display: block;
  }

  .lobby-users-panel {
    position: static;
    width: auto;
    max-height: none;
    margin: 0 0 20px;
  }

  .top-panel,
  .member-panel,
  .lobby-panel,
  .lobby-header,
  .settings-grid,
  .main-layout {
    grid-template-columns: 1fr;
  }

  .lobby-header:has(.room-ticker:not([hidden])) {
    grid-template-columns: 1fr;
  }

  .lobby-header .room-ticker {
    grid-column: 1;
    width: 100%;
    box-sizing: border-box;
  }

  body.baduk-room-chat .main-layout {
    position: static;
    width: auto;
    max-height: none;
    margin: 0 0 20px;
  }

  body.baduk-room-chat .board-chat {
    min-height: 280px;
    max-height: none;
  }

  .lobby-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lobby-flow li:not(:last-child)::after {
    display: none;
  }

  .board-frame {
    width: min(100%, 720px);
  }

  .board-chat {
    width: var(--baduk-chat-width, min(100%, 720px));
  }

  body.baduk-playing .main-layout,
  body.baduk-playing .side-panel {
    grid-template-columns: 1fr;
  }

  body.baduk-playing .board-area,
  body.baduk-playing .board-chat,
  body.baduk-playing .control-panel,
  body.baduk-playing .info-panel,
  body.baduk-playing .result-panel,
  body.baduk-playing .history-panel {
    grid-column: 1;
    grid-row: auto;
  }

  body.baduk-playing .score-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.baduk-playing .chat-messages {
    min-height: 140px;
  }

  .baduk-board-focus .board-area {
    padding: 12px;
  }

  .baduk-board-focus .board-frame {
    margin: auto auto 0;
  }

  .baduk-board-focus .board-chat {
    left: 50%;
    top: auto;
    right: auto;
    bottom: 12px;
    width: var(--baduk-chat-width, min(calc(100vw - 24px), var(--play-board-max, calc(100vh - 190px))));
    height: auto;
    max-height: 34vh;
    transform: translateX(-50%);
  }

  .baduk-board-focus .chat-messages {
    flex: 0 1 auto;
    max-height: 58px;
    min-height: 24px;
  }

  .baduk-board-focus .side-panel .control-panel {
    display: none;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 10px;
  }

  .top-panel,
  .side-panel section {
    padding: 14px;
  }

  h1 {
    font-size: 23px;
  }

  .game-facts,
  .score-list,
  .result-grid,
  .button-grid,
  .rank-editor,
  .room-create-form,
  .room-item,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .lobby-header,
  .room-list-tools,
  .room-search {
    display: grid;
  }

  .lobby-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .lobby-actions button {
    min-width: 0;
    min-height: 38px;
    padding: 0 6px;
    font-size: 13px;
  }

  .room-ready-status {
    grid-template-columns: 1fr;
  }

  .room-ticker {
    min-height: 0;
    gap: 6px;
    padding: 8px;
  }

  .room-ticker-turn,
  .room-ticker-sub {
    font-size: 12px;
  }

  .room-clock-grid {
    gap: 5px;
  }

  .room-clock {
    gap: 4px;
    padding: 6px;
  }

  .room-clock-label,
  .room-clock-sub {
    font-size: 11px;
  }

  .room-clock-stone {
    width: 11px;
    height: 11px;
  }

  .room-clock-time {
    font-size: 22px;
  }

  .room-create-form #roomPasswordWrap,
  #cancelCreateRoomBtn,
  #createRoomSubmitBtn {
    grid-column: auto;
  }

  .lobby-flow {
    grid-template-columns: 1fr;
  }

  .room-list-tools select,
  .room-search input {
    width: 100%;
    margin-left: 0;
  }

  .settings-header {
    display: grid;
  }

  .board-area {
    padding: 8px;
  }

  .board-frame {
    min-width: 0;
    padding: 8px;
  }

  .board-chat {
    min-width: 0;
  }

  .chat-messages {
    height: 130px;
    min-height: 110px;
  }

  .chat-form,
  .chat-messages > div {
    grid-template-columns: 1fr;
  }

  .chat-messages > div {
    display: grid;
    gap: 2px;
  }

  .star-point {
    width: 5px;
    height: 5px;
  }
}
