/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: #f0f7e6;
  color: #3a2e1f;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: #6b8e23;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Navigation ===== */
.nav {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 12px 20px;
  background: #4a7c2e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav a {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 16px;
  border-radius: 20px;
  transition: background 0.2s;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.2);
  text-decoration: none;
}
.nav-github {
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.nav-github:hover {
  opacity: 1;
  background: none !important;
}

/* ===== Drawing Page ===== */
.draw-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}

.draw-title {
  font-size: 28px;
  font-weight: 800;
  margin: 16px 0 4px;
  color: #3a2e1f;
}

.draw-subtitle {
  font-size: 14px;
  color: #7a6b5a;
  margin-bottom: 16px;
}

.canvas-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  transition: background 0.3s;
  background: #fff;
}

#draw-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.ai-feedback {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  font-weight: 600;
  transition: color 0.3s;
}

/* ===== Tools Bar ===== */
.tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 320px;
}

/* Color palette grid */
.tools-color-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  justify-items: center;
}

.color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  padding: 0;
}
.color-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.color-btn.active {
  border-color: #3a2e1f;
  transform: scale(1.25);
  box-shadow: 0 0 0 2px rgba(58,46,31,0.2);
}

/* Action buttons row */
.tools-action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.size-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.size-label {
  font-size: 12px;
  font-weight: 700;
  color: #7a6b5a;
}

.tool-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: #e8e0d4;
  color: #3a2e1f;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.tool-btn:hover {
  background: #d4c9b8;
}
.tool-btn:active {
  transform: scale(0.95);
}
.tool-btn.active {
  background: #6b8e23;
  color: #fff;
}

.size-slider {
  width: 80px;
  accent-color: #6b8e23;
}

/* ===== Submit Button ===== */
.submit-btn {
  margin-top: 16px;
  padding: 14px 40px;
  font-size: 18px;
  font-weight: 800;
  border: none;
  border-radius: 30px;
  background: linear-gradient(135deg, #6b8e23, #8fbc3a);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(107,142,35,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(107,142,35,0.5);
}
.submit-btn:active {
  transform: translateY(0);
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal h2 {
  font-size: 22px;
  margin-bottom: 8px;
}
.modal p {
  color: #7a6b5a;
  margin-bottom: 20px;
  font-size: 14px;
}
.modal input[type="text"] {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid #d4c9b8;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.modal input[type="text"]:focus {
  border-color: #6b8e23;
}
.modal-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin: 0 6px;
  transition: transform 0.1s;
}
.modal-btn:active {
  transform: scale(0.95);
}
.modal-btn.primary {
  background: #6b8e23;
  color: #fff;
}
.modal-btn.primary:disabled {
  background: #b8b8b8;
  cursor: not-allowed;
  opacity: 0.6;
}
.modal-btn.secondary {
  background: #e8e0d4;
  color: #3a2e1f;
}

.modal.good {
  border-top: 4px solid #6b8e23;
}
.modal.bad {
  border-top: 4px solid #c0392b;
}

/* ===== Meadow Page ===== */
.meadow-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 48px);
  overflow: hidden;
}

#meadow-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.meadow-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.meadow-controls button {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.9);
  color: #3a2e1f;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.1s;
}
.meadow-controls button:hover {
  transform: scale(1.05);
}

.mushroom-count {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.9);
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 10;
}

