.gomoku-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.gomoku-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 34px);
}

.gomoku-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.gomoku-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.08;
}

.gomoku-header p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
}

.gomoku-note {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.gomoku-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gomoku-actions button {
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

.gomoku-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.gomoku-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.gomoku-board {
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  width: min(100%, 860px);
  aspect-ratio: 1;
  background: #d7a95e;
  border: 2px solid #805624;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.gomoku-cell {
  position: relative;
  border-right: 1px solid rgba(72, 45, 18, 0.58);
  border-bottom: 1px solid rgba(72, 45, 18, 0.58);
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.gomoku-cell:nth-child(25n) {
  border-right: 0;
}

.gomoku-cell:nth-last-child(-n + 25) {
  border-bottom: 0;
}

.gomoku-cell::after {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 120ms ease;
}

.gomoku-cell.black::after {
  background: radial-gradient(circle at 35% 30%, #5a5a5a, #050505 62%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transform: scale(1);
}

.gomoku-cell.white::after {
  background: radial-gradient(circle at 35% 30%, #ffffff, #d6d6d6 64%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
  transform: scale(1);
}

.gomoku-cell.win {
  background: rgba(15, 118, 110, 0.24);
}

.gomoku-sidebar {
  display: grid;
  gap: 14px;
}

.gomoku-info {
  display: grid;
  gap: 12px;
}

.gomoku-info div {
  border: 1px solid var(--line);
  background: #f8fafb;
  padding: 14px;
}

.gomoku-info span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.gomoku-info strong {
  font-size: 1.06rem;
}

.secondary-link {
  margin-left: 10px;
}

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

.room-card {
  display: grid;
  gap: 12px;
  min-height: 220px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fafb);
  color: var(--ink);
  text-decoration: none;
  padding: 22px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.room-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 16px 40px rgba(31, 41, 55, 0.11);
  transform: translateY(-2px);
}

.room-name {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  aspect-ratio: 1;
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: #eef8f6;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}

.room-summary {
  color: var(--muted);
  font-size: 0.92rem;
}

.room-note {
  border-left: 3px solid rgba(15, 118, 110, 0.35);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
  padding-left: 10px;
}

.room-seat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.room-seat i {
  width: 9px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #a9b4be;
}

.room-seat.is-seated {
  color: var(--accent);
}

.room-seat.is-seated i {
  background: var(--accent);
}

.chat-panel {
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 14px;
}

.move-notice {
  margin-bottom: 10px;
  border-left: 4px solid var(--accent);
  background: #d9f0ed;
  color: #0b5f59;
  font-weight: 800;
  padding: 10px 12px;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 9px;
  height: 230px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: #f8fafb;
  padding: 10px;
}

.chat-message {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--line);
  background: #ffffff;
  padding: 8px 9px;
}

.chat-message span {
  font-size: 0.82rem;
  font-weight: 800;
}

.chat-message p {
  margin: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.chat-message.black {
  border-left-color: #1e2329;
}

.chat-message.black span {
  color: #1e2329;
}

.chat-message.white {
  border-left-color: #7c8794;
}

.chat-message.white span {
  color: #5d6670;
}

.chat-message.system {
  border-left-color: var(--accent);
  background: #eef8f6;
}

.chat-message.system span {
  color: var(--accent);
}

.emoji-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.emoji-panel div {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.emoji-panel span {
  min-width: 36px;
  color: var(--muted);
  font-size: 0.82rem;
}

.emoji-panel button,
.chat-form button {
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.emoji-panel button {
  min-height: 30px;
  padding: 0 7px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  margin-top: 12px;
}

.chat-form input {
  min-width: 0;
}

.chat-form button {
  font-weight: 700;
}

.chat-hint {
  min-height: 22px;
  margin: 8px 0 0;
  color: #b42318;
  font-size: 0.86rem;
}

.undo-dialog {
  width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.undo-dialog::backdrop {
  background: rgba(30, 35, 41, 0.24);
}

.undo-dialog p {
  margin: 0 0 18px;
  font-weight: 800;
  line-height: 1.6;
}

.undo-dialog div {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.undo-dialog button {
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

.undo-dialog button:last-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

@media (max-width: 840px) {
  .gomoku-header,
  .gomoku-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .gomoku-actions {
    justify-content: start;
  }

  .gomoku-info {
    grid-template-columns: 1fr;
  }

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