/* Game-specific styles - Modern overrides */

/* Ensure game layout works properly */
.game-layout {
  min-height: calc(100vh - var(--header-height));
}

/* Hide old sidebar styles */
#left-sidebar {
  display: none !important;
}

/* Override main content margin for new layout */
#main-content.with-sidebar {
  margin-left: 0;
  padding: 0;
}

/* Ensure board container is properly styled */
.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  .game-layout {
    flex-direction: column;
  }
  
  .game-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    transform: translateX(-100%);
    z-index: var(--z-modal);
    background-color: var(--app-bg);
    border-right: none;
    border-bottom: 1px solid var(--app-border);
  }
  
  .game-sidebar.open {
    transform: translateX(0);
  }
  
  .game-main {
    width: 100%;
  }
}

/* Legacy support for any remaining old classes */
.instruction-examples {
  margin: var(--space-4) 0;
  padding: var(--space-3);
  background-color: var(--surface-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.example-item {
  display: flex;
  align-items: center;
  margin: var(--space-2) 0;
  gap: var(--space-3);
}

.example-label {
  font-weight: var(--font-medium);
  min-width: 120px;
  color: var(--text);
}

.example-square {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.example-square.light {
  background-color: var(--board-light);
}

.example-square.dark {
  background-color: var(--board-dark);
}

.example-square.wall {
  background-color: var(--board-wall);
}

.example-square.upgrade {
  background-color: var(--board-upgrade);
}

.example-square.movable {
  background-color: var(--board-move);
}

.example-desc {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Board loading and error states */
.board-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  min-height: 300px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.board-loading p {
  color: var(--text-muted);
  font-size: var(--text-lg);
  margin: 0;
}

.board-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  min-height: 300px;
  text-align: center;
}

.board-error p {
  color: var(--error-600);
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
}

/* ── Keyboard controls list ──────────────────────────────────────────── */

.controls-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: var(--space-3, 0.75rem);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-md);
}

.controls-list > :first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.controls-list > :last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Paired row — two equal cells side by side */
.control-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 0.0625rem solid var(--border);
}

.controls-list > .control-pair:first-child {
  border-top: none;
}

.control-pair .control-btn {
  width: 100%;
  height: 100%;
  border-top: none;
  border-radius: 0;
}

.control-pair .control-btn:first-child {
  border-right: 0.0625rem solid var(--border);
}

.kbd-group {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  font-weight: var(--font-medium);
  background: var(--surface-raised);
  border: none;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition-fast);
  text-align: left;
  box-sizing: border-box;
}

.control-btn kbd {
  flex-shrink: 0;
  min-width: 1.5rem;
  text-align: center;
}

.control-btn > span {
  flex: 1;
}

.control-btn:hover {
  background: var(--surface);
}

.control-btn.active {
  background: var(--primary-600);
  color: white;
}

.control-btn--static {
  cursor: default;
  color: var(--text-muted);
}

.control-btn--static:hover {
  background: var(--surface-raised);
}

/* Pan arrow cluster */
.control-btn--pan {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  justify-content: center;
}

.pan-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 1.6rem;
  flex-shrink: 0;
}

.pan-arrows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.pan-row {
  display: flex;
  gap: 1px;
}

.pan-arrow-btn {
  background: var(--surface-raised);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background var(--transition-fast);
}

.pan-arrow-btn kbd {
  display: block;
  pointer-events: none;
  margin: 0;
  box-shadow: none;
  background: transparent;
  border: none;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
}

.pan-arrow-btn:hover {
  background: var(--surface);
}

/* ── Sidebar Quick Actions ────────────────────────────────────────────── */

.sidebar-quick-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 0.0625rem solid var(--border);
}

.sidebar-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-2);
  font-size: 0.75rem;
  font-weight: var(--font-medium);
  background: var(--surface-raised);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.sidebar-quick-btn:hover {
  background: var(--surface);
}

.sidebar-quick-btn.active {
  background: var(--primary-600);
  color: white;
}

/* ── Chat Sidebar ─────────────────────────────────────────────────────── */

.chat-sidebar {
  position: fixed;
  top: var(--header-height, 4rem); /* JS overrides this with actual header height */
  right: 0;
  width: var(--sidebar-width, 14rem);
  background-color: var(--app-bg-raised);
  border-left: 0.0625rem solid var(--app-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky, 1020);
  transition: transform var(--transition-base, 200ms ease-in-out);
  overflow: hidden;
  border-radius: 0 0 0 var(--radius-lg, 0.5rem);
}

.chat-sidebar:hover {
  z-index: calc(var(--z-fixed) + 1000);
}

.chat-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3, 0.75rem);
  border-bottom: 0.0625rem solid var(--border);
  flex-shrink: 0;
}

.chat-sidebar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.chat-sidebar-title kbd.shortcut-hint {
  font-size: 0.7rem;
  opacity: 0.6;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.chat-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1;
  border-radius: var(--radius-base);
}

.chat-toggle-btn:hover {
  background: var(--surface-raised);
}

/* chat-body fills remaining vertical space */
.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  gap: 0.4rem;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 2px;
}

.chat-message {
  font-size: 0.82rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  max-width: 92%;
  word-break: break-word;
  background: var(--surface-raised);
  border: 0.0625rem solid var(--border);
}

.chat-message-mine {
  align-self: flex-end;
  background: var(--primary-100);
  border-color: var(--primary-200, #bae6fd);
}

.chat-message-theirs {
  align-self: flex-start;
}

.chat-message-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.chat-sender {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.chat-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-body-text {
  line-height: 1.4;
}

.chat-input-row {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  padding-top: 0.25rem;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-base);
  background: var(--surface);
  color: var(--text);
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 2px var(--primary-100);
}

.chat-send-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-completed-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* Mobile: hide chat sidebar (limited screen space) */
@media (max-width: 768px) {
  .chat-sidebar {
    display: none;
  }
}

/* ── Sidebar resize handles ───────────────────────────────────────────────── */

.sidebar-resize-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  cursor: move;
  z-index: 10;
  opacity: 0.35;
  transition: opacity 0.15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle:active {
  opacity: 0.85;
}

/* Corner grip dots — 3×3 dot grid rendered via radial-gradient */
.sidebar-resize-handle::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, var(--text-muted) 1.5px, transparent 1.5px);
  background-size: 5px 5px;
  background-repeat: repeat;
}

/* Left sidebar: handle sits in the upper-right corner */
.resize-top-right {
  top: 4px;
  right: 4px;
}

/* Chat sidebar: handle sits in the upper-left corner */
.resize-top-left {
  top: 4px;
  left: 4px;
}

/* ── Draw Offer Panel ─────────────────────────────────────────────────────── */

.draw-offer-panel {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: var(--surface-raised);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg, 0.5rem);
  padding: 0.75rem 1.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  min-width: 20rem;
  max-width: 90vw;
  text-align: center;
}

.draw-offer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
}

.draw-offer-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.draw-offer-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.draw-action-btn {
  min-width: 6rem;
  padding: 0.3rem 0.9rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm, 0.25rem);
  cursor: pointer;
  border: none;
  font-weight: 600;
}