/* ===== Info Modal (Meadow) ===== */
.info-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.info-modal.show {
  display: flex;
}
.info-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.info-card img {
  max-width: 200px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #f9f6f0;
  padding: 8px;
}
.info-card .artist {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}
.info-card .date {
  font-size: 12px;
  color: #999;
  margin-bottom: 12px;
}
.vote-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.vote-btn {
  padding: 8px 20px;
  border: 2px solid #d4c9b8;
  border-radius: 20px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.vote-btn:hover {
  background: #f0f7e6;
  border-color: #6b8e23;
}
.vote-btn .count {
  margin-left: 4px;
  color: #999;
}

/* ===== Ranking Page ===== */
.rank-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.rank-title {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin: 16px 0 12px;
  color: #3a2e1f;
}

.rank-sort {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.sort-btn {
  padding: 8px 20px;
  border: 2px solid #d4c9b8;
  border-radius: 20px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.sort-btn:hover {
  background: #f0f7e6;
  border-color: #6b8e23;
}
.sort-btn.active {
  background: #6b8e23;
  color: #fff;
  border-color: #6b8e23;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.rank-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-radius: 14px;
  padding: 14px 10px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transition: transform 0.1s;
  position: relative;
}
.rank-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}

.rank-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: #6b8e23;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.rank-img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 8px;
  background: #f9f6f0;
  padding: 4px;
}

.rank-info {
  width: 100%;
  text-align: center;
  margin-top: 8px;
}

.rank-artist {
  font-weight: 700;
  font-size: 14px;
  color: #3a2e1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-date {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.rank-score {
  font-size: 12px;
  font-weight: 800;
  color: #6b8e23;
  margin-top: 2px;
}

.rank-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.rank-vote-btn {
  padding: 3px 8px;
  border: 1.5px solid #d4c9b8;
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.rank-vote-btn:hover {
  border-color: #6b8e23;
  background: #f0f7e6;
}
.rank-vote-btn.up:hover {
  color: #27ae60;
}
.rank-vote-btn.down:hover {
  color: #c0392b;
}

.rank-report-btn {
  padding: 3px 8px;
  border: 1.5px solid #d4c9b8;
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
  color: #c0392b;
  cursor: pointer;
  transition: all 0.15s;
}
.rank-report-btn:hover {
  border-color: #c0392b;
  background: rgba(192,57,43,0.08);
}

.rank-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.rank-delete-btn:hover {
  color: #c0392b;
  background: rgba(192,57,43,0.1);
}

.rank-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.page-btn {
  width: 36px;
  height: 36px;
  border: 2px solid #d4c9b8;
  border-radius: 50%;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.page-btn:hover {
  background: #f0f7e6;
  border-color: #6b8e23;
}
.page-btn.active {
  background: #6b8e23;
  color: #fff;
  border-color: #6b8e23;
}

@media (max-width: 768px) {
  .rank-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

.rank-empty {
  text-align: center;
  padding: 60px 20px;
  color: #7a6b5a;
  font-size: 16px;
}

/* ===== Admin Page ===== */
.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.admin-title {
  font-size: 24px;
  font-weight: 800;
  color: #3a2e1f;
  margin-bottom: 20px;
  text-align: center;
}

.admin-denied {
  text-align: center;
  padding: 60px 20px;
  color: #c0392b;
  font-size: 16px;
}

.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

.admin-card-img {
  flex-shrink: 0;
}

.admin-card-img img {
  width: 80px;
  height: 100px;
  object-fit: contain;
  border-radius: 8px;
  background: #f9f6f0;
  padding: 4px;
}

.admin-card-info {
  flex: 1;
  min-width: 0;
}

.admin-card-artist {
  font-weight: 700;
  font-size: 15px;
  color: #3a2e1f;
}

.admin-card-reason {
  font-size: 13px;
  color: #555;
  margin-top: 4px;
}

.admin-card-date {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.admin-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.admin-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.admin-btn:hover {
  opacity: 0.85;
}

.admin-btn.delete {
  background: #c0392b;
  color: #fff;
}

.admin-btn.dismiss {
  background: #d4c9b8;
  color: #3a2e1f;
}

.admin-empty {
  text-align: center;
  padding: 60px 20px;
  color: #6b8e23;
  font-size: 16px;
  font-weight: 700;
}

/* ===== Login Page ===== */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 20px;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin: 24px 0 16px;
  color: #3a2e1f;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #d4c9b8;
}

.login-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f5f0e8;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.login-tab.active {
  background: #6b8e23;
  color: #fff;
}

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

.login-form input {
  padding: 12px 16px;
  border: 2px solid #d4c9b8;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.login-form input:focus {
  border-color: #6b8e23;
}

.login-submit {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #6b8e23;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.login-submit:hover {
  background: #5a7a1e;
}

.login-divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
  color: #999;
  font-size: 13px;
}
.login-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #d4c9b8;
}
.login-divider span {
  background: #fff;
  padding: 0 12px;
  position: relative;
}

.google-btn {
  width: 100%;
  padding: 12px;
  border: 2px solid #d4c9b8;
  border-radius: 10px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.google-btn:hover {
  border-color: #4285f4;
  background: #f0f4ff;
}

.login-error {
  margin-top: 12px;
  color: #c0392b;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-height: 18px;
}

/* ===== Nav Auth ===== */
.nav-user {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
}
#nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
}
#nav-auth a {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 16px;
  border-radius: 20px;
  transition: background 0.2s;
}
#nav-auth a:hover {
  background: rgba(255,255,255,0.2);
  text-decoration: none;
}

