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

body {
  font-family: Arial, sans-serif;
  background-color: #e9ebee;
  line-height: 1.6;
}

/* CONNECTION STATUS ICON */
.status-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 8px;
  transition: all 0.3s ease;
}
.status-icon.red { background-color: #f44336; box-shadow: 0 0 5px #f44336; }
.status-icon.green { background-color: #4CAF50; box-shadow: 0 0 5px #4CAF50; }
.status-icon.orange { background-color: #ff9800; box-shadow: 0 0 5px #ff9800; }

.status-container {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-text {
  font-weight: 500;
  color: #2c3e50;
}

/* TILE HIGHLIGHT STYLES */
.newly-placed {
  border: 2px solid #4CAF50;
  background-color: #e0ffe0;
}

.recommended-tile {
  background-color: #fff3cd;
  border: 2px dashed #ffcc00;
}

/* GENERAL LAYOUT */
.start-menu {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
}

.start-menu h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 2rem;
}

.start-menu-layout {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
}

.connection-panel,
.player-setup {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 350px;
}

.setup-field {
  margin-bottom: 1.5rem;
}

.setup-field label {
  display: block;
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.setup-field input,
.setup-field select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

/* CONNECTION LOG STYLES */
.connection-log {
  height: 150px;
  overflow-y: auto;
  margin: 1rem 0;
  padding: 0.5rem;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
}

.log-entry {
  padding: 4px 8px;
  margin: 4px 0;
  border-radius: 3px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.log-entry .timestamp {
  color: #666;
  font-size: 0.8rem;
  white-space: nowrap;
}

.log-entry .message {
  flex-grow: 1;
  word-break: break-word;
}

.log-entry.info {
  background-color: #e3f2fd;
  border-left: 3px solid #2196f3;
}

.log-entry.success {
  background-color: #e8f5e9;
  border-left: 3px solid #4caf50;
}

.log-entry.warning {
  background-color: #fff3e0;
  border-left: 3px solid #ff9800;
}

.log-entry.error {
  background-color: #ffebee;
  border-left: 3px solid #f44336;
}

.game-area {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
}

.panel-title {
  margin: 0.5rem 0;
}

.board-section {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 30px);
  grid-template-rows: repeat(15, 30px);
  gap: 1px;
  background: #666;
  padding: 5px;
  border: 2px solid #333;
  margin-bottom: 1rem;
}

.board div {
  width: 30px;
  height: 30px;
  background-color: #f0f0f0;
  text-align: center;
  vertical-align: middle;
  line-height: 30px;
  font-weight: bold;
}

.tile {
  width: 30px;
  height: 30px;
  background-color: #ffffcc;
  border: 1px solid #aaa;
  text-align: center;
  line-height: 30px;
  font-weight: bold;
  cursor: grab;
  transition: all 0.2s ease;
}

.tile:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tile.dragging {
  opacity: 0.5;
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.tile.placed {
  background-color: #e8f5e9;
  border-color: #4CAF50;
}

.tile.invalid {
  background-color: #ffebee;
  border-color: #ef9a9a;
}

.special-TW { background-color: #ff9999; position: relative; }
.special-DW { background-color: #ffcccc; position: relative; }
.special-TL { background-color: #9999ff; position: relative; }
.special-DL { background-color: #ccccff; position: relative; }

.score-panel,
.history-panel,
.chat-panel,
.rack-panel {
  background: #fff;
  padding: 0.5rem;
  border-radius: 6px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
}

.controls-row button {
  margin: 0.25rem;
  padding: 0.4rem 0.6rem;
}

.chat-log {
  flex-grow: 1;
  overflow-y: auto;
  margin: 1rem 0;
  padding: 0.5rem;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.chat-log .bot {
  color: #2e7d32;
  font-weight: bold;
  padding: 5px;
  margin: 5px 0;
  background-color: #e8f5e9;
  border-radius: 4px;
}

.chat-log .user {
  color: #1976d2;
  font-weight: bold;
  padding: 5px;
  margin: 5px 0;
  background-color: #e3f2fd;
  border-radius: 4px;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chat-input input {
  flex-grow: 1;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.timer {
  font-size: 1.2rem;
  font-weight: bold;
}

#recommendation-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.overlay.hidden {
  display: none;
}

.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fff;
  padding: 2rem;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
}

.modal-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

.stats-box {
  background: #fff;
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}

.brain-icon {
  animation: pulse 1s infinite alternate;
  margin-right: 8px;
}

@keyframes pulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* Error Message Styles */
.error-message {
  background-color: #ffebee;
  color: #c62828;
  padding: 10px;
  margin: 10px 0;
  border-radius: 4px;
  border: 1px solid #ef9a9a;
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.error-message.show {
  display: block;
}

/* Loading States */
.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Board Cell States */
.board-cell {
  width: 30px;
  height: 30px;
  background-color: #f0f0f0;
  text-align: center;
  vertical-align: middle;
  line-height: 30px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.board-cell:hover {
  background-color: #e0e0e0;
}

.board-cell.selected {
  background-color: #e3f2fd;
  border: 2px solid #2196f3;
}

.board-cell.invalid {
  background-color: #ffebee;
  border: 2px solid #ef9a9a;
}

/* Thinking Indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  color: #666;
  font-style: italic;
  margin: 5px 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Game Controls */
.game-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

/* Info Sections */
.info-section,
.move-history,
.player-racks,
.chat-interface {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Recommendation Controls */
.recommendation-controls {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* GAME STATUS AND TIMER */
.game-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.game-timer {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: bold;
  color: #2c3e50;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* BUTTON STATES */
.primary-button {
  background-color: #4CAF50;
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.primary-button:hover:not(:disabled) {
  background-color: #45a049;
  transform: translateY(-1px);
}

.primary-button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  opacity: 0.7;
}

.secondary-button {
  background-color: #f8f9fa;
  color: #2c3e50;
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.secondary-button:hover:not(:disabled) {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.secondary-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Add loading animation for retry button */
.secondary-button .fa-sync-alt {
  margin-right: 6px;
  transition: transform 0.3s ease;
}

.secondary-button:hover .fa-sync-alt {
  transform: rotate(180deg);
}

.secondary-button.loading .fa-sync-alt {
  animation: spin 1s linear infinite;
}

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

