:root {
  --bg: #f6efe4;
  --bg-accent: #ede1cf;
  --card: #fffaf2;
  --wood: #e7d4ba;
  --wood-border: #cfa97e;
  --ink: #3c2f25;
  --muted: #7a6655;
  --primary: #b86234;
  --primary-hover: #9f5026;
  --ok: #3a7d58;
  --err: #c24b3f;
  --shadow: 0 10px 28px rgba(72, 48, 24, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fbf6ee 0%, var(--bg) 55%, var(--bg-accent) 100%);
  user-select: none;
  -webkit-user-select: none;
}

.page-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 18px 28px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

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

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--wood);
  border: 2px solid var(--wood-border);
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  background: var(--wood);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--wood-border);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.mode-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.primary-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.1s ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.primary-btn:active {
  transform: scale(0.98);
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border: 1px solid #e7d8c5;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 4px 12px rgba(72, 48, 24, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.stat-value.warn {
  color: var(--err);
}

.workspace {
  display: grid;
  gap: 16px;
}

.zones-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.drop-zone {
  background: var(--card);
  border: 2px dashed var(--wood-border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 156px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #fff4e6;
  transform: translateY(-2px);
}

.drop-zone.flash-ok {
  border-color: var(--ok);
  background: #edf7f0;
}

.drop-zone.flash-err {
  border-color: var(--err);
  background: #fdeeed;
  animation: shake 0.28s ease;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.zone-icon {
  font-size: 24px;
  line-height: 1;
}

.zone-header h2 {
  margin: 0;
  font-size: 15px;
}

.zone-header p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.zone-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
}

.sorted-chip {
  font-size: 12px;
  background: #f3e8d8;
  border: 1px solid #dfc8aa;
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: popIn 0.18s ease;
}

.desk-surface {
  background: linear-gradient(180deg, #ebd8be 0%, #e1c7a6 100%);
  border: 2px solid var(--wood-border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.surface-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.hint-text {
  color: var(--muted);
  font-weight: 400;
}

.desk-board {
  min-height: 220px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  padding: 6px 2px;
}

.desk-item {
  background: var(--card);
  border: 2px solid #e4d2bc;
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 110px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: grab;
  box-shadow: 0 5px 12px rgba(60, 40, 20, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.desk-item:hover {
  transform: translateY(-2px);
  border-color: var(--wood-border);
}

.desk-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184, 98, 52, 0.22);
  transform: translateY(-3px) scale(1.03);
}

.desk-item.dragging {
  opacity: 0.45;
}

.item-emoji {
  font-size: 30px;
  line-height: 1;
}

.item-name {
  font-size: 13px;
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 32, 20, 0.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  border: 2px solid var(--wood-border);
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.modal-emoji {
  font-size: 46px;
  margin-bottom: 8px;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.modal-card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 860px) {
  .zones-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .desk-item {
    min-width: 92px;
    padding: 10px;
  }
}