/* ===== Profile Page ===== */
.profile-container {
  max-width: 460px;
  margin: 0 auto;
  padding: 20px;
}

.profile-login-prompt {
  text-align: center;
  padding: 60px 20px;
}
.profile-login-prompt h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #3a2e1f;
}
.profile-login-prompt p {
  color: #7a6b5a;
  margin-bottom: 20px;
}

.profile-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #6b8e23;
  color: #fff;
  font-size: 32px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.profile-name-row {
  position: relative;
  text-align: center;
}

.profile-name {
  font-size: 22px;
  font-weight: 800;
  color: #3a2e1f;
}

.profile-edit-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #7a6b5a;
  padding: 4px;
  transition: color 0.15s;
}
.profile-edit-btn:hover {
  color: #6b8e23;
}

.profile-name-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.profile-name-edit input {
  padding: 8px 12px;
  border: 2px solid #d4c9b8;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  width: 180px;
}
.profile-name-edit input:focus {
  border-color: #6b8e23;
}

.profile-date {
  font-size: 13px;
  color: #999;
  margin-top: 6px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #3a2e1f;
}
.stat-value.stat-up {
  color: #27ae60;
}
.stat-value.stat-down {
  color: #c0392b;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: #7a6b5a;
  margin-top: 4px;
}

.profile-actions {
  display: flex;
  gap: 10px;
}

.profile-action-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid #d4c9b8;
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.profile-action-btn:hover {
  border-color: #6b8e23;
  background: #f0f7e6;
}

.profile-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #27ae60;
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  transition: transform 0.3s;
  z-index: 2000;
}
.profile-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
  /* Nav */
  .nav {
    gap: 6px;
    padding: 10px 8px;
  }
  .nav a {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Drawing Page */
  .draw-container { padding: 12px; }
  #draw-canvas { width: 100%; height: auto; }
  .draw-title { font-size: 20px; margin: 8px 0; }
  .tools { gap: 6px; padding: 8px 10px; max-width: 100%; }
  .color-btn { width: 24px; height: 24px; }
  .submit-btn { padding: 12px 30px; font-size: 15px; }

  /* Rank Page */
  .rank-container { padding: 12px; }
  .rank-title { font-size: 22px; margin: 10px 0 8px; }
  .rank-sort { gap: 6px; flex-wrap: wrap; }
  .sort-btn { padding: 6px 14px; font-size: 12px; }
  .rank-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .rank-card { padding: 10px 8px; }
  .rank-img { height: 110px; }
  .rank-artist { font-size: 12px; }
  .rank-score { font-size: 11px; }
  .rank-actions { gap: 4px; }
  .rank-vote-btn { padding: 4px 10px; font-size: 14px; }
  .rank-report-btn { padding: 4px 10px; font-size: 14px; }

  /* Meadow Page */
  .mushroom-count { font-size: 12px; padding: 4px 10px; }
  .meadow-controls button { padding: 6px 12px; font-size: 12px; }

  /* Profile Page */
  .profile-container { padding: 12px; }
  .profile-card { padding: 20px 16px; }
  .profile-avatar { width: 60px; height: 60px; font-size: 26px; }
  .profile-name { font-size: 20px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 11px; }
  .profile-actions { gap: 8px; }
  .profile-action-btn { padding: 10px 16px; font-size: 13px; }

  /* Nav Auth */
  #nav-auth a { font-size: 13px; padding: 5px 10px; }

  /* Login Page */
  .login-container { padding: 12px; }
  .login-card { padding: 20px 16px; }
  .login-title { font-size: 22px; }

  /* Admin Page */
  .admin-container { padding: 12px; }
  .admin-card { flex-direction: column; text-align: center; padding: 14px; }
  .admin-card-actions { flex-direction: row; }
}
