body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ececec;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 16px;
  box-sizing: border-box;
}

.app-view-container {
  width: 100%;
  max-width: 1120px;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  visibility: hidden;
}

.view-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  cursor: pointer;
  border-radius: 4px;
}

.view-tab.active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}

body.start-screen-visible #board {
  visibility: hidden;
  pointer-events: none;
}

body.start-screen-visible .game-side-panel {
  visibility: hidden;
  pointer-events: none;
}

#board-container {
  position: relative;
  width: 640px;
  height: 640px;
  border: 2px solid #333;
  background: #ddd;
  overflow: hidden;
}

#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  /* Number of fields visible within the viewport */
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);
}

#start-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.board-wrapper {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
}

.game-side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#minimap-container {
  width: 160px;
  height: 160px;
  border: 1px solid #999;
  background: #1f2937;
  position: relative;
}

#minimap {
  width: 100%;
  height: 100%;
  display: block;
}

#seat-panel {
  width: 160px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.07);
}

#seat-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #111827;
}

.seat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seat-entry {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 6px;
  font-size: 12px;
  background: #f9fafb;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.seat-entry:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.seat-entry.seat-owned {
  border-color: #10b981;
  background: #ecfdf5;
}

.seat-entry.seat-occupied {
  cursor: not-allowed;
  opacity: 0.75;
}

.seat-entry.turn-active {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45);
}

#turn-info {
  margin: 4px 0 0;
}

#turn-menu h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #111827;
}

#turn-menu select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
  background: #f9fafb;
}

.seat-entry strong {
  font-size: 13px;
  color: #111827;
}

.seat-entry .seat-occupant {
  font-size: 12px;
  color: #374151;
}

.seat-entry .seat-empty {
  color: #9ca3af;
}

.seat-message {
  margin: 8px 0 0;
  font-size: 11px;
  color: #6b7280;
}

#map-menu,
#placement-menu,
#rooms-menu {
  background: #fff;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#map-menu h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #111827;
}

.input-hint {
  font-size: 12px;
  color: #dc2626;
  margin: 0;
}

.player-name-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.player-name-modal.visible {
  display: flex;
}

.player-name-dialog {
  background: #ffffff;
  border-radius: 8px;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.25);
}

.player-name-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: #111827;
}

.player-name-dialog p {
  font-size: 14px;
  color: #4b5563;
  margin: 0 0 12px;
}

.player-name-dialog label {
  display: block;
  font-size: 13px;
  color: #374151;
  margin-bottom: 4px;
}

#player-name-field {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-sizing: border-box;
  margin-bottom: 8px;
}

#player-name-field.input-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.2);
}

#player-name-submit {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  color: #fff;
  background: #2563eb;
  cursor: pointer;
}

#player-name-submit:hover {
  background: #1d4ed8;
}

#map-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-option {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f3f4f6;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.map-option:hover:not(.active):not(:disabled) {
  background: #e5e7eb;
}

.map-option.active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}

.map-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.map-option[data-loaded="true"]::after {
  content: "current";
  font-size: 10px;
  color: #059669;
  margin-left: 6px;
  text-transform: uppercase;
}

.map-option.active[data-loaded="true"]::after {
  color: #bfdbfe;
}

#placement-menu h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #111827;
}

#placement-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
}

#start-button {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: #10b981;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}

#start-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

#start-button:not(:disabled):hover {
  background: #059669;
}

.cell {
  box-sizing: border-box;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  user-select: none;
}

.light {
  background: #f0d9b5;
}

.dark {
  background: #b58863;
}

.cell.highlight {
  outline: 3px solid rgba(0, 128, 255, 0.7);
  position: relative;
  z-index: 1;
}

.cell.selected {
  box-shadow: inset 0 0 0 3px rgba(255, 215, 0, 0.9);
}

.cell.obstacle {
  position: relative;
  background: repeating-linear-gradient(
    45deg,
    #374151,
    #374151 4px,
    #4b5563 4px,
    #4b5563 8px
  );
  color: #f3f4f6;
}

.cell.obstacle::after {
  content: attr(data-obstacle-icon);
  font-size: 24px;
  pointer-events: none;
}

.piece {
  pointer-events: none; /* clicks are handled by the cell, not the piece glyph */
  color: #1f2937;
}

.piece.piece-white {
  color: #f9fafb;
  text-shadow: 0 0 2px #111827, 0 0 6px rgba(0, 0, 0, 0.45);
}

.piece.piece-black {
  color: #111827;
}

.piece.piece-green {
  color: #10b981;
  text-shadow: 0 0 2px #052e16;
}

.piece.piece-red {
  color: #ef4444;
  text-shadow: 0 0 2px #450a0a;
}
#rooms-view {
  background: #fff;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rooms-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.rooms-table-section {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rooms-table {
  border: 1px solid #c1c9d2;
  border-radius: 4px;
  background: #fff;
  max-height: 420px;
  overflow-y: auto;
  width: 100%;
  box-shadow: inset 0 1px 0 #e5e7eb;
}

.rooms-table-header,
.room-entry {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
}

.rooms-table-header {
  background: #f1f5f9;
  font-weight: 600;
}

.room-entry {
  cursor: pointer;
  transition: background 0.2s ease;
}

.room-entry:hover {
  background: #eef2ff;
}

.rooms-map-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
