/* ===== Game header ===== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  padding: 8px 12px;
  background: #1f2942;
  border-radius: 8px;
  margin-bottom: 12px;
  box-sizing: border-box;
  gap: 12px;
  flex-wrap: wrap;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #c8d0e8;
  font-size: 0.95em;
}

.progress {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #f0f4ff;
}

/* ===== Play area ===== */
.play-area {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
  max-width: 1200px;
  justify-content: center;
}

.canvas-region {
  position: relative;
  flex: 0 0 auto;
}

#puzzle-canvas {
  display: block;
  background: #14182a;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  touch-action: none;
  max-width: 100%;
  height: auto;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-section {
  background: #1f2942;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.sidebar-section h2 {
  margin: 0 0 8px 0;
  font-size: 0.95em;
  font-weight: 600;
  color: #a8b8d8;
  border-bottom: 1px solid #3a4868;
  padding-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#game-player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95em;
}

#game-player-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: #d0d8ee;
}

#game-player-list li.is-you {
  color: #80e0ff;
}

#game-player-list .player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

#game-player-list .player-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#game-player-list .player-score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #a8b8d8;
}

/* ===== Chat ===== */
#chat-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
  max-height: 280px;
  min-height: 160px;
  overflow-y: auto;
  font-size: 0.9em;
}

#chat-list li {
  padding: 4px 0;
  color: #d0d8ee;
  word-break: break-word;
  line-height: 1.4;
}

#chat-list li .sender {
  font-weight: 600;
  margin-right: 4px;
}

#chat-list li.kind-system {
  color: #a8b8d8;
  font-style: italic;
}

#chat-list li.kind-join {
  color: #a8d0ff;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 6px;
}

#chat-input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid #3a4868;
  background: #16213e;
  color: #f0f4ff;
  font-family: inherit;
  font-size: 0.9em;
  min-width: 0;
}

#chat-input:disabled {
  background: #14182a;
  color: #707898;
  cursor: not-allowed;
}

#btn-send-chat {
  padding: 7px 12px;
  font-size: 0.9em;
}

/* ===== Overlays ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

.overlay-card {
  background: #1f2942;
  border: 1px solid #3a4868;
  border-radius: 10px;
  padding: 24px 32px;
  text-align: center;
  max-width: 80%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  margin: 0 0 8px 0;
  color: #f0f4ff;
}

.overlay-card .overlay-sub {
  margin: 0 0 16px 0;
  color: #a8b0c8;
}

.overlay-card .overlay-sub strong {
  color: #ffd479;
  font-size: 1.2em;
  letter-spacing: 0.05em;
}

.final-scoreboard {
  list-style: decimal inside;
  padding: 0;
  margin: 0 0 16px 0;
  text-align: left;
  max-width: 320px;
}

.final-scoreboard li {
  padding: 6px 10px;
  color: #d0d8ee;
  font-size: 1.05em;
  display: flex;
  justify-content: space-between;
}

.final-scoreboard li:first-child {
  color: #ffd479;
  font-weight: 700;
}

.final-scoreboard li .player-score {
  font-variant-numeric: tabular-nums;
}

/* ===== Reference image (in-game thumbnail) ===== */
.reference-image {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 140px;
  aspect-ratio: 4 / 3;
  background: rgba(20, 24, 42, 0.92);
  border: 1px solid #3a4868;
  border-radius: 6px;
  overflow: hidden;
  z-index: 5;
  display: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.reference-image.active {
  display: block;
}

.reference-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#btn-toggle-ref.active {
  background: #3a4868;
  border-color: #e94560;
}

/* ===== Mobile ===== */
@media (max-width: 920px) {
  body { padding: 12px; }
  h1 { font-size: 1.4em; }
  .play-area {
    flex-direction: column;
    align-items: center;
  }
  .sidebar {
    width: 100%;
    max-width: 800px;
  }
  #chat-list { max-height: 180px; min-height: 100px; }
  .game-header {
    font-size: 0.9em;
  }
}

@media (max-width: 768px) {
  .reference-image {
    width: 90px;
  }
}
