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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: #f5f0e8;
  color: #2c3e50;
  min-height: 100vh;
}

/* Login Screen */
#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
  color: #2c3e50;
}

.login-subtitle {
  color: #7f8c8d;
  margin-bottom: 24px;
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form input[type="text"] {
  padding: 14px 16px;
  border: 2px solid #e0d5c7;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input[type="text"]:focus {
  border-color: #e67e22;
}

.color-picker {
  text-align: left;
}

.color-picker label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: #555;
}

.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.color-btn:hover {
  transform: scale(1.15);
}

.color-btn.selected {
  border-color: #2c3e50;
  transform: scale(1.15);
}

.login-players {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.login-players h3 {
  font-size: 14px;
  color: #888;
  margin-bottom: 12px;
}

#player-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #f8f4ee;
  font-size: 13px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.primary-btn {
  background: #e67e22;
  color: white;
}

.primary-btn:hover {
  background: #d35400;
}

.small-btn {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.tiny-btn {
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: #e74c3c;
  color: white;
}

/* App Header */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

header h1 {
  font-size: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.current-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-block;
}

/* Main Layout */
main {
  width: 100%;
}

#goals-section {
  padding: 28px;
  max-height: none;
}

#goals-section .kanban {
  min-height: 200px;
}

/* Messages Toggle Button */
.msg-toggle-btn {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  width: 48px;
  height: 120px;
  border: none;
  border-radius: 14px 0 0 14px;
  background: #e67e22;
  color: white;
  font-size: 20px;
  cursor: pointer;
  box-shadow: -2px 0 8px rgba(0,0,0,0.1);
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.msg-toggle-btn:hover {
  background: #d35400;
}

.msg-unread-badge {
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Messages Panel */
.messages-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 95;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  padding: 20px;
}

.messages-panel.open {
  right: 0;
}

.messages-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.messages-panel-header h2 {
  font-size: 18px;
}

.msg-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  transition: color 0.2s;
}

.msg-close-btn:hover {
  color: #333;
}

@media (max-width: 500px) {
  .messages-panel {
    width: 100%;
    right: -100%;
  }
}

/* Sections */
section {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#goals-section {
  padding: 28px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h2 {
  font-size: 22px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.paste-hint {
  font-size: 12px;
  color: #bbb;
  background: #f8f4ee;
  padding: 4px 10px;
  border-radius: 6px;
}

/* Messages */
.message-form {
  margin-bottom: 16px;
}

.message-form .image-preview {
  margin-top: 8px;
  padding: 8px;
  background: #faf8f4;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-form .image-preview img {
  max-height: 80px;
  border-radius: 6px;
}

.message-form .image-preview .preview-label {
  font-size: 12px;
  color: #888;
  flex: 1;
}

.message-form textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0d5c7;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.message-form textarea:focus {
  border-color: #e67e22;
}

.message-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.image-upload {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-btn {
  background: #ecf0f1;
  color: #555;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.upload-btn:hover {
  background: #dfe4e6;
}

.file-name {
  font-size: 12px;
  color: #888;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-list {
  max-height: 500px;
  overflow-y: auto;
}

.message-item {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #f0ebe4;
}

.message-item:last-child {
  border-bottom: none;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  font-size: 14px;
}

.message-time {
  font-size: 12px;
  color: #aaa;
}

.msg-delete-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #e74c3c;
  background: transparent;
  color: #e74c3c;
  cursor: pointer;
  margin-left: auto;
  font-family: inherit;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.msg-delete-btn:hover {
  opacity: 1;
  background: #fadbd8;
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-image {
  margin-top: 8px;
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.message-image:hover {
  opacity: 0.85;
}

/* Message actions */
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.msg-action-btn {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #e0d6c8;
  background: #f9f6f0;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #666;
}

.msg-action-btn:hover {
  background: #f0e8dc;
}

.msg-action-btn.liked {
  color: #2e7d32;
  border-color: #a5d6a7;
  background: #e8f5e9;
}

.msg-action-btn.disliked {
  color: #c62828;
  border-color: #ef9a9a;
  background: #ffebee;
}

/* Reply indicator */
.message-reply {
  margin-left: 36px;
  padding: 6px 10px;
  background: #faf8f4;
  border-radius: 8px;
  border-left: 2px solid #e0d6c8;
}

.message-replies {
  margin-top: 6px;
}

.reply-input {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.reply-input input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #e0d6c8;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #faf8f4;
}

.reply-input input:focus {
  border-color: #d4a373;
}

.tiny-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #d4a373;
  background: #d4a373;
  color: white;
  cursor: pointer;
  font-family: inherit;
}

.tiny-btn:hover {
  background: #c08a5e;
}

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 800px) {
  .kanban {
    grid-template-columns: 1fr;
  }
}

.kanban-column {
  background: #faf8f4;
  border-radius: 14px;
  padding: 16px;
  min-height: 200px;
}

.column-header {
  font-size: 16px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 1px;
}

.todo-header { background: #fef9e7; color: #b7950b; }
.progress-header { background: #d6eaf8; color: #1a5276; }
.done-header { background: #d5f5e3; color: #1e8449; }

.goal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  border: 1px solid #f0ebe4;
}

.goal-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.goal-done {
  opacity: 0.75;
  cursor: default;
  background: #fafafa;
}

.goal-done:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: none;
}

.goal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.goal-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}

.goal-priority {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  margin-left: 10px;
  font-weight: 500;
}

.priority-low { background: #eafaf1; color: #27ae60; }
.priority-medium { background: #fef9e7; color: #b7950b; }
.priority-high { background: #fdedec; color: #e74c3c; }
.priority-urgent { background: #fadbd8; color: #c0392b; }

.goal-meta {
  font-size: 13px;
  color: #888;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.goal-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.desc-text {
  color: #666;
  font-size: 13px;
  line-height: 1.5;
  background: #faf8f4;
  padding: 8px 10px;
  border-radius: 8px;
  margin-top: 4px;
}

.goal-thumbnail {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.goal-thumbnail:hover {
  opacity: 0.85;
}

.goal-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0ebe4;
}

.status-btn {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-weight: 500;
}

.status-btn:hover {
  background: #f0ebe4;
  transform: translateY(-1px);
}

.status-btn.done-btn { border-color: #27ae60; color: #27ae60; }
.status-btn.done-btn:hover { background: #d5f5e3; }

.status-btn.in-progress-btn { border-color: #3498db; color: #3498db; }
.status-btn.in-progress-btn:hover { background: #d6eaf8; }

.delete-btn {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #e74c3c;
  background: white;
  color: #e74c3c;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
  font-family: inherit;
  font-weight: 500;
}

.delete-btn:hover {
  background: #fadbd8;
  transform: translateY(-1px);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.close-btn {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #333;
}

.modal-image {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0d5c7;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #e67e22;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.image-preview {
  margin-top: 8px;
}

.image-preview img {
  max-width: 100%;
  max-height: 150px;
  border-radius: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  color: #bbb;
  padding: 20px;
  font-size: 14px;
}

/* Due date badge */
.due-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.due-ok { background: #eafaf1; color: #27ae60; }
.due-soon { background: #fef9e7; color: #b7950b; }
.due-overdue { background: #fadbd8; color: #c0392b; }
