/*
 * Copyright (C) 2026 Lele
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  font-family: 'Segoe UI', 'Poppins', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 36px;
  padding: 24px 20px 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 700px;
  width: 100%;
  text-align: center;
}

h1 {
  font-size: 1.8rem;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}

.subtitle {
  color: #5a6e7c;
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.back-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.back-link {
  color: #2c7da0;
  text-decoration: none;
  font-size: 0.8rem;
  transition: 0.2s;
}

.back-link:hover {
  color: #1f5068;
  transform: translateX(-2px);
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eef2f5;
  padding: 10px 18px;
  border-radius: 60px;
  margin-bottom: 24px;
  font-weight: bold;
  flex-wrap: wrap;
  gap: 10px;
}

#newGameBtn {
  background: #2e7d64;
  border: none;
  color: white;
  padding: 6px 18px;
  border-radius: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

#newGameBtn:hover {
  background: #1f5e4a;
  transform: scale(1.02);
}

/* ========== Binairo 网格布局（格子间有提示） ========== */
.binairo-wrapper {
  display: flex;
  justify-content: center;
  overflow: visible;
}

.binairo-grid {
  --cell-size: 52px;
  display: inline-block;
  background-color: #2c3e50;
  padding: 10px;
  border-radius: 20px;
}

.binairo-grid {
  --cell-size: 52px;
  --conn-ratio: 0.55;
  display: inline-block;
  background-color: #2c3e50;
  padding: 10px;
  border-radius: 20px;
}

/* 行样式 */
.grid-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

/* 单元格 */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  flex-shrink: 0;
  flex-grow: 0;
  background-color: #fef9e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.45);
  font-weight: bold;
  cursor: pointer;
  box-sizing: border-box;
}

.cell.selected {
  box-shadow: inset 0 0 0 3px #f39c12;
  background-color: #fff3e0;
}

.cell.black {
  background-color: #2c3e50;
  color: white;
}

/* .cell.white {
  background-color: #ecf0f1;
  color: #2c3e50;
} */

.cell.white {
  background-color: #2c3e50;
  color: white;
}

.cell.locked {
  color: #8a8a8a;
}

.cell.empty {
  background-color: #2c3e50;
}

.cell:active {
  transform: scale(0.97);
}

/* 水平连接线（格子之间） */
.horizontal-connector {
  width: calc(var(--cell-size) * 0.55);
  height: var(--cell-size);
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.3);
  background-color: #2c3e50;
  cursor: pointer;
  box-sizing: border-box;
}


.horizontal-connector.equal {
  color: #27ae60;
  background-color: #d5f5e3;
}

.horizontal-connector.cross {
  color: #e74c3c;
  background-color: #fadbd8;
}

.horizontal-connector.empty {
  color: #7f8c8d;
  background-color: #34495e;
}

.spacer {
  width: calc(var(--cell-size) * 0.55);
  height: calc(var(--cell-size) * 0.55);
  flex-shrink: 0;      /* 防止被压缩 */
  flex-grow: 0;        /* 防止被拉伸 */
  background-color: #2c3e50;
  box-sizing: border-box;
}

/* 垂直连接线（行之间） */
.vertical-connectors {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.vertical-connector {
  width: var(--cell-size);
  height: calc(var(--cell-size) * 0.55);
  flex-shrink: 0;      /* 防止被压缩 */
  flex-grow: 0;        /* 防止被拉伸 */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.3);
  background-color: #2c3e50;
  cursor: pointer;
  box-sizing: border-box;
}

.vertical-connector.equal {
  color: #27ae60;
  background-color: #d5f5e3;
}

.vertical-connector.cross {
  color: #e74c3c;
  background-color: #fadbd8;
}

.vertical-connector.empty {
  color: #7f8c8d;
  background-color: #34495e;
}

/* 操作栏 */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}

.action-btn {
  background: #2c3e50;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 40px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: 0.1s;
}

.action-btn:hover {
  background: #1e2f3a;
  transform: translateY(-2px);
}

.action-btn.clear-btn {
  background: #b33b2c;
}

.action-btn.clear-btn:hover {
  background: #8e2c1f;
}

.message {
  font-size: 0.9rem;
  font-weight: bold;
  min-height: 48px;
  color: #2e7d64;
  margin: 8px 0;
}

.instructions {
  background: #eef2f5;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 0.75rem;
  color: #2c3e50;
  text-align: left;
  margin-top: 12px;
}

details summary {
  font-weight: bold;
  cursor: pointer;
  color: #1e4663;
}

@media (min-width: 800px) {
  .binairo-grid {
    --cell-size: 56px;
  }
}

@media (max-width: 600px) {
  .binairo-grid {
    --cell-size: min(42px, 10vw);
  }
}

@media (max-width: 480px) {
  .binairo-grid {
    --cell-size: min(36px, 12vw);
  }
}